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