|
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\Heidelpay\Business\Processor\Notification\Expander; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\HeidelpayNotificationTransfer; |
|
|
|
|
|
|
11
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Processor\Notification\Converter\NotificationXmlConverterInterface; |
|
12
|
|
|
use SprykerEco\Zed\Heidelpay\Dependency\Service\HeidelpayToUtilEncodingServiceInterface; |
|
13
|
|
|
|
|
14
|
|
|
class NotificationExpander implements NotificationExpanderInterface |
|
15
|
|
|
{ |
|
16
|
|
|
protected const KEY_ATTRIBUTES = '@attributes'; |
|
17
|
|
|
protected const KEY_IDENTIFICATION = 'Identification'; |
|
18
|
|
|
protected const KEY_PROCESSING = 'Processing'; |
|
19
|
|
|
protected const KEY_PAYMENT = 'Payment'; |
|
20
|
|
|
protected const KEY_CLEARING = 'Clearing'; |
|
21
|
|
|
protected const KEY_ACCOUNT = 'Account'; |
|
22
|
|
|
protected const KEY_CUSTOMER = 'Customer'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \SprykerEco\Zed\Heidelpay\Business\Processor\Notification\Converter\NotificationXmlConverterInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $xmlConverter; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var \SprykerEco\Zed\Heidelpay\Dependency\Service\HeidelpayToUtilEncodingServiceInterface |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $utilEncodingService; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param \SprykerEco\Zed\Heidelpay\Business\Processor\Notification\Converter\NotificationXmlConverterInterface $xmlConverter |
|
36
|
|
|
* @param \SprykerEco\Zed\Heidelpay\Dependency\Service\HeidelpayToUtilEncodingServiceInterface $utilEncodingService |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct( |
|
39
|
|
|
NotificationXmlConverterInterface $xmlConverter, |
|
40
|
|
|
HeidelpayToUtilEncodingServiceInterface $utilEncodingService |
|
41
|
|
|
) { |
|
42
|
|
|
$this->xmlConverter = $xmlConverter; |
|
43
|
|
|
$this->utilEncodingService = $utilEncodingService; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
50
|
|
|
*/ |
|
51
|
|
|
public function expandWithNotificationData(HeidelpayNotificationTransfer $notificationTransfer): HeidelpayNotificationTransfer |
|
52
|
|
|
{ |
|
53
|
|
|
$notificationData = $this->xmlConverter->convert($notificationTransfer->getNotificationBody()); |
|
54
|
|
|
|
|
55
|
|
|
$notificationTransfer = $this->addTransactionData($notificationTransfer, $notificationData[static::KEY_ATTRIBUTES]); |
|
56
|
|
|
$notificationTransfer = $this->addIdentificationData($notificationTransfer, $notificationData[static::KEY_IDENTIFICATION]); |
|
57
|
|
|
$notificationTransfer = $this->addProcessingData($notificationTransfer, $notificationData[static::KEY_PROCESSING]); |
|
58
|
|
|
$notificationTransfer = $this->addPaymentData($notificationTransfer, $notificationData[static::KEY_PAYMENT]); |
|
59
|
|
|
$notificationTransfer = $this->addAccountData($notificationTransfer, $notificationData[static::KEY_ACCOUNT]); |
|
60
|
|
|
$notificationTransfer = $this->addCustomerData($notificationTransfer, $notificationData[static::KEY_CUSTOMER]); |
|
61
|
|
|
|
|
62
|
|
|
return $notificationTransfer; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
67
|
|
|
* @param array $transactionData |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function addTransactionData( |
|
72
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
73
|
|
|
array $transactionData |
|
74
|
|
|
): HeidelpayNotificationTransfer { |
|
75
|
|
|
$notificationTransfer->setTransactionSource($transactionData['source']); |
|
76
|
|
|
$notificationTransfer->setTransactionChannel($transactionData['channel']); |
|
77
|
|
|
$notificationTransfer->setTransactionResponseType($transactionData['response']); |
|
78
|
|
|
$notificationTransfer->setTransactionMode($transactionData['mode']); |
|
79
|
|
|
|
|
80
|
|
|
return $notificationTransfer; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
85
|
|
|
* @param array $identificationData |
|
86
|
|
|
* |
|
87
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
88
|
|
|
*/ |
|
89
|
|
|
protected function addIdentificationData( |
|
90
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
91
|
|
|
array $identificationData |
|
92
|
|
|
): HeidelpayNotificationTransfer { |
|
93
|
|
|
$notificationTransfer->setTransactionId($identificationData['TransactionID']); |
|
94
|
|
|
$notificationTransfer->setUniqueId($identificationData['UniqueID']); |
|
95
|
|
|
$notificationTransfer->setShortId($identificationData['ShortID']); |
|
96
|
|
|
$notificationTransfer->setIdentificationSource($identificationData['Source']); |
|
97
|
|
|
|
|
98
|
|
|
return $notificationTransfer; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
103
|
|
|
* @param array $processingData |
|
104
|
|
|
* |
|
105
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function addProcessingData( |
|
108
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
109
|
|
|
array $processingData |
|
110
|
|
|
): HeidelpayNotificationTransfer { |
|
111
|
|
|
$notificationTransfer->setResultCode($processingData[static::KEY_ATTRIBUTES]['code']); |
|
112
|
|
|
$notificationTransfer->setResultTimestamp($processingData['Timestamp']); |
|
113
|
|
|
$notificationTransfer->setResult($processingData['Result']); |
|
114
|
|
|
$notificationTransfer->setResultStatus($processingData['Status']); |
|
115
|
|
|
$notificationTransfer->setResultReason($processingData['Reason']); |
|
116
|
|
|
$notificationTransfer->setResultReturn($processingData['Return']); |
|
117
|
|
|
|
|
118
|
|
|
return $notificationTransfer; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
123
|
|
|
* @param array $paymentData |
|
124
|
|
|
* |
|
125
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
126
|
|
|
*/ |
|
127
|
|
|
protected function addPaymentData( |
|
128
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
129
|
|
|
array $paymentData |
|
130
|
|
|
): HeidelpayNotificationTransfer { |
|
131
|
|
|
$notificationTransfer->setPaymentCode($paymentData[static::KEY_ATTRIBUTES]['code']); |
|
132
|
|
|
$notificationTransfer->setAmount($paymentData[static::KEY_CLEARING]['Amount']); |
|
133
|
|
|
$notificationTransfer->setCurrency($paymentData[static::KEY_CLEARING]['Currency']); |
|
134
|
|
|
$notificationTransfer->setPaymentDescriptor($paymentData[static::KEY_CLEARING]['Descriptor']); |
|
135
|
|
|
|
|
136
|
|
|
return $notificationTransfer; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
141
|
|
|
* @param array $accountData |
|
142
|
|
|
* |
|
143
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
144
|
|
|
*/ |
|
145
|
|
|
protected function addAccountData( |
|
146
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
147
|
|
|
array $accountData |
|
148
|
|
|
): HeidelpayNotificationTransfer { |
|
149
|
|
|
$notificationTransfer->setAccount( |
|
150
|
|
|
$this->utilEncodingService->encodeJson($accountData) |
|
151
|
|
|
); |
|
152
|
|
|
|
|
153
|
|
|
return $notificationTransfer; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param \Generated\Shared\Transfer\HeidelpayNotificationTransfer $notificationTransfer |
|
158
|
|
|
* @param array $customerData |
|
159
|
|
|
* |
|
160
|
|
|
* @return \Generated\Shared\Transfer\HeidelpayNotificationTransfer |
|
161
|
|
|
*/ |
|
162
|
|
|
protected function addCustomerData( |
|
163
|
|
|
HeidelpayNotificationTransfer $notificationTransfer, |
|
164
|
|
|
array $customerData |
|
165
|
|
|
): HeidelpayNotificationTransfer { |
|
166
|
|
|
$notificationTransfer->setCustomer( |
|
167
|
|
|
$this->utilEncodingService->encodeJson($customerData) |
|
168
|
|
|
); |
|
169
|
|
|
|
|
170
|
|
|
return $notificationTransfer; |
|
171
|
|
|
} |
|
172
|
|
|
} |
|
173
|
|
|
|
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