Passed
Pull Request — master (#23)
by
unknown
10:09 queued 03:56
created

AfterPayFacade::authorizePaymentForQuote()   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 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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\AfterPay\Business;
9
10
use Generated\Shared\Transfer\AfterPayApiResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rPayApiResponseTransfer 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\AfterPayAvailablePaymentMethodsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ePaymentMethodsTransfer 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\AfterPayCallTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AfterPayCallTransfer 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\AfterPayCustomerLookupRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...erLookupRequestTransfer 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\AfterPayCustomerLookupResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...rLookupResponseTransfer 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\AfterPayInstallmentPlansRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...entPlansRequestTransfer 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 Generated\Shared\Transfer\AfterPayInstallmentPlansResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ntPlansResponseTransfer 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...
17
use Generated\Shared\Transfer\AfterPayPaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\AfterPayPaymentTransfer 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...
18
use Generated\Shared\Transfer\AfterPayValidateBankAccountRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...kAccountRequestTransfer 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...
19
use Generated\Shared\Transfer\AfterPayValidateBankAccountResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...AccountResponseTransfer 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...
20
use Generated\Shared\Transfer\AfterPayValidateCustomerRequestTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...CustomerRequestTransfer 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...
21
use Generated\Shared\Transfer\AfterPayValidateCustomerResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ustomerResponseTransfer 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...
22
use Generated\Shared\Transfer\CheckoutResponseTransfer;
0 ignored issues
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...
23
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
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...
24
use Generated\Shared\Transfer\PaymentMethodsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentMethodsTransfer 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...
25
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
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...
26
use Generated\Shared\Transfer\SaveOrderTransfer;
0 ignored issues
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...
27
use Spryker\Zed\Kernel\Business\AbstractFacade;
28
use SprykerEco\Shared\AfterPay\AfterPayConfig as SharedAfterPayConfig;
29
use SprykerEco\Zed\AfterPay\Communication\Converter\QuoteToCallConverter;
30
31
/**
32
 * @method \SprykerEco\Zed\AfterPay\Business\AfterPayBusinessFactory getFactory()
33
 * @method \SprykerEco\Zed\AfterPay\Persistence\AfterPayEntityManagerInterface getEntityManager()
34
 */
35
class AfterPayFacade extends AbstractFacade implements AfterPayFacadeInterface
36
{
37
    /**
38
     * {@inheritDoc}
39
     *
40
     * @api
41
     *
42
     * @param \Generated\Shared\Transfer\PaymentMethodsTransfer $paymentMethodsTransfer
43
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
44
     *
45
     * @return \Generated\Shared\Transfer\PaymentMethodsTransfer
46
     */
47
    public function filterPaymentMethods(
48
        PaymentMethodsTransfer $paymentMethodsTransfer,
49
        QuoteTransfer $quoteTransfer
50
    ): PaymentMethodsTransfer {
51
        return $this->getFactory()
52
            ->createPaymentMethodsFilter()
53
            ->filterPaymentMethods($paymentMethodsTransfer, $quoteTransfer);
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     *
59
     * @api
60
     *
61
     * @param \Generated\Shared\Transfer\AfterPayValidateCustomerRequestTransfer $validateCustomerRequestTransfer
62
     *
63
     * @return \Generated\Shared\Transfer\AfterPayValidateCustomerResponseTransfer
64
     */
65
    public function validateCustomerAddress(AfterPayValidateCustomerRequestTransfer $validateCustomerRequestTransfer): AfterPayValidateCustomerResponseTransfer
66
    {
67
        return $this->getFactory()
68
            ->createValidateCustomerHandler()
69
            ->validateCustomer($validateCustomerRequestTransfer);
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     *
75
     * @api
76
     *
77
     * @param \Generated\Shared\Transfer\AfterPayValidateBankAccountRequestTransfer $validateBankAccountRequestTransfer
78
     *
79
     * @return \Generated\Shared\Transfer\AfterPayValidateBankAccountResponseTransfer
80
     */
81
    public function validateBankAccount(
82
        AfterPayValidateBankAccountRequestTransfer $validateBankAccountRequestTransfer
83
    ): AfterPayValidateBankAccountResponseTransfer {
84
        return $this->getFactory()
85
            ->createValidateBankAccountHandler()
86
            ->validateBankAccount($validateBankAccountRequestTransfer);
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     *
92
     * @api
93
     *
94
     * @param \Generated\Shared\Transfer\AfterPayCustomerLookupRequestTransfer $customerLookupRequestTransfer
95
     *
96
     * @return \Generated\Shared\Transfer\AfterPayCustomerLookupResponseTransfer
97
     */
98
    public function lookupCustomer(AfterPayCustomerLookupRequestTransfer $customerLookupRequestTransfer): AfterPayCustomerLookupResponseTransfer
99
    {
100
        return $this->getFactory()
101
            ->createLookupCustomerHandler()
102
            ->lookupCustomer($customerLookupRequestTransfer);
103
    }
104
105
    /**
106
     * {@inheritDoc}
107
     *
108
     * @api
109
     *
110
     * @param \Generated\Shared\Transfer\AfterPayInstallmentPlansRequestTransfer $installmentPlansRequestTransfer
111
     *
112
     * @return \Generated\Shared\Transfer\AfterPayInstallmentPlansResponseTransfer
113
     */
114
    public function lookupInstallmentPlans(AfterPayInstallmentPlansRequestTransfer $installmentPlansRequestTransfer): AfterPayInstallmentPlansResponseTransfer
115
    {
116
        return $this->getFactory()
117
            ->createLookupInstallmentPlansHandler()
118
            ->lookupInstallmentPlans($installmentPlansRequestTransfer);
119
    }
120
121
    /**
122
     * {@inheritDoc}
123
     *
124
     * @api
125
     *
126
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
127
     * @param \Generated\Shared\Transfer\SaveOrderTransfer $saveOrderTransfer
128
     *
129
     * @return void
130
     */
131
    public function saveOrderPayment(QuoteTransfer $quoteTransfer, SaveOrderTransfer $saveOrderTransfer): void
132
    {
133
        $this->getFactory()
134
            ->createOrderSaver()
135
            ->saveOrderPayment($quoteTransfer, $saveOrderTransfer);
136
    }
137
138
    /**
139
     * {@inheritDoc}
140
     *
141
     * @api
142
     *
143
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
144
     * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
145
     *
146
     * @return \Generated\Shared\Transfer\CheckoutResponseTransfer
147
     */
148
    public function postSaveHook(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer): CheckoutResponseTransfer
149
    {
150
        return $this->getFactory()
151
            ->createPostSaveHook()
152
            ->execute($quoteTransfer, $checkoutResponseTransfer);
153
    }
154
155
    /**
156
     * {@inheritDoc}
157
     *
158
     * @api
159
     *
160
     * @param \Generated\Shared\Transfer\AfterPayCallTransfer $afterPayCallTransfer
161
     *
162
     * @return \Generated\Shared\Transfer\AfterPayApiResponseTransfer
163
     */
164
    public function authorizePayment(AfterPayCallTransfer $afterPayCallTransfer): AfterPayApiResponseTransfer
165
    {
166
        return $this->getFactory()
167
            ->createAuthorizeTransactionHandler()
168
            ->authorize($afterPayCallTransfer);
169
    }
170
171
    /**
172
     * {@inheritDoc}
173
     *
174
     * @api
175
     *
176
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
177
     *
178
     * @return void
179
     */
180
    public function authorizePaymentForQuote(QuoteTransfer $quoteTransfer): void
181
    {
182
        $this->getFactory()
183
            ->createAuthorizeTransactionHandler()
184
            ->authorizeForQuote($quoteTransfer);
185
    }
186
187
    /**
188
     * {@inheritDoc}
189
     *
190
     * @api
191
     *
192
     * @param \Generated\Shared\Transfer\ItemTransfer[] $items
193
     * @param \Generated\Shared\Transfer\AfterPayCallTransfer $afterPayCallTransfer
194
     *
195
     * @return void
196
     */
197
    public function capturePayment(array $items, AfterPayCallTransfer $afterPayCallTransfer): void
198
    {
199
        $this->getFactory()
200
            ->createCaptureTransactionHandler()
201
            ->capture($items, $afterPayCallTransfer);
202
    }
203
204
    /**
205
     * {@inheritDoc}
206
     *
207
     * @api
208
     *
209
     * @param \Generated\Shared\Transfer\ItemTransfer[] $items
210
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
211
     *
212
     * @return void
213
     */
214
    public function refundPayment(array $items, OrderTransfer $orderTransfer): void
215
    {
216
        $this->getFactory()
217
            ->createRefundTransactionHandler()
218
            ->refund($items, $orderTransfer);
219
    }
220
221
    /**
222
     * {@inheritDoc}
223
     *
224
     * @api
225
     *
226
     * @param \Generated\Shared\Transfer\ItemTransfer[] $items
227
     * @param \Generated\Shared\Transfer\AfterPayCallTransfer $afterPayCallTransfer
228
     *
229
     * @return void
230
     */
231
    public function cancelPayment(array $items, AfterPayCallTransfer $afterPayCallTransfer): void
232
    {
233
        $this->getFactory()
234
            ->createCancelTransactionHandler()
235
            ->cancel($items, $afterPayCallTransfer);
236
    }
237
238
    /**
239
     * {@inheritDoc}
240
     *
241
     * @api
242
     *
243
     * @param int $idSalesOrder
244
     *
245
     * @return \Generated\Shared\Transfer\AfterPayPaymentTransfer
246
     */
247
    public function getPaymentByIdSalesOrder(int $idSalesOrder): AfterPayPaymentTransfer
248
    {
249
        return $this->getFactory()
250
            ->createPaymentReader()
251
            ->getPaymentByIdSalesOrder($idSalesOrder);
252
    }
253
254
    /**
255
     * {@inheritDoc}
256
     *
257
     * @api
258
     *
259
     * @return string
260
     */
261
    public function getApiVersion(): string
262
    {
263
        return $this->getFactory()
264
            ->createApiAdapter()
265
            ->getApiVersion();
266
    }
267
268
    /**
269
     * {@inheritDoc}
270
     *
271
     * @api
272
     *
273
     * @return int
274
     */
275
    public function getApiStatus(): int
276
    {
277
        return $this->getFactory()
278
            ->createApiAdapter()
279
            ->getApiStatus();
280
    }
281
282
    /**
283
     * {@inheritDoc}
284
     *
285
     * @api
286
     *
287
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
288
     *
289
     * @return \Generated\Shared\Transfer\AfterPayAvailablePaymentMethodsTransfer
290
     */
291
    public function getAvailablePaymentMethods(QuoteTransfer $quoteTransfer): AfterPayAvailablePaymentMethodsTransfer
292
    {
293
        return $this->getFactory()
294
            ->createPaymentMethodsProvider()
295
            ->getAvailablePaymentMethods($quoteTransfer);
296
    }
297
}
298