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\Payone\Business\Payment\MethodMapper; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ExpenseTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\OrderTransfer; |
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer; |
|
|
|
|
13
|
|
|
use Orm\Zed\Payone\Persistence\SpyPaymentPayone; |
|
|
|
|
14
|
|
|
use SprykerEco\Shared\Payone\PayoneApiConstants; |
15
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer; |
16
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PaymentMethod\SecurityInvoiceContainer; |
17
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PersonalContainer; |
18
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainer; |
19
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\CaptureContainer; |
20
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\CaptureContainerInterface; |
21
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface; |
22
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\DebitContainer; |
23
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\DebitContainerInterface; |
24
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\GetSecurityInvoiceContainer; |
25
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\ItemContainer; |
26
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\PreAuthorizationContainer; |
27
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\PreAuthorizationContainerInterface; |
28
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\RefundContainer; |
29
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\RefundContainerInterface; |
30
|
|
|
use SprykerEco\Zed\Payone\PayoneConfig; |
31
|
|
|
|
32
|
|
|
class SecurityInvoice extends AbstractMapper |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var \SprykerEco\Zed\Payone\PayoneConfig |
36
|
|
|
*/ |
37
|
|
|
protected $payoneConfig; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param \SprykerEco\Zed\Payone\PayoneConfig $payoneConfig |
41
|
|
|
*/ |
42
|
|
|
public function __construct(PayoneConfig $payoneConfig) |
43
|
|
|
{ |
44
|
|
|
$this->payoneConfig = $payoneConfig; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function getName(): string |
51
|
|
|
{ |
52
|
|
|
return PayoneApiConstants::PAYMENT_METHOD_SECURITY_INVOICE; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
57
|
|
|
* @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer |
58
|
|
|
* |
59
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainer |
60
|
|
|
*/ |
61
|
|
|
public function mapPaymentToAuthorization(SpyPaymentPayone $paymentEntity, OrderTransfer $orderTransfer): AbstractAuthorizationContainer |
62
|
|
|
{ |
63
|
|
|
$authorizationContainer = new AuthorizationContainer(); |
64
|
|
|
$authorizationContainer = $this->mapPaymentToAbstractAuthorization($paymentEntity, $authorizationContainer); |
65
|
|
|
$authorizationContainer = $this->mapEmail($paymentEntity, $authorizationContainer); |
66
|
|
|
$authorizationContainer = $this->mapBusinessRelation($authorizationContainer); |
67
|
|
|
$authorizationContainer->setAmount($orderTransfer->getTotals()->getGrandTotal()); |
68
|
|
|
|
69
|
|
|
return $authorizationContainer; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
74
|
|
|
* |
75
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\PreAuthorizationContainerInterface |
76
|
|
|
*/ |
77
|
|
|
public function mapPaymentToPreAuthorization(SpyPaymentPayone $paymentEntity): PreAuthorizationContainerInterface |
78
|
|
|
{ |
79
|
|
|
$preAuthorizationContainer = new PreAuthorizationContainer(); |
80
|
|
|
$preAuthorizationContainer = $this->mapPaymentToAbstractAuthorization($paymentEntity, $preAuthorizationContainer); |
81
|
|
|
$preAuthorizationContainer = $this->mapEmail($paymentEntity, $preAuthorizationContainer); |
82
|
|
|
$preAuthorizationContainer = $this->mapAmount($paymentEntity, $preAuthorizationContainer); |
83
|
|
|
$preAuthorizationContainer = $this->mapBusinessRelation($preAuthorizationContainer); |
84
|
|
|
|
85
|
|
|
return $preAuthorizationContainer; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
90
|
|
|
* @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container |
91
|
|
|
* |
92
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer |
93
|
|
|
*/ |
94
|
|
|
public function mapEmail(SpyPaymentPayone $paymentEntity, AbstractAuthorizationContainer $container): AbstractAuthorizationContainer |
95
|
|
|
{ |
96
|
|
|
$container->setEmail($paymentEntity->getSpySalesOrder()->getEmail()); |
97
|
|
|
|
98
|
|
|
return $container; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
103
|
|
|
* @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container |
104
|
|
|
* |
105
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer |
106
|
|
|
*/ |
107
|
|
|
public function mapAmount(SpyPaymentPayone $paymentEntity, AbstractAuthorizationContainer $container): AbstractAuthorizationContainer |
108
|
|
|
{ |
109
|
|
|
$container->setAmount($paymentEntity->getSpySalesOrder()->getOrderTotals()->get(0)->getSubTotal()); |
110
|
|
|
|
111
|
|
|
return $container; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container |
116
|
|
|
* |
117
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer |
118
|
|
|
*/ |
119
|
|
|
public function mapBusinessRelation(AbstractAuthorizationContainer $container): AbstractAuthorizationContainer |
120
|
|
|
{ |
121
|
|
|
$container->setBusinessrelation($this->payoneConfig->getBusinessRelation()); |
122
|
|
|
|
123
|
|
|
return $container; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param \Generated\Shared\Transfer\ExpenseTransfer $expense |
128
|
|
|
* |
129
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\ItemContainer |
130
|
|
|
*/ |
131
|
|
|
public function mapExpenseToItemContainer(ExpenseTransfer $expense): ItemContainer |
132
|
|
|
{ |
133
|
|
|
$itemContainer = new ItemContainer(); |
134
|
|
|
$itemContainer->setIt(PayoneApiConstants::INVOICING_ITEM_TYPE_SHIPMENT); |
135
|
|
|
$itemContainer->setId('-'); |
136
|
|
|
$itemContainer->setPr($expense->getUnitGrossPrice()); |
137
|
|
|
$itemContainer->setNo($expense->getQuantity()); |
138
|
|
|
$itemContainer->setDe($expense->getName()); |
139
|
|
|
$itemContainer->setVa($expense->getTaxRate()); |
140
|
|
|
|
141
|
|
|
return $itemContainer; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
146
|
|
|
* |
147
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\CaptureContainerInterface |
148
|
|
|
*/ |
149
|
|
|
public function mapPaymentToCapture(SpyPaymentPayone $paymentEntity): CaptureContainerInterface |
150
|
|
|
{ |
151
|
|
|
$paymentDetailEntity = $paymentEntity->getSpyPaymentPayoneDetail(); |
152
|
|
|
|
153
|
|
|
$captureContainer = new CaptureContainer(); |
154
|
|
|
$captureContainer->setAmount($paymentDetailEntity->getAmount()); |
155
|
|
|
$captureContainer->setCurrency($this->getStandardParameter()->getCurrency()); |
156
|
|
|
$captureContainer->setTxid($paymentEntity->getTransactionId()); |
157
|
|
|
|
158
|
|
|
return $captureContainer; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
163
|
|
|
* @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $authorizationContainer |
164
|
|
|
* |
165
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer |
166
|
|
|
*/ |
167
|
|
|
protected function mapPaymentToAbstractAuthorization( |
168
|
|
|
SpyPaymentPayone $paymentEntity, |
169
|
|
|
AbstractAuthorizationContainer $authorizationContainer |
170
|
|
|
): AbstractAuthorizationContainer { |
171
|
|
|
$authorizationContainer->setAid($this->getStandardParameter()->getAid()); |
172
|
|
|
$authorizationContainer->setClearingType(PayoneApiConstants::CLEARING_TYPE_SECURITY_INVOICE); |
173
|
|
|
$authorizationContainer->setClearingsubtype(PayoneApiConstants::CLEARING_SUBTYPE_SECURITY_INVOICE); |
174
|
|
|
$authorizationContainer->setReference($paymentEntity->getReference()); |
175
|
|
|
$authorizationContainer->setCurrency($this->getStandardParameter()->getCurrency()); |
176
|
|
|
$authorizationContainer->setPaymentMethod($this->createPaymentMethodContainerFromPayment()); |
177
|
|
|
|
178
|
|
|
$personalContainer = new PersonalContainer(); |
179
|
|
|
$this->mapBillingAddressToPersonalContainer($personalContainer, $paymentEntity); |
180
|
|
|
|
181
|
|
|
$authorizationContainer->setPersonalData($personalContainer); |
182
|
|
|
|
183
|
|
|
return $authorizationContainer; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
188
|
|
|
* |
189
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\DebitContainerInterface |
190
|
|
|
*/ |
191
|
|
|
public function mapPaymentToDebit(SpyPaymentPayone $paymentEntity): DebitContainerInterface |
192
|
|
|
{ |
193
|
|
|
$debitContainer = new DebitContainer(); |
194
|
|
|
|
195
|
|
|
$debitContainer->setTxid($paymentEntity->getTransactionId()); |
196
|
|
|
$debitContainer->setSequenceNumber($this->getNextSequenceNumber($paymentEntity->getTransactionId())); |
197
|
|
|
$debitContainer->setCurrency($this->getStandardParameter()->getCurrency()); |
198
|
|
|
$debitContainer->setAmount($paymentEntity->getSpyPaymentPayoneDetail()->getAmount()); |
199
|
|
|
|
200
|
|
|
return $debitContainer; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer |
205
|
|
|
* |
206
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface |
207
|
|
|
*/ |
208
|
|
|
public function mapGetSecurityInvoice(PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer): ContainerInterface |
209
|
|
|
{ |
210
|
|
|
$getInvoiceContainer = new GetSecurityInvoiceContainer(); |
211
|
|
|
$getInvoiceContainer->setInvoiceTitle($getSecurityInvoiceTransfer->getReference()); |
212
|
|
|
|
213
|
|
|
return $getInvoiceContainer; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity |
218
|
|
|
* |
219
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\RefundContainerInterface |
220
|
|
|
*/ |
221
|
|
|
public function mapPaymentToRefund(SpyPaymentPayone $paymentEntity): RefundContainerInterface |
222
|
|
|
{ |
223
|
|
|
$refundContainer = new RefundContainer(); |
224
|
|
|
|
225
|
|
|
$refundContainer->setTxid($paymentEntity->getTransactionId()); |
226
|
|
|
$refundContainer->setSequenceNumber($this->getNextSequenceNumber($paymentEntity->getTransactionId())); |
227
|
|
|
$refundContainer->setCurrency($this->getStandardParameter()->getCurrency()); |
228
|
|
|
$refundContainer->setBankcountry($paymentEntity->getSpyPaymentPayoneDetail()->getBankCountry()); |
229
|
|
|
$refundContainer->setBankaccount($paymentEntity->getSpyPaymentPayoneDetail()->getBankAccount()); |
230
|
|
|
$refundContainer->setBankcode($paymentEntity->getSpyPaymentPayoneDetail()->getBankCode()); |
231
|
|
|
$refundContainer->setBankbranchcode($paymentEntity->getSpyPaymentPayoneDetail()->getBankBranchCode()); |
232
|
|
|
$refundContainer->setBankcheckdigit($paymentEntity->getSpyPaymentPayoneDetail()->getBankCheckDigit()); |
233
|
|
|
$refundContainer->setIban($paymentEntity->getSpyPaymentPayoneDetail()->getIban()); |
234
|
|
|
$refundContainer->setBic($paymentEntity->getSpyPaymentPayoneDetail()->getBic()); |
235
|
|
|
|
236
|
|
|
return $refundContainer; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PaymentMethod\SecurityInvoiceContainer |
241
|
|
|
*/ |
242
|
|
|
protected function createPaymentMethodContainerFromPayment(): SecurityInvoiceContainer |
243
|
|
|
{ |
244
|
|
|
return new SecurityInvoiceContainer(); |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|
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