|
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\AfterPay\Business\Payment; |
|
9
|
|
|
|
|
10
|
|
|
use Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPay; |
|
|
|
|
|
|
11
|
|
|
use Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayOrderItem; |
|
|
|
|
|
|
12
|
|
|
use SprykerEco\Zed\AfterPay\Persistence\AfterPayEntityManagerInterface; |
|
13
|
|
|
use SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface; |
|
14
|
|
|
|
|
15
|
|
|
class PaymentWriter implements PaymentWriterInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $afterPayQueryContainer; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var \SprykerEco\Zed\AfterPay\Persistence\AfterPayEntityManagerInterface |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $afterPayEntityManager; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param \SprykerEco\Zed\AfterPay\Persistence\AfterPayQueryContainerInterface $afterPayQueryContainer |
|
29
|
|
|
* @param \SprykerEco\Zed\AfterPay\Persistence\AfterPayEntityManagerInterface $afterPayEntityManager |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct( |
|
32
|
|
|
AfterPayQueryContainerInterface $afterPayQueryContainer, |
|
33
|
|
|
AfterPayEntityManagerInterface $afterPayEntityManager |
|
34
|
|
|
) { |
|
35
|
|
|
$this->afterPayQueryContainer = $afterPayQueryContainer; |
|
36
|
|
|
$this->afterPayEntityManager = $afterPayEntityManager; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param string $idReservation |
|
41
|
|
|
* @param int $idSalesOrder |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setIdReservationByIdSalesOrder(string $idReservation, int $idSalesOrder): void |
|
46
|
|
|
{ |
|
47
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
48
|
|
|
$afterPayPaymentEntity |
|
49
|
|
|
->setIdReservation($idReservation) |
|
50
|
|
|
->save(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $customerNumber |
|
55
|
|
|
* @param int $idSalesOrder |
|
56
|
|
|
* |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
public function setCustomerNumberByIdSalesOrder(string $customerNumber, int $idSalesOrder): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->afterPayEntityManager->addCustomerNumberToAfterPayPaymentByIdSalesOrder($customerNumber, $idSalesOrder); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param int $authorizedTotal |
|
66
|
|
|
* @param int $idSalesOrder |
|
67
|
|
|
* |
|
68
|
|
|
* @return void |
|
69
|
|
|
*/ |
|
70
|
|
|
public function setAuthorizedTotalByIdSalesOrder(int $authorizedTotal, int $idSalesOrder): void |
|
71
|
|
|
{ |
|
72
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
73
|
|
|
$afterPayPaymentEntity |
|
74
|
|
|
->setAuthorizedTotal($authorizedTotal) |
|
75
|
|
|
->save(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param int $amountToAdd |
|
80
|
|
|
* @param int $idSalesOrder |
|
81
|
|
|
* |
|
82
|
|
|
* @return void |
|
83
|
|
|
*/ |
|
84
|
|
|
public function increaseTotalCapturedAmountByIdSalesOrder(int $amountToAdd, int $idSalesOrder): void |
|
85
|
|
|
{ |
|
86
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
87
|
|
|
$afterPayPaymentEntity |
|
88
|
|
|
->setCapturedTotal($afterPayPaymentEntity->getCapturedTotal() + $amountToAdd) |
|
89
|
|
|
->save(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $captureNumber |
|
94
|
|
|
* @param int $idSalesOrder |
|
95
|
|
|
* |
|
96
|
|
|
* @return void |
|
97
|
|
|
*/ |
|
98
|
|
|
public function updateExpensesCaptureNumber(string $captureNumber, int $idSalesOrder): void |
|
99
|
|
|
{ |
|
100
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
101
|
|
|
$afterPayPaymentEntity |
|
102
|
|
|
->setExpensesCaptureNumber($captureNumber) |
|
103
|
|
|
->save(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param int $refundedAmount |
|
108
|
|
|
* @param int $idSalesOrder |
|
109
|
|
|
* |
|
110
|
|
|
* @return void |
|
111
|
|
|
*/ |
|
112
|
|
|
public function increaseRefundedTotalByIdSalesOrder(int $refundedAmount, int $idSalesOrder): void |
|
113
|
|
|
{ |
|
114
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
115
|
|
|
$refundedTotal = $afterPayPaymentEntity->getRefundedTotal(); |
|
116
|
|
|
$afterPayPaymentEntity |
|
117
|
|
|
->setRefundedTotal($refundedTotal + $refundedAmount) |
|
118
|
|
|
->save(); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param string $captureNumber |
|
123
|
|
|
* @param int $idSalesOrderItem |
|
124
|
|
|
* @param int $idPayment |
|
125
|
|
|
* |
|
126
|
|
|
* @return void |
|
127
|
|
|
*/ |
|
128
|
|
|
public function setCaptureNumberByIdSalesOrderItemAndIdPayment( |
|
129
|
|
|
string $captureNumber, |
|
130
|
|
|
int $idSalesOrderItem, |
|
131
|
|
|
int $idPayment |
|
132
|
|
|
): void { |
|
133
|
|
|
$afterPayPaymentOrderItemEntity = $this->getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment( |
|
134
|
|
|
$idSalesOrderItem, |
|
135
|
|
|
$idPayment |
|
136
|
|
|
); |
|
137
|
|
|
$afterPayPaymentOrderItemEntity |
|
138
|
|
|
->setCaptureNumber($captureNumber) |
|
139
|
|
|
->save(); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param int $amountToAdd |
|
144
|
|
|
* @param int $idSalesOrder |
|
145
|
|
|
* |
|
146
|
|
|
* @return void |
|
147
|
|
|
*/ |
|
148
|
|
|
public function increaseTotalCancelledAmountByIdSalesOrder(int $amountToAdd, int $idSalesOrder): void |
|
149
|
|
|
{ |
|
150
|
|
|
$afterPayPaymentEntity = $this->getPaymentEntityByIdSalesOrder($idSalesOrder); |
|
151
|
|
|
$afterPayPaymentEntity |
|
152
|
|
|
->setCancelledTotal($afterPayPaymentEntity->getCancelledTotal() + $amountToAdd) |
|
153
|
|
|
->save(); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param int $idSalesOrder |
|
158
|
|
|
* |
|
159
|
|
|
* @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPay|null |
|
160
|
|
|
*/ |
|
161
|
|
|
protected function getPaymentEntityByIdSalesOrder(int $idSalesOrder): ?SpyPaymentAfterPay |
|
162
|
|
|
{ |
|
163
|
|
|
$afterPayPaymentEntity = $this->afterPayQueryContainer |
|
164
|
|
|
->queryPaymentByIdSalesOrder($idSalesOrder) |
|
165
|
|
|
->findOne(); |
|
166
|
|
|
|
|
167
|
|
|
return $afterPayPaymentEntity; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param int $idSalesOrderItem |
|
172
|
|
|
* @param int $idPayment |
|
173
|
|
|
* |
|
174
|
|
|
* @return \Orm\Zed\AfterPay\Persistence\SpyPaymentAfterPayOrderItem|null |
|
175
|
|
|
*/ |
|
176
|
|
|
protected function getPaymentOrderItemEntityByIdSalesOrderItemAndIdPayment(int $idSalesOrderItem, int $idPayment): ?SpyPaymentAfterPayOrderItem |
|
177
|
|
|
{ |
|
178
|
|
|
$afterPayPaymentOrderItemEntity = $this->afterPayQueryContainer |
|
179
|
|
|
->queryPaymentOrderItemByIdSalesOrderAndIdPayment($idSalesOrderItem, $idPayment) |
|
180
|
|
|
->findOne(); |
|
181
|
|
|
|
|
182
|
|
|
return $afterPayPaymentOrderItemEntity; |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|
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