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\PaymentProcessorModel; |
19
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\Placement; |
20
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\RefundOrderModel; |
21
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\RelatedItemsUpdateModel; |
22
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Order\Saver; |
23
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Ipn\IpnFactory; |
24
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\Logger\TransactionLogger; |
25
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\TransactionFactory; |
26
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Writer\AmazonpayPaymentWriter; |
27
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Payment\Writer\AmazonpayPaymentWriterInterface; |
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
|
|
|
$this->createAmazonPayPaymentWriter() |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface |
54
|
|
|
*/ |
55
|
|
|
public function createAmazonpayConfig() |
56
|
|
|
{ |
57
|
|
|
return new AmazonPayConfig(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Quote\QuoteUpdateFactoryInterface |
62
|
|
|
*/ |
63
|
|
|
public function createQuoteUpdateFactory() |
64
|
|
|
{ |
65
|
|
|
return new QuoteUpdateFactory( |
66
|
|
|
$this->createAdapterFactory(), |
67
|
|
|
$this->getShipmentFacade() |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Ipn\IpnFactoryInterface |
73
|
|
|
*/ |
74
|
|
|
public function createIpnFactory() |
75
|
|
|
{ |
76
|
|
|
return new IpnFactory( |
77
|
|
|
$this->getOmsFacade(), |
78
|
|
|
$this->getQueryContainer(), |
79
|
|
|
$this->getUtilEncodingService(), |
80
|
|
|
$this->createRefundOrderModel(), |
81
|
|
|
$this->createAmazonpayConfig() |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToRefundInterface |
87
|
|
|
*/ |
88
|
|
|
public function getRefundFacade() |
89
|
|
|
{ |
90
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_REFUND); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToMoneyInterface |
95
|
|
|
*/ |
96
|
|
|
protected function getMoneyFacade() |
97
|
|
|
{ |
98
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_MONEY); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToOmsInterface |
103
|
|
|
*/ |
104
|
|
|
protected function getOmsFacade() |
105
|
|
|
{ |
106
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_OMS); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToShipmentInterface |
111
|
|
|
*/ |
112
|
|
|
protected function getShipmentFacade() |
113
|
|
|
{ |
114
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::FACADE_SHIPMENT); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToUtilEncodingInterface |
119
|
|
|
*/ |
120
|
|
|
protected function getUtilEncodingService() |
121
|
|
|
{ |
122
|
|
|
return $this->getProvidedDependency(AmazonPayDependencyProvider::SERVICE_UTIL_ENCODING); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Api\Adapter\AdapterFactoryInterface |
127
|
|
|
*/ |
128
|
|
|
public function createAdapterFactory() |
129
|
|
|
{ |
130
|
|
|
return new AdapterFactory( |
131
|
|
|
$this->createAmazonpayConfig(), |
132
|
|
|
$this->createConverterFactory(), |
133
|
|
|
$this->getMoneyFacade() |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Api\Converter\ConverterFactoryInterface |
139
|
|
|
*/ |
140
|
|
|
protected function createConverterFactory() |
141
|
|
|
{ |
142
|
|
|
return new ConverterFactory(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\SaverInterface |
147
|
|
|
*/ |
148
|
|
|
public function createOrderSaver() |
149
|
|
|
{ |
150
|
|
|
return new Saver(); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Payment\Handler\Transaction\Logger\TransactionLoggerInterface |
155
|
|
|
*/ |
156
|
|
|
public function createTransactionLogger() |
157
|
|
|
{ |
158
|
|
|
return new TransactionLogger($this->createAmazonpayConfig()); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToSalesInterface |
163
|
|
|
*/ |
164
|
|
|
public function getSalesFacade() |
165
|
|
|
{ |
166
|
|
|
return $this->getProvidedDependency( |
167
|
|
|
AmazonPayDependencyProvider::FACADE_SALES |
168
|
|
|
); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayConverterInterface |
173
|
|
|
*/ |
174
|
|
|
public function createAmazonpayConverter() |
175
|
|
|
{ |
176
|
|
|
return new AmazonPayConverter(); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Converter\AmazonPayTransferToEntityConverterInterface |
181
|
|
|
*/ |
182
|
|
|
protected function createAmazonpayTransferToEntityConverter() |
183
|
|
|
{ |
184
|
|
|
return new AmazonPayTransferToEntityConverter(); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\RefundOrderInterface |
189
|
|
|
*/ |
190
|
|
|
protected function createRefundOrderModel() |
191
|
|
|
{ |
192
|
|
|
return new RefundOrderModel($this->getRefundFacade()); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\AmazonpayOrderInfoHydratorInterface |
197
|
|
|
*/ |
198
|
|
|
public function createAmazonpayOrderInfoHydrator() |
199
|
|
|
{ |
200
|
|
|
return new AmazonpayOrderInfoHydrator( |
201
|
|
|
$this->getQueryContainer() |
202
|
|
|
); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\RelatedItemsUpdateInterface |
207
|
|
|
*/ |
208
|
|
|
public function createRelatedItemsUpdateModel() |
209
|
|
|
{ |
210
|
|
|
return new RelatedItemsUpdateModel( |
211
|
|
|
$this->getQueryContainer(), |
212
|
|
|
$this->getOmsFacade() |
213
|
|
|
); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\PaymentProcessorInterface |
218
|
|
|
*/ |
219
|
|
|
protected function createPaymentProcessorModel() |
220
|
|
|
{ |
221
|
|
|
return new PaymentProcessorModel( |
222
|
|
|
$this->getQueryContainer(), |
223
|
|
|
$this->createAmazonpayTransferToEntityConverter() |
224
|
|
|
); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @return \SprykerEco\Zed\AmazonPay\Business\Order\PlacementInterface |
229
|
|
|
*/ |
230
|
|
|
public function createPlacement() |
231
|
|
|
{ |
232
|
|
|
return new Placement( |
233
|
|
|
$this->createTransactionFactory() |
234
|
|
|
->createConfirmPurchaseTransaction() |
235
|
|
|
); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return AmazonpayPaymentWriterInterface |
240
|
|
|
*/ |
241
|
|
|
public function createAmazonPayPaymentWriter(): AmazonpayPaymentWriterInterface |
242
|
|
|
{ |
243
|
|
|
return new AmazonpayPaymentWriter(); |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
|