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\ComputopPaymentComputopOrderItemCollectionTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\ComputopPaymentComputopTransfer; |
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer; |
|
|
|
|
13
|
|
|
use Generated\Shared\Transfer\ComputopSalesOrderItemTransfer; |
|
|
|
|
14
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
15
|
|
|
use Spryker\Zed\Kernel\Persistence\EntityManager\TransactionTrait; |
16
|
|
|
use SprykerEco\Zed\Computop\ComputopConfig; |
17
|
|
|
use SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface; |
18
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface; |
19
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopRepositoryInterface; |
20
|
|
|
|
21
|
|
|
class PayPalExpressResponseSaver implements InitResponseSaverInterface |
22
|
|
|
{ |
23
|
|
|
use TransactionTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface |
27
|
|
|
*/ |
28
|
|
|
protected $omsFacade; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \SprykerEco\Zed\Computop\ComputopConfig |
32
|
|
|
*/ |
33
|
|
|
protected $computopConfig; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \SprykerEco\Zed\Computop\Persistence\ComputopRepositoryInterface |
37
|
|
|
*/ |
38
|
|
|
protected $computopRepository; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface |
42
|
|
|
*/ |
43
|
|
|
protected $computopEntityManager; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface $omsFacade |
47
|
|
|
* @param \SprykerEco\Zed\Computop\ComputopConfig $computopConfig |
48
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopRepositoryInterface $computopRepository |
49
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface $computopEntityManager |
50
|
|
|
*/ |
51
|
|
|
public function __construct( |
52
|
|
|
ComputopToOmsFacadeInterface $omsFacade, |
53
|
|
|
ComputopConfig $computopConfig, |
54
|
|
|
ComputopRepositoryInterface $computopRepository, |
55
|
|
|
ComputopEntityManagerInterface $computopEntityManager |
56
|
|
|
) { |
57
|
|
|
$this->omsFacade = $omsFacade; |
58
|
|
|
$this->computopConfig = $computopConfig; |
59
|
|
|
$this->computopRepository = $computopRepository; |
60
|
|
|
$this->computopEntityManager = $computopEntityManager; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
65
|
|
|
* |
66
|
|
|
* @return \Generated\Shared\Transfer\QuoteTransfer |
67
|
|
|
*/ |
68
|
|
|
public function save(QuoteTransfer $quoteTransfer): QuoteTransfer |
69
|
|
|
{ |
70
|
|
|
$computopPayPalExpressInitResponseTransfer = $quoteTransfer->getPayment() |
71
|
|
|
->getComputopPayPalExpress() |
72
|
|
|
->getPayPalExpressInitResponse(); |
73
|
|
|
|
74
|
|
|
$computopPaymentComputopTransfer = $this->computopRepository |
75
|
|
|
->getComputopPaymentByComputopTransId( |
76
|
|
|
$computopPayPalExpressInitResponseTransfer->getHeader()->getTransId() |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
if ($computopPayPalExpressInitResponseTransfer->getHeader()->getIsSuccess()) { |
80
|
|
|
$this->getTransactionHandler()->handleTransaction( |
81
|
|
|
function () use ($computopPaymentComputopTransfer, $computopPayPalExpressInitResponseTransfer) { |
82
|
|
|
$this->executeSavePaymentComputopDataTransaction($computopPaymentComputopTransfer, $computopPayPalExpressInitResponseTransfer); |
83
|
|
|
} |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return $quoteTransfer; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer |
92
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
93
|
|
|
* |
94
|
|
|
* @return void |
95
|
|
|
*/ |
96
|
|
|
protected function executeSavePaymentComputopDataTransaction( |
97
|
|
|
ComputopPaymentComputopTransfer $computopPaymentComputopTransfer, |
98
|
|
|
ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
99
|
|
|
): void { |
100
|
|
|
$this->savePaymentComputopEntity($computopPaymentComputopTransfer, $computopPayPalExpressInitResponseTransfer); |
101
|
|
|
$this->savePaymentComputopDetailEntity($computopPaymentComputopTransfer, $computopPayPalExpressInitResponseTransfer); |
102
|
|
|
$this->savePaymentComputopOrderItemsEntities($computopPaymentComputopTransfer); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer |
107
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
|
|
*/ |
111
|
|
|
protected function savePaymentComputopEntity( |
112
|
|
|
ComputopPaymentComputopTransfer $computopPaymentComputopTransfer, |
113
|
|
|
ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
114
|
|
|
): void { |
115
|
|
|
$computopPaymentComputopTransfer->setPayId($computopPayPalExpressInitResponseTransfer->getHeader()->getPayId()); |
116
|
|
|
$computopPaymentComputopTransfer->setXId($computopPayPalExpressInitResponseTransfer->getHeader()->getXId()); |
117
|
|
|
|
118
|
|
|
$this->computopEntityManager->saveComputopPayment($computopPaymentComputopTransfer); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer |
123
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
124
|
|
|
* |
125
|
|
|
* @return void |
126
|
|
|
*/ |
127
|
|
|
protected function savePaymentComputopDetailEntity( |
128
|
|
|
ComputopPaymentComputopTransfer $computopPaymentComputopTransfer, |
129
|
|
|
ComputopPayPalExpressInitResponseTransfer $computopPayPalExpressInitResponseTransfer |
130
|
|
|
): void { |
131
|
|
|
$computopPaymentComputopDetailTransfer = $this->computopRepository |
132
|
|
|
->getComputopPaymentDetail($computopPaymentComputopTransfer); |
133
|
|
|
|
134
|
|
|
$computopPaymentComputopDetailTransfer->fromArray($computopPayPalExpressInitResponseTransfer->toArray(), true); |
135
|
|
|
|
136
|
|
|
$this->computopEntityManager->saveComputopPaymentDetail($computopPaymentComputopDetailTransfer); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param \Generated\Shared\Transfer\ComputopPaymentComputopTransfer $computopPaymentComputopTransfer |
141
|
|
|
* |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
protected function savePaymentComputopOrderItemsEntities( |
145
|
|
|
ComputopPaymentComputopTransfer $computopPaymentComputopTransfer |
146
|
|
|
): void { |
147
|
|
|
$salesOrderItemsCollectionTransfer = $this->computopRepository |
148
|
|
|
->getComputopSalesOrderItemsCollection($computopPaymentComputopTransfer); |
149
|
|
|
|
150
|
|
|
$computopPaymentComputopOrderItemsCollection = $this->computopRepository |
151
|
|
|
->getComputopPaymentComputopOrderItemsCollection($computopPaymentComputopTransfer); |
152
|
|
|
|
153
|
|
|
foreach ($salesOrderItemsCollectionTransfer->getComputopSalesOrderItems() as $computopSalesOrderItem) { |
154
|
|
|
$this->updateComputopSalesOrderItem( |
155
|
|
|
$computopPaymentComputopOrderItemsCollection, |
156
|
|
|
$computopSalesOrderItem |
157
|
|
|
); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param \Generated\Shared\Transfer\ComputopPaymentComputopOrderItemCollectionTransfer $computopPaymentComputopOrderItemsCollection |
163
|
|
|
* @param \Generated\Shared\Transfer\ComputopSalesOrderItemTransfer $computopSalesOrderItem |
164
|
|
|
* |
165
|
|
|
* @return void |
166
|
|
|
*/ |
167
|
|
|
protected function updateComputopSalesOrderItem( |
168
|
|
|
ComputopPaymentComputopOrderItemCollectionTransfer $computopPaymentComputopOrderItemsCollection, |
169
|
|
|
ComputopSalesOrderItemTransfer $computopSalesOrderItem |
170
|
|
|
): void { |
171
|
|
|
foreach ($computopPaymentComputopOrderItemsCollection->getComputopPaymentComputopOrderItems() as $computopPaymentComputopOrderItem) { |
172
|
|
|
if ($computopSalesOrderItem->getIdSalesOrderItem() !== $computopPaymentComputopOrderItem->getFkSalesOrderItem()) { |
173
|
|
|
continue; |
174
|
|
|
} |
175
|
|
|
$computopPaymentComputopOrderItem->setStatus($this->computopConfig->getOmsStatusInitialized()); |
176
|
|
|
$this->computopEntityManager->updateComputopPaymentComputopOrderItem($computopPaymentComputopOrderItem); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
} |
180
|
|
|
|
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