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; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; |
11
|
|
|
use SprykerEco\Client\FirstData\FirstDataClientInterface; |
12
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\ApiClient\FirstDataApiClient; |
13
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\ApiClient\FirstDataApiClientInterface; |
14
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Generator\HashGenerator; |
15
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Generator\HashGeneratorInterface; |
16
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Logger\FirstDataApiLogger; |
17
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Logger\FirstDataApiLoggerInterface; |
18
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Builder\FirstDataRequestBuilder; |
19
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Builder\FirstDataRequestBuilderInterface; |
20
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Converter\CaptureRequestConverter; |
21
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Converter\FirstDataRequestConverterInterface; |
22
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Converter\RefundRequestConverter; |
23
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Request\Converter\ReservationRequestConverter; |
24
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Response\Converter\FirstDataResponseConverter; |
25
|
|
|
use SprykerEco\Zed\FirstData\Business\Api\Response\Converter\FirstDataResponseConverterInterface; |
26
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\FirstDataNotificationChecker; |
27
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\FirstDataNotificationCheckerInterface; |
28
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\FirstDataResponseValidator; |
29
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\FirstDataResponseValidatorInterface; |
30
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\PaymentAuthorizationTimeOutChecker; |
31
|
|
|
use SprykerEco\Zed\FirstData\Business\Checker\PaymentAuthorizationTimeOutCheckerInterface; |
32
|
|
|
use SprykerEco\Zed\FirstData\Business\CommandExecutor\CancelCommandExecutor; |
33
|
|
|
use SprykerEco\Zed\FirstData\Business\CommandExecutor\CaptureCommandExecutor; |
34
|
|
|
use SprykerEco\Zed\FirstData\Business\CommandExecutor\FirstDataCommandExecutorInterface; |
35
|
|
|
use SprykerEco\Zed\FirstData\Business\Expander\OrderExpander; |
36
|
|
|
use SprykerEco\Zed\FirstData\Business\Expander\OrderExpanderInterface; |
37
|
|
|
use SprykerEco\Zed\FirstData\Business\Mapper\FirstDataPaymentQuoteMapper; |
38
|
|
|
use SprykerEco\Zed\FirstData\Business\Mapper\FirstDataPaymentQuoteMapperInterface; |
39
|
|
|
use SprykerEco\Zed\FirstData\Business\Processor\NotificationProcessor; |
40
|
|
|
use SprykerEco\Zed\FirstData\Business\Processor\NotificationProcessorInterface; |
41
|
|
|
use SprykerEco\Zed\FirstData\Business\Saver\FirstDataOrderPaymentSaver; |
42
|
|
|
use SprykerEco\Zed\FirstData\Business\Saver\FirstDataOrderPaymentSaverInterface; |
43
|
|
|
use SprykerEco\Zed\FirstData\Dependency\External\Guzzle\FirstDataGuzzleHttpClientAdapter; |
44
|
|
|
use SprykerEco\Zed\FirstData\Dependency\External\Guzzle\FirstDataGuzzleHttpClientAdapterInterface; |
45
|
|
|
use SprykerEco\Zed\FirstData\Dependency\Service\FirstDataToUtilEncodingServiceInterface; |
46
|
|
|
use SprykerEco\Zed\FirstData\FirstDataDependencyProvider; |
47
|
|
|
use SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManager; |
48
|
|
|
use SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @method \SprykerEco\Zed\FirstData\FirstDataConfig getConfig() |
52
|
|
|
* @method \SprykerEco\Zed\FirstData\Persistence\FirstDataRepositoryInterface getRepository() |
53
|
|
|
* @method \SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface getEntityManager() |
54
|
|
|
*/ |
55
|
|
|
class FirstDataBusinessFactory extends AbstractBusinessFactory |
56
|
|
|
{ |
57
|
|
|
/** |
58
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Saver\FirstDataOrderPaymentSaverInterface |
59
|
|
|
*/ |
60
|
|
|
public function createFirstDataOrderPaymentSaver(): FirstDataOrderPaymentSaverInterface |
61
|
|
|
{ |
62
|
|
|
return new FirstDataOrderPaymentSaver( |
63
|
|
|
$this->getEntityManager(), |
64
|
|
|
$this->getConfig() |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Checker\PaymentAuthorizationTimeOutCheckerInterface |
70
|
|
|
*/ |
71
|
|
|
public function createPaymentAuthorizationTimeOutChecker(): PaymentAuthorizationTimeOutCheckerInterface |
72
|
|
|
{ |
73
|
|
|
return new PaymentAuthorizationTimeOutChecker($this->getConfig()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\CommandExecutor\FirstDataCommandExecutorInterface |
78
|
|
|
*/ |
79
|
|
|
public function createCaptureCommandExecutor(): FirstDataCommandExecutorInterface |
80
|
|
|
{ |
81
|
|
|
return new CaptureCommandExecutor( |
82
|
|
|
$this->createFirstDataApiClient(), |
83
|
|
|
$this->getEntityManager(), |
84
|
|
|
$this->getRepository(), |
85
|
|
|
$this->getConfig() |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\CommandExecutor\FirstDataCommandExecutorInterface |
91
|
|
|
*/ |
92
|
|
|
public function createCancelCommandExecutor(): FirstDataCommandExecutorInterface |
93
|
|
|
{ |
94
|
|
|
return new CancelCommandExecutor( |
95
|
|
|
$this->createFirstDataApiClient(), |
96
|
|
|
$this->getEntityManager(), |
97
|
|
|
$this->getRepository(), |
98
|
|
|
$this->getConfig() |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\ApiClient\FirstDataApiClientInterface |
104
|
|
|
*/ |
105
|
|
|
public function createFirstDataApiClient(): FirstDataApiClientInterface |
106
|
|
|
{ |
107
|
|
|
return new FirstDataApiClient( |
108
|
|
|
$this->createFirstDataGuzzleHttpClientAdapter(), |
109
|
|
|
$this->createFirstDataRequestBuilder(), |
110
|
|
|
$this->createFirstDataResponseConverter(), |
111
|
|
|
$this->createFirstDataApiLogger(), |
112
|
|
|
$this->getConfig() |
113
|
|
|
); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return \SprykerEco\Zed\FirstData\Dependency\External\Guzzle\FirstDataGuzzleHttpClientAdapterInterface |
118
|
|
|
*/ |
119
|
|
|
public function createFirstDataGuzzleHttpClientAdapter(): FirstDataGuzzleHttpClientAdapterInterface |
120
|
|
|
{ |
121
|
|
|
return new FirstDataGuzzleHttpClientAdapter(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Request\Builder\FirstDataRequestBuilderInterface |
126
|
|
|
*/ |
127
|
|
|
public function createFirstDataRequestBuilder(): FirstDataRequestBuilderInterface |
128
|
|
|
{ |
129
|
|
|
return new FirstDataRequestBuilder( |
130
|
|
|
$this->createFirstDataRequestConverters(), |
131
|
|
|
$this->getUtilEncodingService(), |
132
|
|
|
$this->getConfig(), |
133
|
|
|
$this->createHashGenerator() |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Mapper\FirstDataPaymentQuoteMapperInterface |
139
|
|
|
*/ |
140
|
|
|
public function createFirstDataPaymentQuoteMapper(): FirstDataPaymentQuoteMapperInterface |
141
|
|
|
{ |
142
|
|
|
return new FirstDataPaymentQuoteMapper(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Response\Converter\FirstDataResponseConverterInterface |
147
|
|
|
*/ |
148
|
|
|
public function createFirstDataResponseConverter(): FirstDataResponseConverterInterface |
149
|
|
|
{ |
150
|
|
|
return new FirstDataResponseConverter($this->getUtilEncodingService()); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Logger\FirstDataApiLoggerInterface |
155
|
|
|
*/ |
156
|
|
|
public function createFirstDataApiLogger(): FirstDataApiLoggerInterface |
157
|
|
|
{ |
158
|
|
|
return new FirstDataApiLogger( |
159
|
|
|
$this->createFirstDataEntityManager(), |
160
|
|
|
$this->getUtilEncodingService() |
161
|
|
|
); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Request\Converter\FirstDataRequestConverterInterface[] |
166
|
|
|
*/ |
167
|
|
|
public function createFirstDataRequestConverters(): array |
168
|
|
|
{ |
169
|
|
|
return [ |
170
|
|
|
$this->createReservationRequestConverter(), |
171
|
|
|
$this->createCaptureRequestConverter(), |
172
|
|
|
$this->createRefundRequestConverter(), |
173
|
|
|
]; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Checker\FirstDataResponseValidatorInterface |
178
|
|
|
*/ |
179
|
|
|
public function createFirstDataResponseValidator(): FirstDataResponseValidatorInterface |
180
|
|
|
{ |
181
|
|
|
return new FirstDataResponseValidator($this->getFirstDataClient(), $this->getConfig()); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Request\Converter\FirstDataRequestConverterInterface |
186
|
|
|
*/ |
187
|
|
|
public function createReservationRequestConverter(): FirstDataRequestConverterInterface |
188
|
|
|
{ |
189
|
|
|
return new ReservationRequestConverter(); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Request\Converter\FirstDataRequestConverterInterface |
194
|
|
|
*/ |
195
|
|
|
public function createCaptureRequestConverter(): FirstDataRequestConverterInterface |
196
|
|
|
{ |
197
|
|
|
return new CaptureRequestConverter(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Request\Converter\FirstDataRequestConverterInterface |
202
|
|
|
*/ |
203
|
|
|
public function createRefundRequestConverter(): FirstDataRequestConverterInterface |
204
|
|
|
{ |
205
|
|
|
return new RefundRequestConverter(); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @return \SprykerEco\Zed\FirstData\Persistence\FirstDataEntityManagerInterface |
210
|
|
|
*/ |
211
|
|
|
public function createFirstDataEntityManager(): FirstDataEntityManagerInterface |
212
|
|
|
{ |
213
|
|
|
return new FirstDataEntityManager(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Api\Generator\HashGeneratorInterface |
218
|
|
|
*/ |
219
|
|
|
public function createHashGenerator(): HashGeneratorInterface |
220
|
|
|
{ |
221
|
|
|
return new HashGenerator($this->getConfig()); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Processor\NotificationProcessorInterface |
226
|
|
|
*/ |
227
|
|
|
public function createNotificationProcessor(): NotificationProcessorInterface |
228
|
|
|
{ |
229
|
|
|
return new NotificationProcessor( |
230
|
|
|
$this->getEntityManager(), |
231
|
|
|
$this->getConfig() |
232
|
|
|
); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Checker\FirstDataNotificationCheckerInterface |
237
|
|
|
*/ |
238
|
|
|
public function createFirstDataNotificationChecker(): FirstDataNotificationCheckerInterface |
239
|
|
|
{ |
240
|
|
|
return new FirstDataNotificationChecker($this->getRepository()); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @return \SprykerEco\Zed\FirstData\Dependency\Service\FirstDataToUtilEncodingServiceInterface |
245
|
|
|
*/ |
246
|
|
|
public function getUtilEncodingService(): FirstDataToUtilEncodingServiceInterface |
247
|
|
|
{ |
248
|
|
|
return $this->getProvidedDependency(FirstDataDependencyProvider::SERVICE_UTIL_ENCODING); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @return \SprykerEco\Client\FirstData\FirstDataClientInterface |
253
|
|
|
*/ |
254
|
|
|
public function getFirstDataClient(): FirstDataClientInterface |
255
|
|
|
{ |
256
|
|
|
return $this->getProvidedDependency(FirstDataDependencyProvider::CLIENT_FIRST_DATA); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @return \SprykerEco\Zed\FirstData\Business\Expander\OrderExpanderInterface |
261
|
|
|
*/ |
262
|
|
|
public function createOrderExpander(): OrderExpanderInterface |
263
|
|
|
{ |
264
|
|
|
return new OrderExpander( |
265
|
|
|
$this->getRepository() |
266
|
|
|
); |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|