1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Apache OSL-2 |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\AmazonPay\Business; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; |
11
|
|
|
use SprykerEco\Shared\AmazonPay\AmazonPayConfig; |
12
|
|
|
use SprykerEco\Zed\AmazonPay\AmazonPayDependencyProvider; |
13
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Api\Adapter\AdapterFactory; |
14
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Api\Converter\ConverterFactory; |
15
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayConverter; |
16
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverter; |
17
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\AmazonpayOrderInfoHydrator; |
18
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\OrderAuthorizer; |
19
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\OrderAuthorizerInterface; |
20
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\PaymentProcessorModel; |
21
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\Placement; |
22
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\RefundOrderModel; |
23
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\RelatedItemsUpdateModel; |
24
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\Saver; |
25
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Ipn\IpnFactory; |
26
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\Logger\TransactionLogger; |
27
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\TransactionFactory; |
28
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Quote\QuoteUpdateFactory; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @method \SprykerEco\Zed\AmazonPay\Persistence\AmazonPayQueryContainerInterface getQueryContainer() |
32
|
|
|
*/ |
33
|
|
|
class AmazonPayBusinessFactory extends AbstractBusinessFactory |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\TransactionFactoryInterface |
37
|
|
|
*/ |
38
|
|
|
public function createTransactionFactory() |
39
|
|
|
{ |
40
|
|
|
return new TransactionFactory( |
41
|
|
|
$this->createAdapterFactory(), |
42
|
|
|
$this->createAmazonpayConfig(), |
43
|
|
|
$this->createTransactionLogger(), |
44
|
|
|
$this->createAmazonpayConverter(), |
45
|
|
|
$this->createAmazonpayTransferToEntityConverter(), |
46
|
|
|
$this->createRefundOrderModel(), |
47
|
|
|
$this->createPaymentProcessorModel() |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface |
53
|
|
|
*/ |
54
|
|
|
public function createAmazonpayConfig() |
55
|
|
|
{ |
56
|
|
|
return new AmazonPayConfig(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Quote\QuoteUpdateFactoryInterface |
61
|
|
|
*/ |
62
|
|
|
public function createQuoteUpdateFactory() |
63
|
|
|
{ |
64
|
|
|
return new QuoteUpdateFactory( |
65
|
|
|
$this->createAdapterFactory(), |
66
|
|
|
$this->getShipmentFacade() |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Ipn\IpnFactoryInterface |
72
|
|
|
*/ |
73
|
|
|
public function createIpnFactory() |
74
|
|
|
{ |
75
|
|
|
return new IpnFactory( |
76
|
|
|
$this->getOmsFacade(), |
77
|
|
|
$this->getQueryContainer(), |
78
|
|
|
$this->getUtilEncodingService(), |
79
|
|
|
$this->createRefundOrderModel(), |
80
|
|
|
$this->createAmazonpayConfig() |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToRefundInterface |
86
|
|
|
*/ |
87
|
|
|
public function getRefundFacade() |
88
|
|
|
{ |
89
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_REFUND); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToMoneyInterface |
94
|
|
|
*/ |
95
|
|
|
protected function getMoneyFacade() |
96
|
|
|
{ |
97
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_MONEY); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToOmsInterface |
102
|
|
|
*/ |
103
|
|
|
protected function getOmsFacade() |
104
|
|
|
{ |
105
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_OMS); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToShipmentInterface |
110
|
|
|
*/ |
111
|
|
|
protected function getShipmentFacade() |
112
|
|
|
{ |
113
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_SHIPMENT); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToUtilEncodingInterface |
118
|
|
|
*/ |
119
|
|
|
protected function getUtilEncodingService() |
120
|
|
|
{ |
121
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::SERVICE_UTIL_ENCODING); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Api\Adapter\AdapterFactoryInterface |
126
|
|
|
*/ |
127
|
|
|
public function createAdapterFactory() |
128
|
|
|
{ |
129
|
|
|
return new AdapterFactory( |
130
|
|
|
$this->createAmazonpayConfig(), |
131
|
|
|
$this->createConverterFactory(), |
132
|
|
|
$this->getMoneyFacade() |
133
|
|
|
); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Api\Converter\ConverterFactoryInterface |
138
|
|
|
*/ |
139
|
|
|
protected function createConverterFactory() |
140
|
|
|
{ |
141
|
|
|
return new ConverterFactory(); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\SaverInterface |
146
|
|
|
*/ |
147
|
|
|
public function createOrderSaver() |
148
|
|
|
{ |
149
|
|
|
return new Saver(); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\Logger\TransactionLoggerInterface |
154
|
|
|
*/ |
155
|
|
|
public function createTransactionLogger() |
156
|
|
|
{ |
157
|
|
|
return new TransactionLogger($this->createAmazonpayConfig()); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToSalesInterface |
162
|
|
|
*/ |
163
|
|
|
public function getSalesFacade() |
164
|
|
|
{ |
165
|
|
|
return $this->getProvidedDependency( |
166
|
|
|
AmazonPayDependencyProvider::FACADE_SALES |
167
|
|
|
); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayConverterInterface |
172
|
|
|
*/ |
173
|
|
|
public function createAmazonpayConverter() |
174
|
|
|
{ |
175
|
|
|
return new AmazonPayConverter(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverterInterface |
180
|
|
|
*/ |
181
|
|
|
protected function createAmazonpayTransferToEntityConverter() |
182
|
|
|
{ |
183
|
|
|
return new AmazonPayTransferToEntityConverter(); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\RefundOrderInterface |
188
|
|
|
*/ |
189
|
|
|
protected function createRefundOrderModel() |
190
|
|
|
{ |
191
|
|
|
return new RefundOrderModel($this->getRefundFacade()); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\AmazonpayOrderInfoHydratorInterface |
196
|
|
|
*/ |
197
|
|
|
public function createAmazonpayOrderInfoHydrator() |
198
|
|
|
{ |
199
|
|
|
return new AmazonpayOrderInfoHydrator( |
200
|
|
|
$this->getQueryContainer() |
201
|
|
|
); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\RelatedItemsUpdateInterface |
206
|
|
|
*/ |
207
|
|
|
public function createRelatedItemsUpdateModel() |
208
|
|
|
{ |
209
|
|
|
return new RelatedItemsUpdateModel( |
210
|
|
|
$this->getQueryContainer(), |
211
|
|
|
$this->getOmsFacade() |
212
|
|
|
); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\PaymentProcessorInterface |
217
|
|
|
*/ |
218
|
|
|
protected function createPaymentProcessorModel() |
219
|
|
|
{ |
220
|
|
|
return new PaymentProcessorModel( |
221
|
|
|
$this->getQueryContainer(), |
222
|
|
|
$this->createAmazonpayTransferToEntityConverter() |
223
|
|
|
); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\PlacementInterface |
228
|
|
|
*/ |
229
|
|
|
public function createPlacement() |
230
|
|
|
{ |
231
|
|
|
return new Placement( |
232
|
|
|
$this->createTransactionFactory() |
233
|
|
|
->createConfirmPurchaseTransaction() |
234
|
|
|
); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\OrderAuthorizerInterface |
239
|
|
|
*/ |
240
|
|
|
public function createOrderAuthorizer(): OrderAuthorizerInterface |
241
|
|
|
{ |
242
|
|
|
return new OrderAuthorizer( |
243
|
|
|
$this->createAmazonpayConverter(), |
244
|
|
|
$this->createTransactionFactory()->createAuthorizeTransaction() |
245
|
|
|
); |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|