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 as SharedComputopConfig; |
13
|
|
|
use SprykerEco\Zed\Computop\ComputopConfig; |
14
|
|
|
use SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface; |
15
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface; |
16
|
|
|
use SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface; |
17
|
|
|
|
18
|
|
|
class PayuCeeSingleResponseSaver extends AbstractResponseSaver |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface |
22
|
|
|
*/ |
23
|
|
|
protected $computopEntityManager; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopQueryContainerInterface $queryContainer |
27
|
|
|
* @param \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface $omsFacade |
28
|
|
|
* @param \SprykerEco\Zed\Computop\ComputopConfig $config |
29
|
|
|
* @param \SprykerEco\Zed\Computop\Persistence\ComputopEntityManagerInterface $computopEntityManager |
30
|
|
|
*/ |
31
|
|
|
public function __construct( |
32
|
|
|
ComputopQueryContainerInterface $queryContainer, |
33
|
|
|
ComputopToOmsFacadeInterface $omsFacade, |
34
|
|
|
ComputopConfig $config, |
35
|
|
|
ComputopEntityManagerInterface $computopEntityManager |
36
|
|
|
) { |
37
|
|
|
parent::__construct($queryContainer, $omsFacade, $config); |
38
|
|
|
$this->computopEntityManager = $computopEntityManager; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
43
|
|
|
* |
44
|
|
|
* @return \Generated\Shared\Transfer\QuoteTransfer |
45
|
|
|
*/ |
46
|
|
|
public function save(QuoteTransfer $quoteTransfer): QuoteTransfer |
47
|
|
|
{ |
48
|
|
|
if ( |
49
|
|
|
!$quoteTransfer->getPayment() || |
50
|
|
|
!$quoteTransfer->getPayment()->getComputopPayuCeeSingle() || |
51
|
|
|
!$quoteTransfer->getPayment()->getComputopPayuCeeSingle()->getPayuCeeSingleInitResponse() |
52
|
|
|
) { |
53
|
|
|
return $quoteTransfer; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$responseTransfer = $quoteTransfer->getPayment()->getComputopPayuCeeSingle()->getPayuCeeSingleInitResponse(); |
57
|
|
|
if ($responseTransfer->getHeader()->getIsSuccess()) { |
58
|
|
|
$this->handleSaveTransaction($responseTransfer); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $quoteTransfer; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
66
|
|
|
*/ |
67
|
|
|
protected function handleSaveTransaction(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): void |
68
|
|
|
{ |
69
|
|
|
$this->getTransactionHandler()->handleTransaction(function () use ($responseTransfer) { |
70
|
|
|
$this->executeSavePaymentResponseTransaction($responseTransfer); |
71
|
|
|
}); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
protected function executeSavePaymentResponseTransaction(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): void |
80
|
|
|
{ |
81
|
|
|
$paymentStatus = $this->getPaymentStatus($responseTransfer); |
82
|
|
|
$this->computopEntityManager->savePaymentResponse($responseTransfer, $paymentStatus); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
protected function getPaymentStatus(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): string |
91
|
|
|
{ |
92
|
|
|
$responseStatus = $this->getResponseStatus($responseTransfer); |
93
|
|
|
if (!$responseTransfer) { |
|
|
|
|
94
|
|
|
return $this->config->getOmsStatusNew(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if ($responseStatus === SharedComputopConfig::AUTHORIZE_REQUEST_STATUS) { |
98
|
|
|
return $this->config->getAuthorizeRequestOmsStatus(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$responseDescription = $responseTransfer->getHeader()->getDescription(); |
102
|
|
|
if ($responseStatus === SharedComputopConfig::SUCCESS_OK && $responseDescription === SharedComputopConfig::SUCCESS_STATUS) { |
103
|
|
|
return $this->config->getOmsStatusAuthorized(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return $this->config->getOmsStatusNew(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param \Generated\Shared\Transfer\ComputopPayuCeeSingleInitResponseTransfer $responseTransfer |
111
|
|
|
* |
112
|
|
|
* @return string|null |
113
|
|
|
*/ |
114
|
|
|
protected function getResponseStatus(ComputopPayuCeeSingleInitResponseTransfer $responseTransfer): ?string |
115
|
|
|
{ |
116
|
|
|
if ($responseTransfer && $responseTransfer->getHeader()) { |
117
|
|
|
return $responseTransfer->getHeader()->getStatus(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return null; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
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