|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MIT License |
|
4
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace SprykerEco\Zed\Heidelpay\Business\Adapter; |
|
8
|
|
|
|
|
9
|
|
|
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; |
|
10
|
|
|
use SprykerEco\Shared\Heidelpay\HeidelpayConfig; |
|
11
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\RequestToHeidelpay; |
|
12
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\ResponseFromHeidelpay; |
|
13
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\ResponsePayloadToApiResponse; |
|
14
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\CreditCardPayment; |
|
15
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\IdealPayment; |
|
16
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\PaypalPayment; |
|
17
|
|
|
use SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\SofortPayment; |
|
18
|
|
|
use SprykerEco\Zed\Heidelpay\HeidelpayDependencyProvider; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @method \SprykerEco\Zed\Heidelpay\HeidelpayConfig getConfig() |
|
22
|
|
|
*/ |
|
23
|
|
|
class AdapterFactory extends AbstractBusinessFactory implements AdapterFactoryInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Payment\Type\PaymentWithAuthorizeInterface[] |
|
27
|
|
|
*/ |
|
28
|
|
View Code Duplication |
public function getAuthorizePaymentMethodAdapterCollection() |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
return [ |
|
31
|
|
|
HeidelpayConfig::PAYMENT_METHOD_SOFORT => $this->createSofortPaymentMethodAdapter(), |
|
32
|
|
|
HeidelpayConfig::PAYMENT_METHOD_PAYPAL_AUTHORIZE => $this->createPaypalPaymentMethodAdapter(), |
|
33
|
|
|
HeidelpayConfig::PAYMENT_METHOD_IDEAL => $this->createIdealPaymentMethodAdapter(), |
|
34
|
|
|
HeidelpayConfig::PAYMENT_METHOD_CREDIT_CARD_SECURE => $this->createCreditCardPaymentMethodAdapter(), |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Payment\Type\PaymentWithCaptureInterface[] |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getCapturePaymentMethodAdapterCollection() |
|
42
|
|
|
{ |
|
43
|
|
|
return [ |
|
44
|
|
|
HeidelpayConfig::PAYMENT_METHOD_PAYPAL_AUTHORIZE => $this->createPaypalPaymentMethodAdapter(), |
|
45
|
|
|
HeidelpayConfig::PAYMENT_METHOD_CREDIT_CARD_SECURE => $this->createCreditCardPaymentMethodAdapter(), |
|
46
|
|
|
]; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Payment\Type\PaymentWithDebitInterface[] |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getDebitPaymentMethodAdapterCollection() |
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
|
|
HeidelpayConfig::PAYMENT_METHOD_PAYPAL_DEBIT => $this->createPaypalPaymentMethodAdapter(), |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Payment\Type\PaymentWithExternalResponseInterface[] |
|
61
|
|
|
*/ |
|
62
|
|
View Code Duplication |
public function getExternalResponsePaymentMethodAdapterCollection() |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
return [ |
|
65
|
|
|
HeidelpayConfig::PAYMENT_METHOD_SOFORT => $this->createSofortPaymentMethodAdapter(), |
|
66
|
|
|
HeidelpayConfig::PAYMENT_METHOD_PAYPAL_AUTHORIZE => $this->createPaypalPaymentMethodAdapter(), |
|
67
|
|
|
HeidelpayConfig::PAYMENT_METHOD_PAYPAL_DEBIT => $this->createPaypalPaymentMethodAdapter(), |
|
68
|
|
|
HeidelpayConfig::PAYMENT_METHOD_IDEAL => $this->createIdealPaymentMethodAdapter(), |
|
69
|
|
|
HeidelpayConfig::PAYMENT_METHOD_CREDIT_CARD_SECURE => $this->createCreditCardPaymentMethodAdapter(), |
|
70
|
|
|
]; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\SofortPaymentInterface |
|
75
|
|
|
*/ |
|
76
|
|
|
public function createSofortPaymentMethodAdapter() |
|
77
|
|
|
{ |
|
78
|
|
|
return new SofortPayment( |
|
79
|
|
|
$this->createRequestToHeidelpayMapper(), |
|
80
|
|
|
$this->createResponseFromHeidelpayMapper(), |
|
81
|
|
|
$this->getHeidelpayConfig() |
|
82
|
|
|
); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\IdealPaymentInterface |
|
87
|
|
|
*/ |
|
88
|
|
|
public function createIdealPaymentMethodAdapter() |
|
89
|
|
|
{ |
|
90
|
|
|
return new IdealPayment( |
|
91
|
|
|
$this->createRequestToHeidelpayMapper(), |
|
92
|
|
|
$this->createResponseFromHeidelpayMapper(), |
|
93
|
|
|
$this->getHeidelpayConfig() |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\PaypalPaymentInterface |
|
99
|
|
|
*/ |
|
100
|
|
|
public function createPaypalPaymentMethodAdapter() |
|
101
|
|
|
{ |
|
102
|
|
|
return new PaypalPayment( |
|
103
|
|
|
$this->createRequestToHeidelpayMapper(), |
|
104
|
|
|
$this->createResponseFromHeidelpayMapper(), |
|
105
|
|
|
$this->getHeidelpayConfig() |
|
106
|
|
|
); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Payment\CreditCardPaymentInterface |
|
111
|
|
|
*/ |
|
112
|
|
|
public function createCreditCardPaymentMethodAdapter() |
|
113
|
|
|
{ |
|
114
|
|
|
return new CreditCardPayment( |
|
115
|
|
|
$this->createRequestToHeidelpayMapper(), |
|
116
|
|
|
$this->createResponseFromHeidelpayMapper(), |
|
117
|
|
|
$this->getHeidelpayConfig() |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\TransactionParserInterface |
|
123
|
|
|
*/ |
|
124
|
|
|
public function createTransactionParser() |
|
125
|
|
|
{ |
|
126
|
|
|
return new TransactionParser( |
|
127
|
|
|
$this->createResponseFromHeidelpayMapper(), |
|
128
|
|
|
$this->createResponsePayloadToApiResponseMapper() |
|
129
|
|
|
); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\ResponsePayloadToApiResponseInterface |
|
134
|
|
|
*/ |
|
135
|
|
|
protected function createResponsePayloadToApiResponseMapper() |
|
136
|
|
|
{ |
|
137
|
|
|
return new ResponsePayloadToApiResponse( |
|
138
|
|
|
$this->getUtilEncodingService() |
|
139
|
|
|
); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\RequestToHeidelpayInterface |
|
144
|
|
|
*/ |
|
145
|
|
|
protected function createRequestToHeidelpayMapper() |
|
146
|
|
|
{ |
|
147
|
|
|
return new RequestToHeidelpay(); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Business\Adapter\Mapper\ResponseFromHeidelpayInterface |
|
152
|
|
|
*/ |
|
153
|
|
|
protected function createResponseFromHeidelpayMapper() |
|
154
|
|
|
{ |
|
155
|
|
|
return new ResponseFromHeidelpay( |
|
156
|
|
|
$this->getUtilEncodingService() |
|
157
|
|
|
); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @return \SprykerEco\Zed\Heidelpay\HeidelpayConfigInterface |
|
162
|
|
|
*/ |
|
163
|
|
|
protected function getHeidelpayConfig() |
|
164
|
|
|
{ |
|
165
|
|
|
return $this->getConfig(); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @return \SprykerEco\Zed\Heidelpay\Dependency\Service\HeidelpayToUtilEncodingInterface |
|
170
|
|
|
*/ |
|
171
|
|
|
protected function getUtilEncodingService() |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->getProvidedDependency(HeidelpayDependencyProvider::SERVICE_UTIL_ENCODING); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.