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