|
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\CrefoPayApi\Business\Request\Converter; |
|
9
|
|
|
|
|
10
|
|
|
use ArrayObject; |
|
11
|
|
|
use Generated\Shared\Transfer\CrefoPayApiAmountTransfer; |
|
|
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\CrefoPayApiBasketItemTransfer; |
|
|
|
|
|
|
13
|
|
|
use Generated\Shared\Transfer\CrefoPayApiRequestTransfer; |
|
|
|
|
|
|
14
|
|
|
use Generated\Shared\Transfer\CrefoPayApiReserveInformationRequestTransfer; |
|
|
|
|
|
|
15
|
|
|
use SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig; |
|
16
|
|
|
|
|
17
|
|
|
class ReserveRequestConverter implements CrefoPayApiRequestConverterInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $config; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param \SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig $config |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct(CrefoPayApiConfig $config) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->config = $config; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiRequestTransfer $requestTransfer |
|
34
|
|
|
* |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
|
|
public function convertRequestTransferToArray(CrefoPayApiRequestTransfer $requestTransfer): array |
|
38
|
|
|
{ |
|
39
|
|
|
$reserveRequest = $requestTransfer->getReserveRequest(); |
|
40
|
|
|
if ($reserveRequest === null) { |
|
41
|
|
|
return []; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return [ |
|
45
|
|
|
$this->config->getApiFieldMerchantId() => $reserveRequest->getMerchantID(), |
|
46
|
|
|
$this->config->getApiFieldStoreId() => $reserveRequest->getStoreID(), |
|
47
|
|
|
$this->config->getApiFieldOrderId() => $reserveRequest->getOrderID(), |
|
48
|
|
|
$this->config->getApiFieldPaymentMethod() => $reserveRequest->getPaymentMethod(), |
|
49
|
|
|
$this->config->getApiFieldPaymentInstrumentId() => $reserveRequest->getPaymentInstrumentID(), |
|
50
|
|
|
$this->config->getApiFieldAdditionalInformation() => $this->getAdditionalInformationData($reserveRequest->getAdditionalInformation()), |
|
51
|
|
|
$this->config->getApiFieldAmount() => $this->getAmountData($reserveRequest->getAmount()), |
|
52
|
|
|
$this->config->getApiFieldBasketItems() => $this->getBasketItemsData($reserveRequest->getBasketItems()), |
|
53
|
|
|
$this->config->getApiFieldCvv() => $reserveRequest->getCvv(), |
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiReserveInformationRequestTransfer|null $reserveInformationRequestTransfer |
|
59
|
|
|
* |
|
60
|
|
|
* @return array|null |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function getAdditionalInformationData(?CrefoPayApiReserveInformationRequestTransfer $reserveInformationRequestTransfer): ?array |
|
63
|
|
|
{ |
|
64
|
|
|
return $reserveInformationRequestTransfer ? $this->convertAdditionalInformationTransferToArray($reserveInformationRequestTransfer) : null; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiReserveInformationRequestTransfer $reserveInformationRequestTransfer |
|
69
|
|
|
* |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function convertAdditionalInformationTransferToArray(CrefoPayApiReserveInformationRequestTransfer $reserveInformationRequestTransfer): array |
|
73
|
|
|
{ |
|
74
|
|
|
return [ |
|
75
|
|
|
$this->config->getApiObjectAdditionalInformationFieldSalutation() => $reserveInformationRequestTransfer->getSalutation(), |
|
76
|
|
|
$this->config->getApiObjectAdditionalInformationFieldDateOfBirth() => $reserveInformationRequestTransfer->getDateOfBirth(), |
|
77
|
|
|
]; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param \ArrayObject|\Generated\Shared\Transfer\CrefoPayApiBasketItemTransfer[] $basketItems |
|
82
|
|
|
* |
|
83
|
|
|
* @return array|null |
|
84
|
|
|
*/ |
|
85
|
|
|
protected function getBasketItemsData(ArrayObject $basketItems): ?array |
|
86
|
|
|
{ |
|
87
|
|
|
if ($basketItems->count() === 0) { |
|
88
|
|
|
return null; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return array_map( |
|
92
|
|
|
function (CrefoPayApiBasketItemTransfer $basketItem) { |
|
93
|
|
|
return $this->convertBasketItemTransferToArray($basketItem); |
|
94
|
|
|
}, |
|
95
|
|
|
$basketItems->getArrayCopy() |
|
96
|
|
|
); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiBasketItemTransfer|null $basketItem |
|
101
|
|
|
* |
|
102
|
|
|
* @return array |
|
103
|
|
|
*/ |
|
104
|
|
|
protected function convertBasketItemTransferToArray(?CrefoPayApiBasketItemTransfer $basketItem): array |
|
105
|
|
|
{ |
|
106
|
|
|
if ($basketItem === null) { |
|
107
|
|
|
return []; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
return [ |
|
111
|
|
|
$this->config->getApiObjectBasketItemFieldText() => $basketItem->getBasketItemText(), |
|
112
|
|
|
$this->config->getApiObjectBasketItemFieldId() => $basketItem->getBasketItemID(), |
|
113
|
|
|
$this->config->getApiObjectBasketItemFieldCount() => $basketItem->getBasketItemCount(), |
|
114
|
|
|
$this->config->getApiObjectBasketItemFieldAmount() => $this->getAmountData($basketItem->getBasketItemAmount()), |
|
115
|
|
|
$this->config->getApiObjectBasketItemFieldRiskClass() => $basketItem->getBasketItemRiskClass(), |
|
116
|
|
|
$this->config->getApiObjectBasketItemFieldType() => $basketItem->getBasketItemType(), |
|
117
|
|
|
]; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiAmountTransfer|null $amountTransfer |
|
122
|
|
|
* |
|
123
|
|
|
* @return array|null |
|
124
|
|
|
*/ |
|
125
|
|
|
protected function getAmountData(?CrefoPayApiAmountTransfer $amountTransfer): ?array |
|
126
|
|
|
{ |
|
127
|
|
|
return $amountTransfer ? $this->convertAmountTransferToArray($amountTransfer) : null; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param \Generated\Shared\Transfer\CrefoPayApiAmountTransfer $amountTransfer |
|
132
|
|
|
* |
|
133
|
|
|
* @return array |
|
134
|
|
|
*/ |
|
135
|
|
|
protected function convertAmountTransferToArray(CrefoPayApiAmountTransfer $amountTransfer): array |
|
136
|
|
|
{ |
|
137
|
|
|
return [ |
|
138
|
|
|
$this->config->getApiObjectAmountFieldAmount() => $amountTransfer->getAmount(), |
|
139
|
|
|
$this->config->getApiObjectAmountFieldVatAmount() => $amountTransfer->getVatAmount(), |
|
140
|
|
|
$this->config->getApiObjectAmountFieldVatRate() => $amountTransfer->getVatRate(), |
|
141
|
|
|
]; |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|
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