Completed
Push — feature/ECO-1185-eco-ci ( 4da4ac...5d4add )
by Andrey
13:41 queued 10:25
created

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