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\Persistence; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ComputopNotificationTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer; |
|
|
|
|
12
|
|
|
use Orm\Zed\Computop\Persistence\SpyPaymentComputopDetail; |
|
|
|
|
13
|
|
|
use Propel\Runtime\Collection\ObjectCollection; |
14
|
|
|
use Spryker\Zed\Kernel\Persistence\AbstractEntityManager; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @method \SprykerEco\Zed\Computop\Persistence\ComputopPersistenceFactory getFactory() |
18
|
|
|
*/ |
19
|
|
|
class ComputopEntityManager extends AbstractEntityManager implements ComputopEntityManagerInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function savePaymentComputopNotification(ComputopNotificationTransfer $computopNotificationTransfer): void |
27
|
|
|
{ |
28
|
|
|
$paymentComputopNotificationEntity = $this->getFactory() |
29
|
|
|
->createPaymentComputopNotificationQuery() |
30
|
|
|
->filterByPayId($computopNotificationTransfer->getPayId()) |
31
|
|
|
->filterByTransId($computopNotificationTransfer->getTransId()) |
32
|
|
|
->filterByXId($computopNotificationTransfer->getXId()) |
33
|
|
|
->findOneOrCreate(); |
34
|
|
|
|
35
|
|
|
$paymentComputopNotificationEntity->fromArray( |
36
|
|
|
$computopNotificationTransfer->modifiedToArray() |
37
|
|
|
); |
38
|
|
|
$paymentComputopNotificationEntity->save(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param \Generated\Shared\Transfer\ComputopNotificationTransfer $computopNotificationTransfer |
43
|
|
|
* @param string $orderItemsStatus |
44
|
|
|
* |
45
|
|
|
* @return bool |
46
|
|
|
*/ |
47
|
|
|
public function updatePaymentComputopOrderItemPaymentConfirmation( |
48
|
|
|
ComputopNotificationTransfer $computopNotificationTransfer, |
49
|
|
|
string $orderItemsStatus |
50
|
|
|
): bool { |
51
|
|
|
/** @var \Orm\Zed\Computop\Persistence\SpyPaymentComputopOrderItem[]|\Propel\Runtime\Collection\ObjectCollection $paymentComputopOrderItemEntities */ |
52
|
|
|
$paymentComputopOrderItemEntities = $this->getFactory() |
53
|
|
|
->createPaymentComputopOrderItemQuery() |
54
|
|
|
->useSpyPaymentComputopQuery() |
55
|
|
|
->filterByTransId($computopNotificationTransfer->getTransId()) |
56
|
|
|
->filterByPayId($computopNotificationTransfer->getPayId()) |
57
|
|
|
->endUse() |
58
|
|
|
->find(); |
59
|
|
|
|
60
|
|
|
if (!$paymentComputopOrderItemEntities->count()) { |
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
foreach ($paymentComputopOrderItemEntities as $paymentComputopOrderItemEntity) { |
65
|
|
|
$paymentComputopOrderItemEntity |
66
|
|
|
->setIsPaymentConfirmed((bool)$computopNotificationTransfer->getIsSuccess()) |
67
|
|
|
->setStatus($orderItemsStatus) |
68
|
|
|
->save(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
76
|
|
|
* @param string $orderItemsStatus |
77
|
|
|
* |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
public function saveComputopPayuCeeSingleInitResponse( |
81
|
|
|
ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer, |
82
|
|
|
string $orderItemsStatus |
83
|
|
|
): void { |
84
|
|
|
$computopApiResponseHeaderTransfer = $computopPayuCeeSingleInitResponseTransfer->requireHeader() |
85
|
|
|
->getHeader() |
86
|
|
|
->requireTransId() |
87
|
|
|
->requirePayId() |
88
|
|
|
->requireXid(); |
89
|
|
|
|
90
|
|
|
$paymentComputopEntity = $this->getFactory() |
91
|
|
|
->createPaymentComputopQuery() |
92
|
|
|
->filterByTransId($computopApiResponseHeaderTransfer->getTransId()) |
93
|
|
|
->findOne(); |
94
|
|
|
|
95
|
|
|
if (!$paymentComputopEntity) { |
96
|
|
|
return; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$paymentComputopEntity |
100
|
|
|
->setPayId($computopApiResponseHeaderTransfer->getPayId()) |
101
|
|
|
->setXId($computopApiResponseHeaderTransfer->getXId()) |
102
|
|
|
->save(); |
103
|
|
|
|
104
|
|
|
$this->savePaymentComputopDetailEntity( |
105
|
|
|
$paymentComputopEntity->getSpyPaymentComputopDetail(), |
106
|
|
|
$computopPayuCeeSingleInitResponseTransfer |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
$this->savePaymentComputopOrderItems($paymentComputopEntity->getSpyPaymentComputopOrderItems(), $orderItemsStatus); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param \Orm\Zed\Computop\Persistence\SpyPaymentComputopDetail $paymentComputopDetailEntity |
114
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
115
|
|
|
* |
116
|
|
|
* @return void |
117
|
|
|
*/ |
118
|
|
|
protected function savePaymentComputopDetailEntity( |
119
|
|
|
SpyPaymentComputopDetail $paymentComputopDetailEntity, |
120
|
|
|
ComputopPayuCeeSingleInitResponseTransfer $computopPayuCeeSingleInitResponseTransfer |
121
|
|
|
): void { |
122
|
|
|
$paymentComputopDetailEntity->fromArray($computopPayuCeeSingleInitResponseTransfer->toArray()); |
123
|
|
|
$customerTransactionId = $computopPayuCeeSingleInitResponseTransfer->getCustomerTransactionId(); |
124
|
|
|
if ($customerTransactionId) { |
125
|
|
|
$paymentComputopDetailEntity->setCustomerTransactionId((int)$customerTransactionId); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
$paymentComputopDetailEntity->save(); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param \Orm\Zed\Computop\Persistence\SpyPaymentComputopOrderItem[]|\Propel\Runtime\Collection\ObjectCollection $paymentComputopOrderItemEntities |
133
|
|
|
* @param string $paymentStatus |
134
|
|
|
* |
135
|
|
|
* @return void |
136
|
|
|
*/ |
137
|
|
|
public function savePaymentComputopOrderItems(ObjectCollection $paymentComputopOrderItemEntities, string $paymentStatus): void |
138
|
|
|
{ |
139
|
|
|
foreach ($paymentComputopOrderItemEntities as $paymentComputopOrderItem) { |
140
|
|
|
$paymentComputopOrderItem->setStatus($paymentStatus); |
141
|
|
|
$paymentComputopOrderItem->save(); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
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