|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\CrefoPay\Quote; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\CrefoPayTransactionTransfer; |
|
|
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
|
|
12
|
|
|
use SprykerEco\Client\CrefoPay\CrefoPayClientInterface; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
14
|
|
|
|
|
15
|
|
|
class CrefoPayQuoteExpander implements CrefoPayQuoteExpanderInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \SprykerEco\Client\CrefoPay\CrefoPayClientInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
protected CrefoPayClientInterface $client; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param \SprykerEco\Client\CrefoPay\CrefoPayClientInterface $client |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct(CrefoPayClientInterface $client) |
|
26
|
|
|
{ |
|
27
|
|
|
$this->client = $client; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
32
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
33
|
|
|
* |
|
34
|
|
|
* @return \Generated\Shared\Transfer\QuoteTransfer |
|
35
|
|
|
*/ |
|
36
|
|
|
public function expand(Request $request, QuoteTransfer $quoteTransfer): QuoteTransfer |
|
37
|
|
|
{ |
|
38
|
|
|
if (!$this->shouldTransactionBeExecuted($quoteTransfer)) { |
|
39
|
|
|
return $quoteTransfer; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$quoteTransfer->setCrefoPayTransaction( |
|
43
|
|
|
$this->createCrefoPayTransactionTransfer($request), |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
return $this->client->startCrefoPayTransaction($quoteTransfer); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
51
|
|
|
* |
|
52
|
|
|
* @return \Generated\Shared\Transfer\CrefoPayTransactionTransfer |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function createCrefoPayTransactionTransfer(Request $request): CrefoPayTransactionTransfer |
|
55
|
|
|
{ |
|
56
|
|
|
return (new CrefoPayTransactionTransfer()) |
|
57
|
|
|
->setClientIp($request->getClientIp()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
62
|
|
|
* |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function shouldTransactionBeExecuted(QuoteTransfer $quoteTransfer): bool |
|
66
|
|
|
{ |
|
67
|
|
|
$crefoPayTransaction = $quoteTransfer->getCrefoPayTransaction(); |
|
68
|
|
|
if ( |
|
69
|
|
|
$crefoPayTransaction === null |
|
70
|
|
|
|| !$crefoPayTransaction->getIsSuccess() |
|
71
|
|
|
) { |
|
72
|
|
|
return true; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if (!$quoteTransfer->getBillingAddress() || !$crefoPayTransaction->getBillingAddress()) { |
|
76
|
|
|
return true; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return $quoteTransfer->getBillingAddressOrFail()->getIso2Code() !== $crefoPayTransaction->getBillingAddressOrFail()->getCountry(); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths