Completed
Push — master ( 9db63e...40913a )
by Oleksandr
24s queued 13s
created

PayoneBusinessFactory   F

Complexity

Total Complexity 67

Size/Duplication

Total Lines 726
Duplicated Lines 0 %

Importance

Changes 7
Bugs 2 Features 0
Metric Value
wmc 67
eloc 208
c 7
b 2
f 0
dl 0
loc 726
rs 3.04

65 Methods

Rating   Name   Duplication   Size   Complexity  
A createPayoneAuthorizeRequestSender() 0 8 1
A createPayoneFileReader() 0 8 1
A createPayoneBankAccountChecker() 0 7 1
A createSequenceNumberProvider() 0 7 1
A createApiLogFinder() 0 4 1
A createCashOnDelivery() 0 3 1
A createRiskCheckFactory() 0 3 1
A createTransactionStatusRequest() 0 3 1
A createExecutionAdapter() 0 5 1
A createPaymentDataChecker() 0 3 1
A createCreditCardCheckResponseMapper() 0 3 1
A createPayoneDebitRequestSender() 0 9 1
A createPayoneOrderItemStatusFinder() 0 3 1
A createPayoneCaptureRequestSender() 0 12 1
A createOrderPriceDistributor() 0 3 1
A getStandardParameter() 0 7 2
A createDiscountMapper() 0 3 1
A createHashProvider() 0 3 1
A getAvailablePaymentMethods() 0 15 1
A createKlarnaPaymentMapper() 0 3 1
A getRequestStack() 0 3 1
A createPostSaveHook() 0 7 1
A createPayoneRefundRequestSender() 0 11 1
A createPaymentMethodFilter() 0 3 1
A createPayoneInitPaypalExpressCheckoutMethodSender() 0 5 1
A createCaptureResponseMapper() 0 3 1
A createOnlineBankTransfer() 0 3 1
A createAuthorizationResponseMapper() 0 3 1
A getStore() 0 3 1
A createPayonePartialCaptureRequestSender() 0 14 1
A createPayoneSecurityInvoiceReader() 0 8 1
A createPayonePartialRefundRequestSender() 0 11 1
A createOrderManager() 0 3 1
A createApiCallLogWriter() 0 4 1
A createGenericPayment() 0 3 1
A createPaymentMapperReader() 0 12 2
A createExpenseMapper() 0 3 1
A createDebitResponseMapper() 0 3 1
A createPayoneKlarnaStartSessionMethodSender() 0 10 1
A createShipmentMapper() 0 3 1
A createPayonePaypalExpressCheckoutDetailsReader() 0 5 1
A createDirectDebit() 0 3 1
A createPrepayment() 0 3 1
A createProductMapper() 0 3 1
A createPayonePreAuthorizeRequestSender() 0 7 1
A createPayoneGenericRequestMethodSender() 0 6 1
A createUrlHmacGenerator() 0 3 1
A createEWallet() 0 3 1
A createPayoneInvoiceReader() 0 8 1
A createPayoneBaseAuthorizeSender() 0 8 1
A createPayoneManageMandateMethodSender() 0 7 1
A createSecurityInvoice() 0 3 1
A createTransactionStatusManager() 0 6 1
A createCreditCardPseudo() 0 3 1
A createInvoice() 0 3 1
A createHashGenerator() 0 4 1
A createRiskCheckManager() 0 6 1
A createModeDetector() 0 3 1
A createStandartParameterMapper() 0 3 1
A createRiskCheckMapper() 0 7 1
A createRefundResponseMapper() 0 3 1
A createRefundChecker() 0 3 1
A createPayoneCreditCardChecker() 0 8 1
A createPayoneRequestProductDataMapper() 0 6 1
A getGlossaryFacade() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like PayoneBusinessFactory often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use PayoneBusinessFactory, and based on these observations, apply Extract Interface, too.

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;
9
10
use Generated\Shared\Transfer\PayoneStandardParameterTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...andardParameterTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ionStatusUpdateTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spryker\Shared\Kernel\Store;
13
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
14
use SprykerEco\Shared\Payone\Dependency\HashInterface;
15
use SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface;
16
use SprykerEco\Shared\Payone\PayoneApiConstants;
17
use SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface;
18
use SprykerEco\Zed\Payone\Business\Api\Adapter\Http\Guzzle;
19
use SprykerEco\Zed\Payone\Business\Api\Log\ApiCallLogWriter;
20
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapper;
21
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapperInterface;
22
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CaptureResponseMapper;
23
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CaptureResponseMapperInterface;
24
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapper;
25
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapperInterface;
26
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\DebitResponseMapper;
27
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\DebitResponseMapperInterface;
28
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\RefundResponseMapper;
29
use SprykerEco\Zed\Payone\Business\Api\Response\Mapper\RefundResponseMapperInterface;
30
use SprykerEco\Zed\Payone\Business\Api\TransactionStatus\TransactionStatusRequest;
31
use SprykerEco\Zed\Payone\Business\ApiLog\ApiLogFinder;
32
use SprykerEco\Zed\Payone\Business\ApiLog\ApiLogFinderInterface;
33
use SprykerEco\Zed\Payone\Business\ConditionChecker\PaymentDataChecker;
34
use SprykerEco\Zed\Payone\Business\ConditionChecker\PaymentDataCheckerInterface;
35
use SprykerEco\Zed\Payone\Business\ConditionChecker\RefundChecker;
36
use SprykerEco\Zed\Payone\Business\ConditionChecker\RefundCheckerInterface;
37
use SprykerEco\Zed\Payone\Business\Distributor\OrderPriceDistributor;
38
use SprykerEco\Zed\Payone\Business\Distributor\OrderPriceDistributorInterface;
39
use SprykerEco\Zed\Payone\Business\Key\HashGenerator;
40
use SprykerEco\Zed\Payone\Business\Key\HashGeneratorInterface;
41
use SprykerEco\Zed\Payone\Business\Key\HashProvider;
42
use SprykerEco\Zed\Payone\Business\Key\HmacGeneratorInterface;
43
use SprykerEco\Zed\Payone\Business\Key\UrlHmacGenerator;
44
use SprykerEco\Zed\Payone\Business\Mode\ModeDetector;
45
use SprykerEco\Zed\Payone\Business\Order\OrderManager;
46
use SprykerEco\Zed\Payone\Business\Order\OrderManagerInterface;
47
use SprykerEco\Zed\Payone\Business\Order\PayoneOrderItemStatusFinder;
48
use SprykerEco\Zed\Payone\Business\Order\PayoneOrderItemStatusFinderInterface;
49
use SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneBankAccountChecker;
50
use SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneBankAccountCheckerInterface;
51
use SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneCreditCardChecker;
52
use SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneCreditCardCheckerInterface;
53
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\DiscountMapper;
54
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\DiscountMapperInterface;
55
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ExpenseMapper;
56
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ExpenseMapperInterface;
57
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapper;
58
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapperInterface;
59
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ProductMapper;
60
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ProductMapperInterface;
61
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ShipmentMapper;
62
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\ShipmentMapperInterface;
63
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapper;
64
use SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface;
65
use SprykerEco\Zed\Payone\Business\Payment\GenericPaymentMethodMapperInterface;
66
use SprykerEco\Zed\Payone\Business\Payment\Hook\PostSaveHook;
67
use SprykerEco\Zed\Payone\Business\Payment\Hook\PostSaveHookInterface;
68
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CashOnDelivery;
69
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CreditCardPseudo;
70
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CreditCardPseudoInterface;
71
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\DirectDebit;
72
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\DirectDebitInterface;
73
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\EWallet;
74
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\GenericPayment;
75
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\Invoice;
76
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\InvoiceInterface;
77
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\KlarnaPaymentMapper;
78
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\KlarnaPaymentMapperInterface;
79
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\OnlineBankTransfer;
80
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\Prepayment;
81
use SprykerEco\Zed\Payone\Business\Payment\MethodMapper\SecurityInvoice;
82
use SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReader;
83
use SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface;
84
use SprykerEco\Zed\Payone\Business\Payment\PaymentMethodFilter;
85
use SprykerEco\Zed\Payone\Business\Payment\PaymentMethodFilterInterface;
86
use SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface;
87
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneFileReader;
88
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneFileReaderInterface;
89
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneInvoiceReader;
90
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneInvoiceReaderInterface;
91
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayonePaypalExpressCheckoutDetailsReader;
92
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayonePaypalExpressCheckoutDetailsReaderInterface;
93
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneSecurityInvoiceReader;
94
use SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneSecurityInvoiceReaderInterface;
95
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneAuthorizeRequestSender;
96
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneAuthorizeRequestSenderInterface;
97
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneBaseAuthorizeSender;
98
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneBaseAuthorizeSenderInterface;
99
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneCaptureRequestSender;
100
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneCaptureRequestSenderInterface;
101
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneDebitRequestSender;
102
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneDebitRequestSenderInterface;
103
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneGenericRequestMethodSender;
104
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneGenericRequestMethodSenderInterface;
105
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneInitPaypalExpressCheckoutMethodSender;
106
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneInitPaypalExpressCheckoutMethodSenderInterface;
107
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneKlarnaStartSessionMethodSender;
108
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneKlarnaStartSessionMethodSenderInterface;
109
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneManageMandateMethodSender;
110
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneManageMandateMethodSenderInterface;
111
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialCaptureRequestSender;
112
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialCaptureRequestSenderInterface;
113
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialRefundRequestSender;
114
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialRefundRequestSenderInterface;
115
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePreAuthorizeRequestSender;
116
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePreAuthorizeRequestSenderInterface;
117
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneRefundRequestSender;
118
use SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneRefundRequestSenderInterface;
119
use SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactory;
120
use SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface;
121
use SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapper;
122
use SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapperInterface;
123
use SprykerEco\Zed\Payone\Business\RiskManager\RiskCheckManager;
124
use SprykerEco\Zed\Payone\Business\RiskManager\RiskCheckManagerInterface;
125
use SprykerEco\Zed\Payone\Business\SequenceNumber\SequenceNumberProvider;
126
use SprykerEco\Zed\Payone\Business\SequenceNumber\SequenceNumberProviderInterface;
127
use SprykerEco\Zed\Payone\Business\TransactionStatus\TransactionStatusUpdateManager;
128
use SprykerEco\Zed\Payone\Business\TransactionStatus\TransactionStatusUpdateManagerInterface;
129
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToGlossaryFacadeInterface;
130
use SprykerEco\Zed\Payone\PayoneDependencyProvider;
131
use Symfony\Component\HttpFoundation\RequestStack;
132
133
/**
134
 * @method \SprykerEco\Zed\Payone\PayoneConfig getConfig()
135
 * @method \SprykerEco\Zed\Payone\Persistence\PayoneQueryContainerInterface getQueryContainer()
136
 * @method \SprykerEco\Zed\Payone\Persistence\PayoneRepositoryInterface getRepository()
137
 * @method \SprykerEco\Zed\Payone\Persistence\PayoneEntityManagerInterface getEntityManager()
138
 */
