|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\FirstData\Business\Saver; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ItemTransfer; |
|
|
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\PaymentFirstDataItemTransfer; |
|
|
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\PaymentFirstDataTransfer; |
|
|
|
|
|
|
13
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
|
|
14
|
|
|
use Generated\Shared\Transfer\SaveOrderTransfer; |
|
|
|
|
|
|
15
|
|
|
use Spryker\Zed\Kernel\Persistence\EntityManager\TransactionTrait; |
|
16
|
|
|
use SprykerEco\Shared\FirstData\FirstDataConfig as SharedFirstDataConfig; |
|
17
|
|
|
use SprykerEco\Zed\FirstData\FirstDataConfig; |
|
18
|
|
|
use SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface; |
|
19
|
|
|
|
|
20
|
|
|
class FirstDataOrderPaymentSaver implements FirstDataOrderPaymentSaverInterface |
|
21
|
|
|
{ |
|
22
|
|
|
use TransactionTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $entityManager; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var \SprykerEco\Zed\FirstData\FirstDataConfig |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $firstDataConfig; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param \SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface $entityManager |
|
36
|
|
|
* @param \SprykerEco\Zed\FirstData\FirstDataConfig $firstDataConfig |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct( |
|
39
|
|
|
FirstDataEntityManagerInterface $entityManager, |
|
40
|
|
|
FirstDataConfig $firstDataConfig |
|
41
|
|
|
) { |
|
42
|
|
|
$this->entityManager = $entityManager; |
|
43
|
|
|
$this->firstDataConfig = $firstDataConfig; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
48
|
|
|
* @param \Generated\Shared\Transfer\SaveOrderTransfer $saveOrderTransfer |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function savePaymentEntities(QuoteTransfer $quoteTransfer, SaveOrderTransfer $saveOrderTransfer): void |
|
53
|
|
|
{ |
|
54
|
|
|
$paymentTransfer = $quoteTransfer->getPayment(); |
|
55
|
|
|
|
|
56
|
|
|
if (!$paymentTransfer || $paymentTransfer->getPaymentProvider() !== SharedFirstDataConfig::PAYMENT_PROVIDER_NAME_KEY) { |
|
57
|
|
|
return; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$this->getTransactionHandler()->handleTransaction(function () use ($quoteTransfer, $saveOrderTransfer): void { |
|
61
|
|
|
$this->executeSavePaymentEntitiesTransaction($quoteTransfer, $saveOrderTransfer); |
|
62
|
|
|
}); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
67
|
|
|
* @param \Generated\Shared\Transfer\SaveOrderTransfer $saveOrderTransfer |
|
68
|
|
|
* |
|
69
|
|
|
* @return void |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function executeSavePaymentEntitiesTransaction( |
|
72
|
|
|
QuoteTransfer $quoteTransfer, |
|
73
|
|
|
SaveOrderTransfer $saveOrderTransfer |
|
74
|
|
|
): void { |
|
75
|
|
|
$paymentFirstDataTransfer = $this->savePaymentFirstData($quoteTransfer, $saveOrderTransfer); |
|
76
|
|
|
|
|
77
|
|
|
foreach ($saveOrderTransfer->getOrderItems() as $itemTransfer) { |
|
78
|
|
|
$this->savePaymentFirstDataItem($paymentFirstDataTransfer, $itemTransfer); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
84
|
|
|
* @param \Generated\Shared\Transfer\SaveOrderTransfer $saveOrderTransfer |
|
85
|
|
|
* |
|
86
|
|
|
* @return \Generated\Shared\Transfer\PaymentFirstDataTransfer |
|
87
|
|
|
*/ |
|
88
|
|
|
protected function savePaymentFirstData( |
|
89
|
|
|
QuoteTransfer $quoteTransfer, |
|
90
|
|
|
SaveOrderTransfer $saveOrderTransfer |
|
91
|
|
|
): PaymentFirstDataTransfer { |
|
92
|
|
|
$firstDataTransactionDataTransfer = $quoteTransfer |
|
93
|
|
|
->getPaymentOrFail() |
|
94
|
|
|
->getFirstDataCreditCardOrFail() |
|
95
|
|
|
->getFirstDataTransactionDataOrFail(); |
|
96
|
|
|
|
|
97
|
|
|
$paymentFirstDataTransfer = (new PaymentFirstDataTransfer()) |
|
98
|
|
|
->fromArray($firstDataTransactionDataTransfer->toArray(), true) |
|
99
|
|
|
->setFkSalesOrder($saveOrderTransfer->getIdSalesOrder()) |
|
100
|
|
|
->setOrderReference($saveOrderTransfer->getOrderReference()); |
|
101
|
|
|
|
|
102
|
|
|
return $this->entityManager->savePaymentFirstData($paymentFirstDataTransfer); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param \Generated\Shared\Transfer\PaymentFirstDataTransfer $paymentFirstDataTransfer |
|
107
|
|
|
* @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer |
|
108
|
|
|
* |
|
109
|
|
|
* @return \Generated\Shared\Transfer\PaymentFirstDataItemTransfer |
|
110
|
|
|
*/ |
|
111
|
|
|
protected function savePaymentFirstDataItem( |
|
112
|
|
|
PaymentFirstDataTransfer $paymentFirstDataTransfer, |
|
113
|
|
|
ItemTransfer $itemTransfer |
|
114
|
|
|
): PaymentFirstDataItemTransfer { |
|
115
|
|
|
$paymentFirstDataItemTransfer = (new PaymentFirstDataItemTransfer()) |
|
116
|
|
|
->setFkSalesOrderItem($itemTransfer->getIdSalesOrderItem()) |
|
117
|
|
|
->setFkPaymentFirstData($paymentFirstDataTransfer->getIdPaymentFirstData()) |
|
118
|
|
|
->setStatus($this->firstDataConfig->getOmsStatusNew()) |
|
119
|
|
|
->setTransactionId($paymentFirstDataTransfer->getTransactionId()); |
|
120
|
|
|
|
|
121
|
|
|
return $this->entityManager->savePaymentFirstDataItem($paymentFirstDataItemTransfer); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|
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