1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer; |
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
13
|
|
|
use SprykerEco\Zed\Computop\ComputopConfig; |
14
|
|
|
use SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface; |
15
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface; |
16
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface; |
17
|
|
|
|
18
|
|
|
class PayuCeeSingleResponseSaver extends AbstractResponseSaver |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface |
22
|
|
|
*/ |
23
|
|
|
protected $computopEntityManager; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface $queryContainer |
27
|
|
|
* @param \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface $omsFacade |
28
|
|
|
* @param \SprykerEco\Zed\Computop\ComputopConfig $config |
29
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface $computopEntityManager |
30
|
|
|
*/ |
31
|
|
|
public function __construct( |
32
|
|
|
ComputopQueryContainerInterface $queryContainer, |
33
|
|
|
ComputopToOmsFacadeInterface $omsFacade, |
34
|
|
|
ComputopConfig $config, |
35
|
|
|
ComputopEntityManagerInterface $computopEntityManager |
36
|
|
|
) { |
37
|
|
|
parent::__construct($queryContainer, $omsFacade, $config); |
38
|
|
|
$this->computopEntityManager = $computopEntityManager; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
43
|
|
|
* |
44
|
|
|
* @return \Generated\Shared\Transfer\QuoteTransfer |
45
|
|
|
*/ |
46
|
|
|
public function save(QuoteTransfer $quoteTransfer): QuoteTransfer |
47
|
|
|
{ |
48
|
|
|
$computopPayuCeeSingleInitResponse = $this->getPayuCeeSingleInitResponseFromQuoteTransfer($quoteTransfer); |
49
|
|
|
if (!$computopPayuCeeSingleInitResponse) { |
50
|
|
|
return $quoteTransfer; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$computopApiResponseHeaderTransfer = $computopPayuCeeSingleInitResponse->getHeaderOrFail() |
54
|
|
|
->requireTransId() |
55
|
|
|
->requirePayId() |
56
|
|
|
->requireXid(); |
57
|
|
|
|
58
|
|
|
if (!$computopApiResponseHeaderTransfer->getIsSuccess()) { |
59
|
|
|
return $quoteTransfer; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
$this->setPaymentEntity($computopApiResponseHeaderTransfer->getTransId()); |
63
|
|
|
if (!$this->getPaymentEntity()) { |
64
|
|
|
return $quoteTransfer; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$this->handleSaveTransaction($computopPayuCeeSingleInitResponse); |
68
|
|
|
|
69
|
|
|
return $quoteTransfer; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
protected function handleSaveTransaction( |
78
|
|
|
ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
79
|
|
|
): void { |
80
|
|
|
$this->getTransactionHandler()->handleTransaction(function () use ($computopPayuCeeSingleInitResponseTransfer) { |
81
|
|
|
$this->executeSavePaymentResponseTransaction($computopPayuCeeSingleInitResponseTransfer); |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
87
|
|
|
* |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
protected function executeSavePaymentResponseTransaction( |
91
|
|
|
ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
92
|
|
|
): void { |
93
|
|
|
$this->computopEntityManager->updatePaymentComputopEntityByComputopApiResponseHeaderTransfer( |
94
|
|
|
$computopPayuCeeSingleInitResponseTransfer->getHeader(), |
95
|
|
|
$this->getPaymentEntity() |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
if ($this->getPaymentEntity()->getSpyPaymentComputopDetail()) { |
99
|
|
|
$this->computopEntityManager->updatePaymentComputopDetailEntityByComputopApiResponseHeaderTransfer( |
100
|
|
|
$this->getPaymentEntity()->getSpyPaymentComputopDetail(), |
101
|
|
|
$computopPayuCeeSingleInitResponseTransfer |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$this->computopEntityManager->updatePaymentComputopOrderItemsStatus( |
106
|
|
|
$this->getPaymentEntity()->getSpyPaymentComputopOrderItems(), |
107
|
|
|
$this->getOrderItemPaymentStatusFromResponseHeader($computopPayuCeeSingleInitResponseTransfer->getHeader()) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
113
|
|
|
* |
114
|
|
|
* @return \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer|null |
115
|
|
|
*/ |
116
|
|
|
protected function getPayuCeeSingleInitResponseFromQuoteTransfer(QuoteTransfer $quoteTransfer): ?ComputopPayuCeeSingleInitResponseTransfer |
117
|
|
|
{ |
118
|
|
|
$computopPayuCeeSinglePaymentTransfer = $this->getComputopPayuCeeSinglePaymentTransferFromQuote($quoteTransfer); |
119
|
|
|
if (!($computopPayuCeeSinglePaymentTransfer && $computopPayuCeeSinglePaymentTransfer->getPayuCeeSingleInitResponse())) { |
120
|
|
|
return null; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $computopPayuCeeSinglePaymentTransfer->getPayuCeeSingleInitResponse(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
128
|
|
|
* |
129
|
|
|
* @return \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer|null |
130
|
|
|
*/ |
131
|
|
|
protected function getComputopPayuCeeSinglePaymentTransferFromQuote(QuoteTransfer $quoteTransfer): ?ComputopPayuCeeSinglePaymentTransfer |
132
|
|
|
{ |
133
|
|
|
foreach ($quoteTransfer->getPayments() as $paymentTransfer) { |
134
|
|
|
if ($paymentTransfer->getComputopPayuCeeSingle()) { |
135
|
|
|
return $paymentTransfer->getComputopPayuCeeSingle(); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return $quoteTransfer->getPayment() ? $quoteTransfer->getPayment()->getComputopPayuCeeSingle() : null; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
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