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
|
|
|
|
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
|
|
|
* |
44
|
|
|
* @return bool |
45
|
|
|
*/ |
46
|
|
|
public function updatePaymentComputopOrderItemPaymentConfirmation( |
47
|
|
|
ComputopNotificationTransfer $computopNotificationTransfer |
48
|
|
|
): bool { |
49
|
|
|
/** @var \Orm\Zed\Computop\Persistence\SpyPaymentComputopOrderItem[]|\Propel\Runtime\Collection\ObjectCollection $paymentComputopOrderItemEntities */ |
50
|
|
|
$paymentComputopOrderItemEntities = $this->getFactory() |
51
|
|
|
->createPaymentComputopOrderItemQuery() |
52
|
|
|
->useSpyPaymentComputopQuery() |
53
|
|
|
->filterByTransId($computopNotificationTransfer->getTransId()) |
54
|
|
|
->filterByPayId($computopNotificationTransfer->getPayId()) |
55
|
|
|
->endUse() |
56
|
|
|
->find(); |
57
|
|
|
|
58
|
|
|
if (!$paymentComputopOrderItemEntities->count()) { |
59
|
|
|
return false; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
foreach ($paymentComputopOrderItemEntities as $paymentComputopOrderItemEntity) { |
63
|
|
|
$paymentComputopOrderItemEntity->setIsPaymentConfirmed((bool)$computopNotificationTransfer->getIsSuccess()); |
64
|
|
|
$paymentComputopOrderItemEntity->save(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return true; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
|
|
|
|
72
|
|
|
* |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
|
|
public function savePaymentResponse(TransferInterface $responseTransfer): void |
76
|
|
|
{ |
77
|
|
|
$header = $responseTransfer->requireHeader()->getHeader(); |
|
|
|
|
78
|
|
|
$header |
79
|
|
|
->requireTransId() |
80
|
|
|
->requirePayId() |
81
|
|
|
->requireXid(); |
82
|
|
|
|
83
|
|
|
$paymentEntity = $this->getFactory() |
84
|
|
|
->createPaymentComputopQuery() |
85
|
|
|
->filterByTransId($header->getTransId()) |
86
|
|
|
->findOne(); |
87
|
|
|
|
88
|
|
|
$paymentEntity |
89
|
|
|
->setPayId($header->getPayId()) |
90
|
|
|
->setXId($header->getXId()) |
91
|
|
|
->save(); |
92
|
|
|
|
93
|
|
|
$this->savePaymentDetailEntity($paymentEntity->getSpyPaymentComputopDetail(), $responseTransfer); |
94
|
|
|
|
95
|
|
|
$this->saveAuthorizedPaymentOrderItems($paymentEntity->getSpyPaymentComputopOrderItems()); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param \Orm\Zed\Computop\Persistence\SpyPaymentComputopDetail $paymentEntityDetails |
100
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
101
|
|
|
* |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
|
public function savePaymentDetailEntity( |
105
|
|
|
SpyPaymentComputopDetail $paymentEntityDetails, |
106
|
|
|
TransferInterface $responseTransfer |
107
|
|
|
): void { |
108
|
|
|
$paymentEntityDetails->fromArray($responseTransfer->toArray()); |
109
|
|
|
$paymentEntityDetails->setCustomerTransactionId($responseTransfer->getCustomerTransactionId()); |
|
|
|
|
110
|
|
|
$paymentEntityDetails->save(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param \Orm\Zed\Computop\Persistence\SpyPaymentComputopOrderItem[]|\Propel\Runtime\Collection\ObjectCollection $paymentComputopOrderItems |
115
|
|
|
* |
116
|
|
|
* @return void |
117
|
|
|
*/ |
118
|
|
|
public function saveAuthorizedPaymentOrderItems(ObjectCollection $paymentComputopOrderItems): void |
119
|
|
|
{ |
120
|
|
|
$authorizedStatus = $this->getFactory()->getConfig()->getOmsStatusAuthorized(); |
121
|
|
|
foreach ($paymentComputopOrderItems as $paymentComputopOrderItem) { |
122
|
|
|
$paymentComputopOrderItem->setStatus($authorizedStatus); |
123
|
|
|
$paymentComputopOrderItem->save(); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
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