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 Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
12
|
|
|
use SprykerEco\Shared\Computop\ComputopConfig; |
13
|
|
|
|
14
|
|
|
class PayuCeeSingleResponseSaver extends AbstractResponseSaver |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
18
|
|
|
* |
19
|
|
|
* @return \Generated\Shared\Transfer\QuoteTransfer |
20
|
|
|
*/ |
21
|
|
|
public function save(QuoteTransfer $quoteTransfer): QuoteTransfer |
22
|
|
|
{ |
23
|
|
|
if ( |
24
|
|
|
!$quoteTransfer->getPayment() || |
25
|
|
|
!$quoteTransfer->getPayment()->getComputopPayuCeeSingle() || |
26
|
|
|
!$quoteTransfer->getPayment()->getComputopPayuCeeSingle()->getPayuCeeSingleInitResponse() |
27
|
|
|
) { |
28
|
|
|
return $quoteTransfer; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$responseTransfer = $quoteTransfer->getPayment()->getComputopPayuCeeSingle()->getPayuCeeSingleInitResponse(); |
32
|
|
|
if ($responseTransfer->getHeader()->getIsSuccess()) { |
33
|
|
|
$this->setPaymentEntity($responseTransfer->getHeader()->getTransId()); |
34
|
|
|
|
35
|
|
|
$this->getTransactionHandler()->handleTransaction(function () use ($responseTransfer) { |
36
|
|
|
$this->executeSavePaymentResponseTransaction($responseTransfer); |
37
|
|
|
}); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
return $quoteTransfer; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
protected function savePaymentComputopEntity(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer) |
49
|
|
|
{ |
50
|
|
|
$paymentEntity = $this->getPaymentEntity(); |
51
|
|
|
$paymentEntity->setPayId($responseTransfer->getHeader()->getPayId()); |
52
|
|
|
$paymentEntity->setXId($responseTransfer->getHeader()->getXId()); |
53
|
|
|
$paymentEntity->save(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
58
|
|
|
* |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
protected function savePaymentComputopDetailEntity(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer) |
62
|
|
|
{ |
63
|
|
|
$paymentEntityDetails = $this->getPaymentEntity()->getSpyPaymentComputopDetail(); |
64
|
|
|
$paymentEntityDetails->fromArray($responseTransfer->toArray()); |
65
|
|
|
|
66
|
|
|
if ($responseTransfer->getCustomerTransactionId()) { |
67
|
|
|
$paymentEntityDetails->setCustomerTransactionId((int)$responseTransfer->getCustomerTransactionId()); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$paymentEntityDetails->save(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer|null $responseTransfer |
75
|
|
|
* |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
protected function savePaymentComputopOrderItemsEntities(?ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): void |
79
|
|
|
{ |
80
|
|
|
$status = $this->getPaymentStatus($responseTransfer); |
81
|
|
|
|
82
|
|
|
foreach ($this->getPaymentEntity()->getSpyPaymentComputopOrderItems() as $item) { |
83
|
|
|
$item->setStatus($status); |
84
|
|
|
$item->save(); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer|null $responseTransfer |
90
|
|
|
* |
91
|
|
|
* @return void |
92
|
|
|
*/ |
93
|
|
|
protected function executeSavePaymentResponseTransaction(?ComputopPayuCeeSingleInitResponseTransfer $responseTransfer) |
94
|
|
|
{ |
95
|
|
|
$this->savePaymentComputopEntity($responseTransfer); |
|
|
|
|
96
|
|
|
$this->savePaymentComputopDetailEntity($responseTransfer); |
|
|
|
|
97
|
|
|
$this->savePaymentComputopOrderItemsEntities($responseTransfer); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer|null $responseTransfer |
102
|
|
|
* |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
protected function getPaymentStatus(?ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): string |
106
|
|
|
{ |
107
|
|
|
$responseStatus = $this->getResponseStatus($responseTransfer); |
108
|
|
|
if (!$responseTransfer) { |
109
|
|
|
return $this->config->getOmsStatusNew(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
if ($responseStatus === ComputopConfig::AUTHORIZE_REQUEST_STATUS) { |
113
|
|
|
return $this->config->getOmsStatusAuthorizeRequest(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
$responseDescription = $responseTransfer->getHeader()->getDescription(); |
117
|
|
|
if ($responseStatus === ComputopConfig::SUCCESS_OK && $responseDescription === ComputopConfig::SUCCESS_STATUS) { |
118
|
|
|
return $this->config->getOmsStatusAuthorized(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
return $this->config->getOmsStatusNew(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer|null $responseTransfer |
126
|
|
|
* |
127
|
|
|
* @return string|null |
128
|
|
|
*/ |
129
|
|
|
protected function getResponseStatus(?ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): ?string |
130
|
|
|
{ |
131
|
|
|
if ($responseTransfer && $responseTransfer->getHeader()) { |
132
|
|
|
return $responseTransfer->getHeader()->getStatus(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
return null; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
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