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\Braintree\Business; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; |
11
|
|
|
use SprykerEco\Zed\Braintree\BraintreeDependencyProvider; |
12
|
|
|
use SprykerEco\Zed\Braintree\Business\Hook\PostSaveHook; |
13
|
|
|
use SprykerEco\Zed\Braintree\Business\Hook\PostSaveHookInterface; |
14
|
|
|
use SprykerEco\Zed\Braintree\Business\Log\TransactionStatusLog; |
15
|
|
|
use SprykerEco\Zed\Braintree\Business\Log\TransactionStatusLogInterface; |
16
|
|
|
use SprykerEco\Zed\Braintree\Business\Order\Saver; |
17
|
|
|
use SprykerEco\Zed\Braintree\Business\Order\SaverInterface; |
18
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Filter\PaypalExpressPaymentMethodFilter; |
19
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Filter\PaypalExpressPaymentMethodFilterInterface; |
20
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\AuthorizeTransaction; |
21
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\CaptureItemsTransaction; |
22
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\CaptureOrderTransaction; |
23
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\AuthorizeTransactionHandler; |
24
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\AuthorizeTransactionHandlerInterface; |
25
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureItemsTransactionHandler; |
26
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureItemsTransactionHandlerInterface; |
27
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureOrderTransactionHandler; |
28
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureOrderTransactionHandlerInterface; |
29
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\PreCheckTransactionHandler; |
30
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\PreCheckTransactionHandlerInterface; |
31
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundItemsTransactionHandler; |
32
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundItemsTransactionHandlerInterface; |
33
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundOrderTransactionHandler; |
34
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundOrderTransactionHandlerInterface; |
35
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundTransactionHandler; |
|
|
|
|
36
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundTransactionHandlerInterface; |
|
|
|
|
37
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RevertTransactionHandler; |
38
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RevertTransactionHandlerInterface; |
39
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentRefundTransactionHandler; |
40
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentRefundTransactionHandlerInterface; |
41
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentTransactionHandler; |
42
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentTransactionHandlerInterface; |
43
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\PaymentTransactionMetaVisitor; |
44
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\TransactionMetaVisitorComposite; |
45
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\TransactionMetaVisitorInterface; |
46
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\PreCheckTransaction; |
47
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\RefundItemsTransaction; |
48
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\RefundOrderTransaction; |
49
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\RefundTransaction; |
|
|
|
|
50
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\RevertTransaction; |
51
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\ShipmentRefundTransaction; |
52
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\ShipmentTransaction; |
53
|
|
|
use SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface; |
54
|
|
|
use SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToMoneyFacadeInterface; |
55
|
|
|
use SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToRefundFacadeInterface; |
56
|
|
|
use SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToSalesFacadeInterface; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @method \SprykerEco\Zed\Braintree\Persistence\BraintreeQueryContainerInterface getQueryContainer() |
60
|
|
|
* @method \SprykerEco\Zed\Braintree\BraintreeConfig getConfig() |
61
|
|
|
* @method \SprykerEco\Zed\Braintree\Persistence\BraintreeRepositoryInterface getRepository() |
62
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
63
|
|
|
* @method \SprykerEco\Zed\Braintree\Persistence\BraintreeEntityManagerInterface getEntityManager() |
64
|
|
|
*/ |
65
|
|
|
class BraintreeBusinessFactory extends AbstractBusinessFactory |
66
|
|
|
{ |
67
|
|
|
/** |
68
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\AuthorizeTransactionHandlerInterface |
69
|
|
|
*/ |
70
|
|
|
public function createAuthorizeTransactionHandler(): AuthorizeTransactionHandlerInterface |
71
|
|
|
{ |
72
|
|
|
return new AuthorizeTransactionHandler( |
73
|
|
|
$this->createAuthorizeTransaction(), |
74
|
|
|
$this->createDefaultTransactionMetaVisitor() |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureItemsTransactionHandlerInterface |
80
|
|
|
*/ |
81
|
|
|
public function createCaptureItemsTransactionHandler(): CaptureItemsTransactionHandlerInterface |
82
|
|
|
{ |
83
|
|
|
return new CaptureItemsTransactionHandler( |
84
|
|
|
$this->createCaptureItemsTransaction(), |
85
|
|
|
$this->createDefaultTransactionMetaVisitor() |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\CaptureOrderTransactionHandlerInterface |
91
|
|
|
*/ |
92
|
|
|
public function createCaptureOrderTransactionHandler(): CaptureOrderTransactionHandlerInterface |
93
|
|
|
{ |
94
|
|
|
return new CaptureOrderTransactionHandler( |
95
|
|
|
$this->createCaptureOrderTransaction(), |
96
|
|
|
$this->createDefaultTransactionMetaVisitor() |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\PreCheckTransactionHandlerInterface |
102
|
|
|
*/ |
103
|
|
|
public function createPreCheckTransactionHandler(): PreCheckTransactionHandlerInterface |
104
|
|
|
{ |
105
|
|
|
return new PreCheckTransactionHandler( |
106
|
|
|
$this->createPreCheckTransaction(), |
107
|
|
|
$this->createDefaultTransactionMetaVisitor() |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundOrderTransactionHandlerInterface |
113
|
|
|
*/ |
114
|
|
|
public function createRefundOrderTransactionHandler(): RefundOrderTransactionHandlerInterface |
115
|
|
|
{ |
116
|
|
|
return new RefundOrderTransactionHandler( |
117
|
|
|
$this->createRefundOrderTransaction(), |
118
|
|
|
$this->createDefaultTransactionMetaVisitor(), |
119
|
|
|
$this->getRefundFacade() |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RefundItemsTransactionHandlerInterface |
125
|
|
|
*/ |
126
|
|
|
public function createRefundItemsTransactionHandler(): RefundItemsTransactionHandlerInterface |
127
|
|
|
{ |
128
|
|
|
return new RefundItemsTransactionHandler( |
129
|
|
|
$this->createRefundItemsTransaction(), |
130
|
|
|
$this->createDefaultTransactionMetaVisitor(), |
131
|
|
|
$this->getRefundFacade(), |
132
|
|
|
$this->getRepository() |
133
|
|
|
); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\RevertTransactionHandlerInterface |
138
|
|
|
*/ |
139
|
|
|
public function createRevertTransactionHandler(): RevertTransactionHandlerInterface |
140
|
|
|
{ |
141
|
|
|
return new RevertTransactionHandler( |
142
|
|
|
$this->createRevertTransaction(), |
143
|
|
|
$this->createDefaultTransactionMetaVisitor() |
144
|
|
|
); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Order\SaverInterface |
149
|
|
|
*/ |
150
|
|
|
public function createOrderSaver(): SaverInterface |
151
|
|
|
{ |
152
|
|
|
return new Saver(); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Log\TransactionStatusLogInterface |
157
|
|
|
*/ |
158
|
|
|
public function createTransactionStatusLog(): TransactionStatusLogInterface |
159
|
|
|
{ |
160
|
|
|
return new TransactionStatusLog($this->getRepository()); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Hook\PostSaveHookInterface |
165
|
|
|
*/ |
166
|
|
|
public function createPostSaveHook(): PostSaveHookInterface |
167
|
|
|
{ |
168
|
|
|
return new PostSaveHook($this->getRepository()); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
173
|
|
|
*/ |
174
|
|
|
public function createAuthorizeTransaction(): TransactionInterface |
175
|
|
|
{ |
176
|
|
|
return new AuthorizeTransaction($this->getConfig()); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\TransactionMetaVisitorInterface |
181
|
|
|
*/ |
182
|
|
|
public function createDefaultTransactionMetaVisitor(): TransactionMetaVisitorInterface |
183
|
|
|
{ |
184
|
|
|
$transactionMetaVisitorComposite = $this->createTransactionMetaVisitorComposite(); |
185
|
|
|
$transactionMetaVisitorComposite->addVisitor($this->createPaymentTransactionMetaVisitor()); |
186
|
|
|
|
187
|
|
|
return $transactionMetaVisitorComposite; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\TransactionMetaVisitorInterface |
192
|
|
|
*/ |
193
|
|
|
public function createTransactionMetaVisitorComposite(): TransactionMetaVisitorInterface |
194
|
|
|
{ |
195
|
|
|
return new TransactionMetaVisitorComposite(); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\MetaVisitor\TransactionMetaVisitorInterface |
200
|
|
|
*/ |
201
|
|
|
public function createPaymentTransactionMetaVisitor(): TransactionMetaVisitorInterface |
202
|
|
|
{ |
203
|
|
|
return new PaymentTransactionMetaVisitor($this->getRepository()); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
208
|
|
|
*/ |
209
|
|
|
public function createCaptureOrderTransaction(): TransactionInterface |
210
|
|
|
{ |
211
|
|
|
return new CaptureOrderTransaction($this->getConfig()); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
216
|
|
|
*/ |
217
|
|
|
public function createCaptureItemsTransaction(): TransactionInterface |
218
|
|
|
{ |
219
|
|
|
return new CaptureItemsTransaction( |
220
|
|
|
$this->getConfig(), |
221
|
|
|
$this->getMoneyFacade(), |
222
|
|
|
$this->getRepository(), |
223
|
|
|
$this->getEntityManager(), |
224
|
|
|
$this->getSalesFacade(), |
225
|
|
|
$this->createShipmentTransactionHandler() |
226
|
|
|
); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
231
|
|
|
*/ |
232
|
|
|
public function createShipmentTransaction(): TransactionInterface |
233
|
|
|
{ |
234
|
|
|
return new ShipmentTransaction( |
235
|
|
|
$this->getConfig(), |
236
|
|
|
$this->getEntityManager() |
237
|
|
|
); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
242
|
|
|
*/ |
243
|
|
|
public function createShipmentRefundTransaction(): TransactionInterface |
244
|
|
|
{ |
245
|
|
|
return new ShipmentRefundTransaction( |
246
|
|
|
$this->getConfig(), |
247
|
|
|
$this->getEntityManager() |
248
|
|
|
); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentTransactionHandlerInterface |
253
|
|
|
*/ |
254
|
|
|
public function createShipmentTransactionHandler(): ShipmentTransactionHandlerInterface |
255
|
|
|
{ |
256
|
|
|
return new ShipmentTransactionHandler( |
257
|
|
|
$this->createShipmentTransaction(), |
258
|
|
|
$this->createDefaultTransactionMetaVisitor() |
259
|
|
|
); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\Handler\ShipmentRefundTransactionHandlerInterface |
264
|
|
|
*/ |
265
|
|
|
public function createShipmentRefundTransactionHandler(): ShipmentRefundTransactionHandlerInterface |
266
|
|
|
{ |
267
|
|
|
return new ShipmentRefundTransactionHandler( |
268
|
|
|
$this->createShipmentRefundTransaction(), |
269
|
|
|
$this->createDefaultTransactionMetaVisitor() |
270
|
|
|
); |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
275
|
|
|
*/ |
276
|
|
|
public function createPreCheckTransaction(): TransactionInterface |
277
|
|
|
{ |
278
|
|
|
return new PreCheckTransaction($this->getConfig(), $this->getMoneyFacade()); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* @return \SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToMoneyFacadeInterface |
283
|
|
|
*/ |
284
|
|
|
public function getMoneyFacade(): BraintreeToMoneyFacadeInterface |
285
|
|
|
{ |
286
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::FACADE_MONEY); |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
291
|
|
|
*/ |
292
|
|
|
public function createRefundOrderTransaction(): TransactionInterface |
293
|
|
|
{ |
294
|
|
|
return new RefundOrderTransaction( |
295
|
|
|
$this->getConfig(), |
296
|
|
|
$this->getMoneyFacade(), |
297
|
|
|
$this->createShipmentRefundTransactionHandler(), |
298
|
|
|
$this->getRepository() |
299
|
|
|
); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
304
|
|
|
*/ |
305
|
|
|
public function createRefundItemsTransaction(): TransactionInterface |
306
|
|
|
{ |
307
|
|
|
return new RefundItemsTransaction( |
308
|
|
|
$this->getConfig(), |
309
|
|
|
$this->getMoneyFacade(), |
310
|
|
|
$this->createShipmentRefundTransactionHandler(), |
311
|
|
|
$this->getRepository() |
312
|
|
|
); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Transaction\TransactionInterface |
317
|
|
|
*/ |
318
|
|
|
public function createRevertTransaction(): TransactionInterface |
319
|
|
|
{ |
320
|
|
|
return new RevertTransaction($this->getConfig()); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @return \SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToRefundFacadeInterface |
325
|
|
|
*/ |
326
|
|
|
public function getRefundFacade(): BraintreeToRefundFacadeInterface |
327
|
|
|
{ |
328
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::FACADE_REFUND); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @return \SprykerEco\Zed\Braintree\Business\Payment\Filter\PaypalExpressPaymentMethodFilterInterface |
333
|
|
|
*/ |
334
|
|
|
public function createPaypalExpressCheckoutPaymentMethod(): PaypalExpressPaymentMethodFilterInterface |
335
|
|
|
{ |
336
|
|
|
return new PaypalExpressPaymentMethodFilter(); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @return \SprykerEco\Zed\Braintree\Dependency\Facade\BraintreeToSalesFacadeInterface |
341
|
|
|
*/ |
342
|
|
|
public function getSalesFacade(): BraintreeToSalesFacadeInterface |
343
|
|
|
{ |
344
|
|
|
return $this->getProvidedDependency(BraintreeDependencyProvider::FACADE_SALES); |
345
|
|
|
} |
346
|
|
|
} |
347
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths