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