139
class PayoneBusinessFactory extends AbstractBusinessFactory
140
{
141
    /**
142
     * @var \Generated\Shared\Transfer\PayoneStandardParameterTransfer
143
     */
144
    private $standardParameter;
145
146
    /**
147
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePreAuthorizeRequestSenderInterface
148
     */
149
    public function createPayonePreAuthorizeRequestSender(): PayonePreAuthorizeRequestSenderInterface
150
    {
151
        return new PayonePreAuthorizeRequestSender(
152
            $this->getQueryContainer(),
153
            $this->createPaymentMapperReader(),
154
            $this->createPayoneBaseAuthorizeSender(),
155
            $this->createAuthorizationResponseMapper(),
156
        );
157
    }
158
159
    /**
160
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneAuthorizeRequestSenderInterface
161
     */
162
    public function createPayoneAuthorizeRequestSender(): PayoneAuthorizeRequestSenderInterface
163
    {
164
        return new PayoneAuthorizeRequestSender(
165
            $this->getQueryContainer(),
166
            $this->createPaymentMapperReader(),
167
            $this->createPayoneRequestProductDataMapper(),
168
            $this->createPayoneBaseAuthorizeSender(),
169
            $this->createAuthorizationResponseMapper(),
170
        );
171
    }
172
173
    /**
174
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneCaptureRequestSenderInterface
175
     */
176
    public function createPayoneCaptureRequestSender(): PayoneCaptureRequestSenderInterface
177
    {
178
        return new PayoneCaptureRequestSender(
179
            $this->createExecutionAdapter(),
180
            $this->getQueryContainer(),
181
            $this->createPaymentMapperReader(),
182
            $this->getStandardParameter(),
183
            $this->createOrderPriceDistributor(),
184
            $this->createStandartParameterMapper(),
185
            $this->createPayoneRequestProductDataMapper(),
186
            $this->createExpenseMapper(),
187
            $this->createCaptureResponseMapper(),
188
        );
189
    }
190
191
    /**
192
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialCaptureRequestSenderInterface
193
     */
194
    public function createPayonePartialCaptureRequestSender(): PayonePartialCaptureRequestSenderInterface
195
    {
196
        return new PayonePartialCaptureRequestSender(
197
            $this->createExecutionAdapter(),
198
            $this->getQueryContainer(),
199
            $this->createPaymentMapperReader(),
200
            $this->createExpenseMapper(),
201
            $this->getStandardParameter(),
202
            $this->getRepository(),
203
            $this->getEntityManager(),
204
            $this->createOrderPriceDistributor(),
205
            $this->createStandartParameterMapper(),
206
            $this->createShipmentMapper(),
207
            $this->createCaptureResponseMapper(),
208
        );
209
    }
210
211
    /**
212
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneDebitRequestSenderInterface
213
     */
214
    public function createPayoneDebitRequestSender(): PayoneDebitRequestSenderInterface
215
    {
216
        return new PayoneDebitRequestSender(
217
            $this->createExecutionAdapter(),
218
            $this->getQueryContainer(),
219
            $this->getStandardParameter(),
220
            $this->createStandartParameterMapper(),
221
            $this->createPaymentMapperReader(),
222
            $this->createDebitResponseMapper(),
223
        );
224
    }
225
226
    /**
227
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneRefundRequestSenderInterface
228
     */
229
    public function createPayoneRefundRequestSender(): PayoneRefundRequestSenderInterface
230
    {
231
        return new PayoneRefundRequestSender(
232
            $this->createExecutionAdapter(),
233
            $this->getQueryContainer(),
234
            $this->createPaymentMapperReader(),
235
            $this->getStandardParameter(),
236
            $this->createOrderPriceDistributor(),
237
            $this->createStandartParameterMapper(),
238
            $this->createPayoneRequestProductDataMapper(),
239
            $this->createRefundResponseMapper(),
240
        );
241
    }
242
243
    /**
244
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayonePartialRefundRequestSenderInterface
245
     */
246
    public function createPayonePartialRefundRequestSender(): PayonePartialRefundRequestSenderInterface
247
    {
248
        return new PayonePartialRefundRequestSender(
249
            $this->createExecutionAdapter(),
250
            $this->getQueryContainer(),
251
            $this->createPaymentMapperReader(),
252
            $this->getStandardParameter(),
253
            $this->getRepository(),
254
            $this->getEntityManager(),
255
            $this->createStandartParameterMapper(),
256
            $this->createRefundResponseMapper(),
257
        );
258
    }
259
260
    /**
261
     * @return \SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneBankAccountCheckerInterface
262
     */
263
    public function createPayoneBankAccountChecker(): PayoneBankAccountCheckerInterface
264
    {
265
        return new PayoneBankAccountChecker(
266
            $this->createExecutionAdapter(),
267
            $this->createPaymentMapperReader(),
268
            $this->getStandardParameter(),
269
            $this->createStandartParameterMapper(),
270
        );
271
    }
272
273
    /**
274
     * @return \SprykerEco\Zed\Payone\Business\Payment\Checker\PayoneCreditCardCheckerInterface
275
     */
276
    public function createPayoneCreditCardChecker(): PayoneCreditCardCheckerInterface
277
    {
278
        return new PayoneCreditCardChecker(
279
            $this->createExecutionAdapter(),
280
            $this->getStandardParameter(),
281
            $this->createStandartParameterMapper(),
282
            $this->createPaymentMapperReader(),
283
            $this->createCreditCardCheckResponseMapper(),
284
        );
285
    }
286
287
    /**
288
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneManageMandateMethodSenderInterface
289
     */
290
    public function createPayoneManageMandateMethodSender(): PayoneManageMandateMethodSenderInterface
291
    {
292
        return new PayoneManageMandateMethodSender(
293
            $this->createExecutionAdapter(),
294
            $this->getStandardParameter(),
295
            $this->createStandartParameterMapper(),
296
            $this->createPaymentMapperReader(),
297
        );
298
    }
299
300
    /**
301
     * @return \SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneFileReaderInterface
302
     */
303
    public function createPayoneFileReader(): PayoneFileReaderInterface
304
    {
305
        return new PayoneFileReader(
306
            $this->createExecutionAdapter(),
307
            $this->getQueryContainer(),
308
            $this->getStandardParameter(),
309
            $this->createStandartParameterMapper(),
310
            $this->createPaymentMapperReader(),
311
        );
312
    }
313
314
    /**
315
     * @return \SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneInvoiceReaderInterface
316
     */
317
    public function createPayoneInvoiceReader(): PayoneInvoiceReaderInterface
318
    {
319
        return new PayoneInvoiceReader(
320
            $this->createExecutionAdapter(),
321
            $this->getQueryContainer(),
322
            $this->getStandardParameter(),
323
            $this->createStandartParameterMapper(),
324
            $this->createPaymentMapperReader(),
325
        );
326
    }
327
328
    /**
329
     * @return \SprykerEco\Zed\Payone\Business\Payment\Reader\PayoneSecurityInvoiceReaderInterface
330
     */
331
    public function createPayoneSecurityInvoiceReader(): PayoneSecurityInvoiceReaderInterface
332
    {
333
        return new PayoneSecurityInvoiceReader(
334
            $this->createExecutionAdapter(),
335
            $this->getQueryContainer(),
336
            $this->getStandardParameter(),
337
            $this->createStandartParameterMapper(),
338
            $this->createPaymentMapperReader(),
339
        );
340
    }
341
342
    /**
343
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneInitPaypalExpressCheckoutMethodSenderInterface
344
     */
345
    public function createPayoneInitPaypalExpressCheckoutMethodSender(): PayoneInitPaypalExpressCheckoutMethodSenderInterface
346
    {
347
        return new PayoneInitPaypalExpressCheckoutMethodSender(
348
            $this->createPaymentMapperReader(),
349
            $this->createPayoneGenericRequestMethodSender(),
350
        );
351
    }
352
353
    /**
354
     * @return \SprykerEco\Zed\Payone\Business\Payment\Reader\PayonePaypalExpressCheckoutDetailsReaderInterface
355
     */
356
    public function createPayonePaypalExpressCheckoutDetailsReader(): PayonePaypalExpressCheckoutDetailsReaderInterface
357
    {
358
        return new PayonePaypalExpressCheckoutDetailsReader(
359
            $this->createPaymentMapperReader(),
360
            $this->createPayoneGenericRequestMethodSender()
361
        );
362
    }
363
364
    /**
365
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneGenericRequestMethodSenderInterface
366
     */
367
    public function createPayoneGenericRequestMethodSender(): PayoneGenericRequestMethodSenderInterface
368
    {
369
        return new PayoneGenericRequestMethodSender(
370
            $this->createExecutionAdapter(),
371
            $this->getStandardParameter(),
372
            $this->createStandartParameterMapper(),
373
        );
374
    }
375
376
    /**
377
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneKlarnaStartSessionMethodSenderInterface
378
     */
379
    public function createPayoneKlarnaStartSessionMethodSender(): PayoneKlarnaStartSessionMethodSenderInterface
380
    {
381
        return new PayoneKlarnaStartSessionMethodSender(
382
            $this->createExecutionAdapter(),
383
            $this->createStandartParameterMapper(),
384
            $this->createPayoneRequestProductDataMapper(),
385
            $this->createKlarnaPaymentMapper($this->getStore()),
386
            $this->getStandardParameter(),
387
            $this->createSequenceNumberProvider(),
388
            $this->createUrlHmacGenerator(),
389
        );
390
    }
391
392
    /**
393
     * @return \SprykerEco\Zed\Payone\Business\Order\OrderManagerInterface
394
     */
395
    public function createOrderManager(): OrderManagerInterface
396
    {
397
        return new OrderManager($this->getConfig(), $this->getEntityManager());
398
    }
399
400
    /**
401
     * @return \SprykerEco\Zed\Payone\Business\TransactionStatus\TransactionStatusUpdateManagerInterface
402
     */
403
    public function createTransactionStatusManager(): TransactionStatusUpdateManagerInterface
404
    {
405
        return new TransactionStatusUpdateManager(
406
            $this->getQueryContainer(),
407
            $this->getStandardParameter(),
408
            $this->createHashGenerator()
409
        );
410
    }
411
412
    /**
413
     * @return \SprykerEco\Zed\Payone\Business\ApiLog\ApiLogFinderInterface
414
     */
415
    public function createApiLogFinder(): ApiLogFinderInterface
416
    {
417
        return new ApiLogFinder(
418
            $this->getQueryContainer()
419
        );
420
    }
421
422
    /**
423
     * @return \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface
424
     */
425
    public function createExecutionAdapter(): AdapterInterface
426
    {
427
        return new Guzzle(
428
            $this->getStandardParameter()->getPaymentGatewayUrl(),
429
            $this->createApiCallLogWriter()
430
        );
431
    }
432
433
    /**
434
     * @return \SprykerEco\Zed\Payone\Business\Api\Log\ApiCallLogWriter
435
     */
436
    public function createApiCallLogWriter(): ApiCallLogWriter
437
    {
438
        return new ApiCallLogWriter(
439
            $this->getQueryContainer()
440
        );
441
    }
442
443
    /**
444
     * @return \SprykerEco\Zed\Payone\Business\SequenceNumber\SequenceNumberProviderInterface
445
     */
446
    public function createSequenceNumberProvider(): SequenceNumberProviderInterface
447
    {
448
        $defaultEmptySequenceNumber = $this->getConfig()->getEmptySequenceNumber();
449
450
        return new SequenceNumberProvider(
451
            $this->getQueryContainer(),
452
            $defaultEmptySequenceNumber
453
        );
454
    }
455
456
    /**
457
     * @return \SprykerEco\Shared\Payone\Dependency\HashInterface
458
     */
459
    public function createHashProvider(): HashInterface
460
    {
461
        return new HashProvider();
462
    }
463
464
    /**
465
     * @return \SprykerEco\Zed\Payone\Business\Key\HashGeneratorInterface
466
     */
467
    public function createHashGenerator(): HashGeneratorInterface
468
    {
469
        return new HashGenerator(
470
            $this->createHashProvider()
471
        );
472
    }
473
474
    /**
475
     * @return \SprykerEco\Zed\Payone\Business\Key\HmacGeneratorInterface
476
     */
477
    public function createUrlHmacGenerator(): HmacGeneratorInterface
478
    {
479
        return new UrlHmacGenerator();
480
    }
481
482
    /**
483
     * @return \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface
484
     */
485
    public function createModeDetector(): ModeDetectorInterface
486
    {
487
        return new ModeDetector($this->getConfig());
488
    }
489
490
    /**
491
     * @param \Generated\Shared\Transfer\PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer
492
     *
493
     * @return \SprykerEco\Zed\Payone\Business\Api\TransactionStatus\TransactionStatusRequest
494
     */
495
    public function createTransactionStatusRequest(PayoneTransactionStatusUpdateTransfer $transactionStatusUpdateTransfer): TransactionStatusRequest
496
    {
497
        return new TransactionStatusRequest($transactionStatusUpdateTransfer->toArray());
498
    }
499
500
    /**
501
     * @return \SprykerEco\Zed\Payone\Business\Payment\RequestSender\PayoneBaseAuthorizeSenderInterface
502
     */
503
    public function createPayoneBaseAuthorizeSender(): PayoneBaseAuthorizeSenderInterface
504
    {
505
        return new PayoneBaseAuthorizeSender(
506
            $this->createExecutionAdapter(),
507
            $this->getQueryContainer(),
508
            $this->createPaymentMapperReader(),
509
            $this->getStandardParameter(),
510
            $this->createStandartParameterMapper(),
511
        );
512
    }
513
514
    /**
515
     * @param \Spryker\Shared\Kernel\Store $storeConfig
516
     *
517
     * @return \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CreditCardPseudoInterface
518
     */
519
    public function createCreditCardPseudo(Store $storeConfig): CreditCardPseudoInterface
520
    {
521
        return new CreditCardPseudo($storeConfig);
522
    }
523
524
    /**
525
     * @param \Spryker\Shared\Kernel\Store $storeConfig
526
     *
527
     * @return \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\DirectDebitInterface
528
     */
529
    public function createDirectDebit(Store $storeConfig): DirectDebitInterface
530
    {
531
        return new DirectDebit($storeConfig);
532
    }
533
534
    /**
535
     * @param \Spryker\Shared\Kernel\Store $storeConfig
536
     *
537
     * @return \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\InvoiceInterface
538
     */
539
    public function createInvoice(Store $storeConfig): InvoiceInterface
540
    {
541
        return new Invoice($storeConfig);
542
    }
543
544
    /**
545
     * @param \Spryker\Shared\Kernel\Store $storeConfig
546
     *
547
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface
548
     */
549
    public function createSecurityInvoice(Store $storeConfig): PaymentMethodMapperInterface
550
    {
551
        return new SecurityInvoice($storeConfig, $this->getConfig());
552
    }
553
554
    /**
555
     * @param \Spryker\Shared\Kernel\Store $storeConfig
556
     *
557
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface
558
     */
559
    public function createOnlineBankTransfer(Store $storeConfig): PaymentMethodMapperInterface
560
    {
561
        return new OnlineBankTransfer($storeConfig);
562
    }
563
564
    /**
565
     * @param \Spryker\Shared\Kernel\Store $storeConfig
566
     *
567
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface
568
     */
569
    public function createEWallet(Store $storeConfig): PaymentMethodMapperInterface
570
    {
571
        return new EWallet($storeConfig);
572
    }
573
574
    /**
575
     * @param \Spryker\Shared\Kernel\Store $storeConfig
576
     * @param \SprykerEco\Zed\Payone\Dependency\Facade\PayoneToGlossaryFacadeInterface $glossary
577
     *
578
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface
579
     */
580
    public function createCashOnDelivery(Store $storeConfig, PayoneToGlossaryFacadeInterface $glossary): PaymentMethodMapperInterface
581
    {
582
        return new CashOnDelivery($storeConfig, $glossary);
583
    }
584
585
    /**
586
     * @param \Spryker\Shared\Kernel\Store $storeConfig
587
     *
588
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodMapperInterface
589
     */
590
    public function createPrepayment(Store $storeConfig): PaymentMethodMapperInterface
591
    {
592
        return new Prepayment($storeConfig);
593
    }
594
595
    /**
596
     * @param \Spryker\Shared\Kernel\Store $store
597
     *
598
     * @return \SprykerEco\Zed\Payone\Business\Payment\GenericPaymentMethodMapperInterface
599
     */
600
    public function createGenericPayment(Store $store): GenericPaymentMethodMapperInterface
601
    {
602
        return new GenericPayment($store);
603
    }
604
605
    /**
606
     * @param \Spryker\Shared\Kernel\Store $store
607
     *
608
     * @return \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\KlarnaPaymentMapperInterface
609
     */
610
    public function createKlarnaPaymentMapper(Store $store): KlarnaPaymentMapperInterface
611
    {
612
        return new KlarnaPaymentMapper($store, $this->getRequestStack());
613
    }
614
615
    /**
616
     * @return \SprykerEco\Zed\Payone\Business\RiskManager\RiskCheckManagerInterface
617
     */
618
    public function createRiskCheckManager(): RiskCheckManagerInterface
619
    {
620
        return new RiskCheckManager(
621
            $this->createRiskCheckMapper(),
622
            $this->createExecutionAdapter(),
623
            $this->createRiskCheckFactory()
624
        );
625
    }
626
627
    /**
628
     * @return \SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapperInterface
629
     */
630
    public function createRiskCheckMapper(): RiskCheckMapperInterface
631
    {
632
        return new RiskCheckMapper(
633
            $this->createRiskCheckFactory(),
634
            $this->getStandardParameter(),
635
            $this->createModeDetector(),
636
            $this->getConfig()
637
        );
638
    }
639
640
    /**
641
     * @return \SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface
642
     */
643
    public function createRiskCheckFactory(): RiskCheckFactoryInterface
644
    {
645
        return new RiskCheckFactory();
646
    }
647
648
    /**
649
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMethodFilterInterface
650
     */
651
    public function createPaymentMethodFilter(): PaymentMethodFilterInterface
652
    {
653
        return new PaymentMethodFilter($this->getConfig());
654
    }
655
656
    /**
657
     * @return \SprykerEco\Zed\Payone\Business\Order\PayoneOrderItemStatusFinderInterface
658
     */
659
    public function createPayoneOrderItemStatusFinder(): PayoneOrderItemStatusFinderInterface
660
    {
661
        return new PayoneOrderItemStatusFinder($this->getRepository());
662
    }
663
664
    /**
665
     * @return \SprykerEco\Zed\Payone\Business\Distributor\OrderPriceDistributorInterface
666
     */
667
    public function createOrderPriceDistributor(): OrderPriceDistributorInterface
668
    {
669
        return new OrderPriceDistributor();
670
    }
671
672
    /**
673
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\StandartParameterMapperInterface
674
     */
675
    public function createStandartParameterMapper(): StandartParameterMapperInterface
676
    {
677
        return new StandartParameterMapper($this->createHashGenerator(), $this->createModeDetector());
678
    }
679
680
    /**
681
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\PayoneRequestProductDataMapperInterface
682
     */
683
    public function createPayoneRequestProductDataMapper(): PayoneRequestProductDataMapperInterface
684
    {
685
        return new PayoneRequestProductDataMapper(
686
            $this->createProductMapper(),
687
            $this->createShipmentMapper(),
688
            $this->createDiscountMapper(),
689
        );
690
    }
691
692
    /**
693
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\ProductMapperInterface
694
     */
695
    public function createProductMapper(): ProductMapperInterface
696
    {
697
        return new ProductMapper();
698
    }
699
700
    /**
701
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\ShipmentMapperInterface
702
     */
703
    public function createShipmentMapper(): ShipmentMapperInterface
704
    {
705
        return new ShipmentMapper();
706
    }
707
708
    /**
709
     * @return \SprykerEco\Zed\Payone\Business\Payment\PaymentMapperReaderInterface
710
     */
711
    public function createPaymentMapperReader(): PaymentMapperReaderInterface
712
    {
713
        $paymentMapperReader = new PaymentMapperReader(
714
            $this->createSequenceNumberProvider(),
715
            $this->createUrlHmacGenerator()
716
        );
717
718
        foreach ($this->getAvailablePaymentMethods() as $paymentMethod) {
719
            $paymentMapperReader->registerPaymentMethodMapper($paymentMethod, $this->getStandardParameter());
720
        }
721
722
        return $paymentMapperReader;
723
    }
724
725
    /**
726
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\DiscountMapperInterface
727
     */
728
    public function createDiscountMapper(): DiscountMapperInterface
729
    {
730
        return new DiscountMapper();
731
    }
732
733
    /**
734
     * @return \SprykerEco\Zed\Payone\Business\Payment\DataMapper\ExpenseMapperInterface
735
     */
736
    public function createExpenseMapper(): ExpenseMapperInterface
737
    {
738
        return new ExpenseMapper();
739
    }
740
741
    /**
742
     * @return \SprykerEco\Zed\Payone\Business\ConditionChecker\RefundCheckerInterface
743
     */
744
    public function createRefundChecker(): RefundCheckerInterface
745
    {
746
        return new RefundChecker($this->getRepository(), $this->createPaymentDataChecker());
747
    }
748
749
    /**
750
     * @return \SprykerEco\Zed\Payone\Business\ConditionChecker\PaymentDataCheckerInterface
751
     */
752
    public function createPaymentDataChecker(): PaymentDataCheckerInterface
753
    {
754
        return new PaymentDataChecker($this->getRepository(), $this->getConfig());
755
    }
756
757
    /**
758
     * @return \SprykerEco\Zed\Payone\Business\Payment\Hook\PostSaveHookInterface
759
     */
760
    public function createPostSaveHook(): PostSaveHookInterface
761
    {
762
        return new PostSaveHook(
763
            $this->getRepository(),
764
            $this->createPaymentMapperReader(),
765
            $this->createPayoneRequestProductDataMapper(),
766
            $this->createPayoneBaseAuthorizeSender()
767
        );
768
    }
769
770
    /**
771
     * @return \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\RefundResponseMapperInterface
772
     */
773
    public function createRefundResponseMapper(): RefundResponseMapperInterface
774
    {
775
        return new RefundResponseMapper();
776
    }
777
778
    /**
779
     * @return \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\AuthorizationResponseMapperInterface
780
     */
781
    public function createAuthorizationResponseMapper(): AuthorizationResponseMapperInterface
782
    {
783
        return new AuthorizationResponseMapper();
784
    }
785
786
    /**
787
     * @return \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CaptureResponseMapperInterface
788
     */
789
    public function createCaptureResponseMapper(): CaptureResponseMapperInterface
790
    {
791
        return new CaptureResponseMapper();
792
    }
793
794
    /**
795
     * @return \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\CreditCardCheckResponseMapperInterface
796
     */
797
    public function createCreditCardCheckResponseMapper(): CreditCardCheckResponseMapperInterface
798
    {
799
        return new CreditCardCheckResponseMapper();
800
    }
801
802
    /**
803
     * @return \SprykerEco\Zed\Payone\Business\Api\Response\Mapper\DebitResponseMapperInterface
804
     */
805
    public function createDebitResponseMapper(): DebitResponseMapperInterface
806
    {
807
        return new DebitResponseMapper();
808
    }
809
810
    /**
811
     * @return array
812
     */
813
    public function getAvailablePaymentMethods(): array
814
    {
815
        $storeConfig = $this->getProvidedDependency(PayoneDependencyProvider::STORE_CONFIG);
816
817
        return [
818
            PayoneApiConstants::PAYMENT_METHOD_CREDITCARD_PSEUDO => $this->createCreditCardPseudo($storeConfig),
819
            PayoneApiConstants::PAYMENT_METHOD_INVOICE => $this->createInvoice($storeConfig),
820
            PayoneApiConstants::PAYMENT_METHOD_SECURITY_INVOICE => $this->createSecurityInvoice($storeConfig),
821
            PayoneApiConstants::PAYMENT_METHOD_ONLINE_BANK_TRANSFER => $this->createOnlineBankTransfer($storeConfig),
822
            PayoneApiConstants::PAYMENT_METHOD_E_WALLET => $this->createEWallet($storeConfig),
823
            PayoneApiConstants::PAYMENT_METHOD_PREPAYMENT => $this->createPrepayment($storeConfig),
824
            PayoneApiConstants::PAYMENT_METHOD_DIRECT_DEBIT => $this->createDirectDebit($storeConfig),
825
            PayoneApiConstants::PAYMENT_METHOD_PAYPAL_EXPRESS_CHECKOUT => $this->createGenericPayment($storeConfig),
826
            PayoneApiConstants::PAYMENT_METHOD_CASH_ON_DELIVERY => $this->createCashOnDelivery($storeConfig, $this->getGlossaryFacade()),
827
            PayoneApiConstants::PAYMENT_METHOD_KLARNA => $this->createKlarnaPaymentMapper($storeConfig),
828
        ];
829
    }
830
831
    /**
832
     * @return \Spryker\Shared\Kernel\Store
833
     */
834
    public function getStore(): Store
835
    {
836
        return $this->getProvidedDependency(PayoneDependencyProvider::STORE_CONFIG);
837
    }
838
839
    /**
840
     * @return \Generated\Shared\Transfer\PayoneStandardParameterTransfer
841
     */
842
    public function getStandardParameter(): PayoneStandardParameterTransfer
843
    {
844
        if ($this->standardParameter === null) {
845
            $this->standardParameter = $this->getConfig()->getRequestStandardParameter();
846
        }
847
848
        return $this->standardParameter;
849
    }
850
851
    /**
852
     * @return \SprykerEco\Zed\Payone\Dependency\Facade\PayoneToGlossaryFacadeInterface
853
     */
854
    public function getGlossaryFacade(): PayoneToGlossaryFacadeInterface
855
    {
856
        return $this->getProvidedDependency(PayoneDependencyProvider::FACADE_GLOSSARY);
857
    }
858
859
    /**
860
     * @return \Symfony\Component\HttpFoundation\RequestStack
861
     */
862
    public function getRequestStack(): RequestStack
863
    {
864
        return $this->getProvidedDependency(PayoneDependencyProvider::SERVICE_REQUEST_STACK);
865
    }
866
}
867