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