Completed
Pull Request — master (#25)
by Andrey
11:08 queued 03:02
created

AmazonPayFacade::placeOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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 Generated\Shared\Transfer\AmazonpayCallTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\AmazonpayCallTransfer 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\AmazonpayIpnPaymentRequestTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...nPaymentRequestTransfer 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 Generated\Shared\Transfer\CheckoutResponseTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\CheckoutResponseTransfer 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...
13
use Generated\Shared\Transfer\OrderTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer 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...
14
use Generated\Shared\Transfer\QuoteTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
15
use Generated\Shared\Transfer\SaveOrderTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfer\SaveOrderTransfer 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...
16
use Spryker\Zed\Kernel\Business\AbstractFacade;
17
18
/**
19
 * @api
20
 *
21
 * @method \SprykerEco\Zed\AmazonPay\Business\AmazonPayBusinessFactory getFactory()
22
 */
23
class AmazonPayFacade extends AbstractFacade implements AmazonPayFacadeInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     *
28
     * @api
29
     *
30
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
31
     *
32
     * @return \Generated\Shared\Transfer\QuoteTransfer
33
     */
34
    public function handleCartWithAmazonPay(QuoteTransfer $quoteTransfer)
35
    {
36
        return $this->getFactory()
37
            ->createQuoteUpdateFactory()
38
            ->createQuoteUpdaterCollection()
39
            ->update($quoteTransfer);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     *
45
     * @api
46
     *
47
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
48
     *
49
     * @return \Generated\Shared\Transfer\QuoteTransfer
50
     */
51
    public function addSelectedAddressToQuote(QuoteTransfer $quoteTransfer)
52
    {
53
        return $this->getFactory()
54
            ->createQuoteUpdateFactory()
55
            ->createShippingAddressQuoteDataUpdater()
56
            ->update($quoteTransfer);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     *
62
     * @api
63
     *
64
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
65
     *
66
     * @return \Generated\Shared\Transfer\QuoteTransfer
67
     */
68
    public function addSelectedShipmentMethodToQuote(QuoteTransfer $quoteTransfer)
69
    {
70
        return $this->getFactory()
71
            ->createQuoteUpdateFactory()
72
            ->createShipmentDataQuoteUpdater()
73
            ->update($quoteTransfer);
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     *
79
     * @api
80
     *
81
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
82
     *
83
     * @return \Generated\Shared\Transfer\QuoteTransfer
84
     */
85
    public function confirmPurchase(QuoteTransfer $quoteTransfer)
86
    {
87
        return $this->getFactory()
88
            ->createTransactionFactory()
89
            ->createConfirmPurchaseTransaction()
90
            ->execute($quoteTransfer);
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     *
96
     * @api
97
     *
98
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
99
     *
100
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
101
     */
102
    public function captureOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
103
    {
104
        return $this->getFactory()
105
            ->createTransactionFactory()
106
            ->createCaptureAuthorizedTransaction()
107
            ->execute($amazonpayCallTransfer);
108
    }
109
110
    /**
111
     * {@inheritdoc}
112
     *
113
     * @api
114
     *
115
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
116
     *
117
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
118
     */
119
    public function cancelOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
120
    {
121
        return $this->getFactory()
122
            ->createTransactionFactory()
123
            ->createCancelOrderTransactionSequence()
124
            ->execute($amazonpayCallTransfer);
125
    }
126
127
    /**
128
     * {@inheritdoc}
129
     *
130
     * @api
131
     *
132
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
133
     *
134
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
135
     */
136
    public function closeOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
137
    {
138
        return $this->getFactory()
139
            ->createTransactionFactory()
140
            ->createCloseCapturedOrderTransaction()
141
            ->execute($amazonpayCallTransfer);
142
    }
143
144
    /**
145
     * {@inheritdoc}
146
     *
147
     * @api
148
     *
149
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
150
     *
151
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
152
     */
153
    public function refundOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
154
    {
155
        return $this->getFactory()
156
            ->createTransactionFactory()
157
            ->createRefundOrderTransaction()
158
            ->execute($amazonpayCallTransfer);
159
    }
160
161
    /**
162
     * {@inheritdoc}
163
     *
164
     * @api
165
     *
166
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
167
     *
168
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
169
     */
170
    public function reauthorizeExpiredOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
171
    {
172
        return $this->getFactory()
173
            ->createTransactionFactory()
174
            ->createReauthorizeExpiredOrderTransaction()
175
            ->execute($amazonpayCallTransfer);
176
    }
177
178
    /**
179
     * {@inheritdoc}
180
     *
181
     * @api
182
     *
183
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
184
     *
185
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
186
     */
187
    public function authorizeOrderItems(AmazonpayCallTransfer $amazonpayCallTransfer)
188
    {
189
        return $this->getFactory()
190
            ->createTransactionFactory()
191
            ->createAuthorizeTransaction()
192
            ->execute($amazonpayCallTransfer);
193
    }
194
195
    /**
196
     * {@inheritdoc}
197
     *
198
     * @api
199
     *
200
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
201
     *
202
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
203
     */
204
    public function reauthorizeSuspendedOrder(AmazonpayCallTransfer $amazonpayCallTransfer)
205
    {
206
        return $this->getFactory()
207
            ->createTransactionFactory()
208
            ->createReauthorizeOrderTransaction()
209
            ->execute($amazonpayCallTransfer);
210
    }
211
212
    /**
213
     * @api
214
     *
215
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
216
     *
217
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
218
     */
219
    public function updateAuthorizationStatus(AmazonpayCallTransfer $amazonpayCallTransfer)
220
    {
221
        return $this->getFactory()
222
            ->createTransactionFactory()
223
            ->createUpdateOrderAuthorizationStatusTransaction()
224
            ->execute($amazonpayCallTransfer);
225
    }
226
227
    /**
228
     * {@inheritdoc}
229
     *
230
     * @api
231
     *
232
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
233
     *
234
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
235
     */
236
    public function updateCaptureStatus(AmazonpayCallTransfer $amazonpayCallTransfer)
237
    {
238
        return $this->getFactory()
239
            ->createTransactionFactory()
240
            ->createUpdateOrderCaptureStatusHandler()
241
            ->execute($amazonpayCallTransfer);
242
    }
243
244
    /**
245
     * {@inheritdoc}
246
     *
247
     * @api
248
     *
249
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
250
     *
251
     * @return \Generated\Shared\Transfer\AmazonpayCallTransfer
252
     */
253
    public function updateRefundStatus(AmazonpayCallTransfer $amazonpayCallTransfer)
254
    {
255
        return $this->getFactory()
256
            ->createTransactionFactory()
257
            ->createUpdateOrderRefundStatusTransaction()
258
            ->execute($amazonpayCallTransfer);
259
    }
260
261
    /**
262
     * {@inheritdoc}
263
     *
264
     * @api
265
     *
266
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
267
     * @param \Generated\Shared\Transfer\SaveOrderTransfer $saveOrderTransfer
268
     *
269
     * @return void
270
     */
271
    public function saveOrderPayment(
272
        QuoteTransfer $quoteTransfer,
273
        SaveOrderTransfer $saveOrderTransfer
274
    ) {
275
        $this->getFactory()
276
            ->createOrderSaver()
277
            ->saveOrderPayment($quoteTransfer, $saveOrderTransfer);
278
    }
279
280
    /**
281
     * {@inheritdoc}
282
     *
283
     * @api
284
     *
285
     * @param array $headers
286
     * @param string $body
287
     *
288
     * @return \Generated\Shared\Transfer\AmazonpayIpnPaymentRequestTransfer
289
     */
290
    public function convertAmazonPayIpnRequest(array $headers, $body)
291
    {
292
        return $this->getFactory()
293
            ->createAdapterFactory()
294
            ->createIpnRequestAdapter($headers, $body)
295
            ->getIpnRequest($body);
296
    }
297
298
    /**
299
     * {@inheritdoc}
300
     *
301
     * @api
302
     *
303
     * @param \Generated\Shared\Transfer\AmazonpayIpnPaymentRequestTransfer $ipnRequestTransfer
304
     *
305
     * @return void
306
     */
307
    public function handleAmazonPayIpnRequest(AmazonpayIpnPaymentRequestTransfer $ipnRequestTransfer)
308
    {
309
        $this->getFactory()
310
            ->createIpnFactory()
311
            ->createIpnRequestFactory()
312
            ->getConcreteIpnRequestHandler($ipnRequestTransfer)
313
            ->handle($ipnRequestTransfer);
314
    }
315
316
    /**
317
     * {@inheritdoc}
318
     *
319
     * @api
320
     *
321
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
322
     *
323
     * @return \Generated\Shared\Transfer\OrderTransfer
324
     */
325
    public function hydrateOrderInfo(OrderTransfer $orderTransfer)
326
    {
327
        return $this->getFactory()
328
            ->createAmazonpayOrderInfoHydrator()
329
            ->hydrateOrderInfo($orderTransfer);
330
    }
331
332
    /**
333
     * {@inheritdoc}
334
     *
335
     * @api
336
     *
337
     * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer
338
     * @param int[] $alreadyAffectedItems
339
     * @param string $eventName
340
     *
341
     * @return void
342
     */
343
    public function triggerEventForRelatedItems(AmazonpayCallTransfer $amazonpayCallTransfer, array $alreadyAffectedItems, $eventName)
344
    {
345
        $this->getFactory()
346
            ->createRelatedItemsUpdateModel()
347
            ->triggerEvent($amazonpayCallTransfer, $alreadyAffectedItems, $eventName);
348
    }
349
350
    /**
351
     * {@inheritdoc}
352
     *
353
     * @api
354
     *
355
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
356
     * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
357
     *
358
     * @return bool
359
     */
360
    public function placeOrder(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer)
361
    {
362
        return $this->getFactory()
363
            ->createPlacement()
364
            ->placeOrder($quoteTransfer, $checkoutResponseTransfer);
365
    }
366
}
367