@akinon/next 1.15.0 → 1.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,516 +1,516 @@
1
- import {
2
- setBankAccounts,
3
- setInstallmentOptions,
4
- setPaymentStepBusy,
5
- setSelectedBankAccountPk,
6
- setSelectedCreditPaymentPk,
7
- setShippingStepBusy
8
- } from '../../redux/reducers/checkout';
9
- import {
10
- CheckoutContext,
11
- GuestLoginFormParams,
12
- Order,
13
- PreOrder
14
- } from '../../types';
15
- import { buildClientRequestUrl } from '../../utils';
16
- import { api } from './api';
17
- import { checkout } from '../urls';
18
- import { store } from 'redux/store';
19
-
20
- interface CheckoutResponse {
21
- pre_order?: PreOrder;
22
- errors: {
23
- non_field_errors: string;
24
- };
25
- context_list?: CheckoutContext[];
26
- template_name?: string;
27
- redirect_url?: string;
28
- }
29
-
30
- interface SetAddressesParams {
31
- shippingAddressPk: number;
32
- billingAddressPk: number;
33
- }
34
-
35
- interface SetRetailStoreParams {
36
- retailStorePk: number;
37
- billingAddressPk: number;
38
- }
39
-
40
- interface CompleteCreditCardParams {
41
- card_holder: string;
42
- card_cvv: string;
43
- card_number: string;
44
- card_month: string;
45
- card_year: string;
46
- use_three_d?: boolean;
47
- }
48
-
49
- interface GetContractResponse {
50
- result: string;
51
- }
52
-
53
- interface ApplePaySelectParams {
54
- agreement: boolean;
55
- validationURL: string;
56
- }
57
-
58
- interface ApplePayQueryParams {
59
- agreement: boolean;
60
- paymentToken: string;
61
- }
62
-
63
- export interface PayOnDeliveryParams {
64
- agreement: string;
65
- paymentType: string;
66
- }
67
-
68
- export const checkoutApi = api.injectEndpoints({
69
- endpoints: (build) => ({
70
- fetchCheckout: build.query<CheckoutResponse, void>({
71
- query: () => ({
72
- url: buildClientRequestUrl(checkout.fetchCheckout, {})
73
- }),
74
- providesTags: ['Checkout']
75
- }),
76
- fetchCheckoutResult: build.query<{ order: Order }, string>({
77
- query: (token: string) =>
78
- buildClientRequestUrl(checkout.fetchCheckoutResult(token))
79
- }),
80
- get3dRedirectForm: build.query<{ result: string }, void>({
81
- query: () =>
82
- buildClientRequestUrl(checkout.get3dRedirectForm, {
83
- responseType: 'text'
84
- })
85
- }),
86
- getContract: build.query<GetContractResponse, string>({
87
- query: (slug: string) =>
88
- buildClientRequestUrl(checkout.getContract(slug), {
89
- responseType: 'text'
90
- })
91
- }),
92
- completeCreditCardPayment: build.mutation<
93
- CheckoutResponse,
94
- CompleteCreditCardParams
95
- >({
96
- query: ({
97
- card_holder,
98
- card_cvv,
99
- card_number,
100
- card_month,
101
- card_year,
102
- use_three_d = true
103
- }) => ({
104
- url: buildClientRequestUrl(checkout.completeCreditCardPayment, {
105
- useFormData: true
106
- }),
107
- method: 'POST',
108
- body: {
109
- agreement: '1',
110
- use_three_d: use_three_d ? '1' : '0',
111
- card_cvv,
112
- card_holder,
113
- card_month,
114
- card_number,
115
- card_year
116
- }
117
- }),
118
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
119
- dispatch(setPaymentStepBusy(true));
120
- await queryFulfilled;
121
- dispatch(setPaymentStepBusy(false));
122
- },
123
- invalidatesTags: ['Basket']
124
- }),
125
- completeFundsTransfer: build.mutation<CheckoutResponse, void>({
126
- query: () => ({
127
- url: buildClientRequestUrl(checkout.completeFundsTransfer, {
128
- useFormData: true
129
- }),
130
- method: 'POST',
131
- body: {
132
- agreement: '1'
133
- }
134
- }),
135
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
136
- dispatch(setPaymentStepBusy(true));
137
- await queryFulfilled;
138
- dispatch(setPaymentStepBusy(false));
139
- },
140
- invalidatesTags: ['Basket']
141
- }),
142
- guestLogin: build.mutation<CheckoutResponse, GuestLoginFormParams>({
143
- query: ({ user_email, phone_number }) => ({
144
- url: buildClientRequestUrl(checkout.guestLogin, {
145
- useFormData: true
146
- }),
147
- method: 'POST',
148
- body: {
149
- user_email,
150
- phone_number
151
- }
152
- }),
153
- invalidatesTags: ['Checkout']
154
- }),
155
- setDeliveryOption: build.mutation<CheckoutResponse, number>({
156
- query: (pk: number) => ({
157
- url: buildClientRequestUrl(checkout.setDeliveryOption, {
158
- useFormData: true
159
- }),
160
- method: 'POST',
161
- body: {
162
- delivery_option: String(pk)
163
- }
164
- }),
165
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
166
- dispatch(setShippingStepBusy(true));
167
- await queryFulfilled;
168
- dispatch(setShippingStepBusy(false));
169
- }
170
- }),
171
- setAddresses: build.mutation<CheckoutResponse, SetAddressesParams>({
172
- query: ({ shippingAddressPk, billingAddressPk }) => ({
173
- url: buildClientRequestUrl(checkout.setAddresses, {
174
- useFormData: true
175
- }),
176
- method: 'POST',
177
- body: {
178
- shipping_address: String(shippingAddressPk),
179
- billing_address: String(billingAddressPk)
180
- }
181
- }),
182
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
183
- dispatch(setShippingStepBusy(true));
184
- await queryFulfilled;
185
- dispatch(setShippingStepBusy(false));
186
- }
187
- }),
188
- setShippingOption: build.mutation<CheckoutResponse, number>({
189
- query: (pk: number) => ({
190
- url: buildClientRequestUrl(checkout.setShippingOption, {
191
- useFormData: true
192
- }),
193
- method: 'POST',
194
- body: {
195
- shipping_option: String(pk)
196
- }
197
- }),
198
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
199
- dispatch(setShippingStepBusy(true));
200
- await queryFulfilled;
201
- dispatch(setShippingStepBusy(false));
202
- }
203
- }),
204
- setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
205
- query: ({ retailStorePk, billingAddressPk }) => ({
206
- url: buildClientRequestUrl(
207
- '/orders/checkout?page=RetailStoreSelectionPage',
208
- {
209
- useFormData: true
210
- }
211
- ),
212
- method: 'POST',
213
- body: {
214
- retail_store: Number(retailStorePk),
215
- billing_address: Number(billingAddressPk)
216
- }
217
- })
218
- }),
219
- setPaymentOption: build.mutation<CheckoutResponse, number>({
220
- query: (pk: number) => ({
221
- url: buildClientRequestUrl(checkout.setPaymentOption, {
222
- useFormData: true
223
- }),
224
- method: 'POST',
225
- body: {
226
- payment_option: String(pk)
227
- }
228
- }),
229
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
230
- dispatch(setPaymentStepBusy(true));
231
- dispatch(setInstallmentOptions([]));
232
- dispatch(setBankAccounts([]));
233
- dispatch(setSelectedBankAccountPk(null));
234
- await queryFulfilled;
235
- dispatch(setPaymentStepBusy(false));
236
- }
237
- }),
238
- setBinNumber: build.mutation<CheckoutResponse, string>({
239
- query: (binNumber: string) => {
240
- const paymentOption =
241
- store.getState().checkout?.preOrder?.payment_option;
242
- const binNumberUrl =
243
- paymentOption?.payment_type === 'masterpass'
244
- ? checkout.setMasterpassBinNumber
245
- : checkout.setBinNumber;
246
-
247
- return {
248
- url: buildClientRequestUrl(binNumberUrl, {
249
- useFormData: true
250
- }),
251
- method: 'POST',
252
- body: {
253
- bin_number: binNumber
254
- }
255
- };
256
- },
257
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
258
- dispatch(setPaymentStepBusy(true));
259
- await queryFulfilled;
260
- dispatch(setPaymentStepBusy(false));
261
- }
262
- }),
263
- setInstallmentOption: build.mutation<CheckoutResponse, number>({
264
- query: (pk: number) => {
265
- const paymentOption =
266
- store.getState().checkout?.preOrder?.payment_option;
267
- const installmentOption =
268
- paymentOption?.payment_type === 'masterpass'
269
- ? checkout.setMasterPassInstallmentOption
270
- : checkout.setInstallmentOption;
271
- return {
272
- url: buildClientRequestUrl(installmentOption, {
273
- useFormData: true
274
- }),
275
- method: 'POST',
276
- body: {
277
- installment: String(pk)
278
- }
279
- };
280
- },
281
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
282
- dispatch(setPaymentStepBusy(true));
283
- await queryFulfilled;
284
- dispatch(setPaymentStepBusy(false));
285
- }
286
- }),
287
- setFundsTransferOption: build.mutation<CheckoutResponse, number>({
288
- query: (pk: number) => ({
289
- url: buildClientRequestUrl(checkout.setFundsTransferOption, {
290
- useFormData: true
291
- }),
292
- method: 'POST',
293
- body: {
294
- bank_account: String(pk)
295
- }
296
- }),
297
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
298
- dispatch(setPaymentStepBusy(true));
299
- await queryFulfilled;
300
- dispatch(setPaymentStepBusy(false));
301
- dispatch(setSelectedBankAccountPk(arg));
302
- }
303
- }),
304
- setCreditPaymentOption: build.mutation<CheckoutResponse, number>({
305
- query: (pk: number) => ({
306
- url: buildClientRequestUrl(checkout.setCreditPaymentOption, {
307
- useFormData: true
308
- }),
309
- method: 'POST',
310
- body: {
311
- credit_payment_option: pk
312
- }
313
- }),
314
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
315
- dispatch(setPaymentStepBusy(true));
316
- await queryFulfilled;
317
- dispatch(setPaymentStepBusy(false));
318
- dispatch(setSelectedCreditPaymentPk(arg));
319
- }
320
- }),
321
- confirmationCreditPayment: build.mutation<CheckoutResponse, void>({
322
- query: () => ({
323
- url: buildClientRequestUrl(checkout.confirmationCreditPayment, {
324
- useFormData: true
325
- }),
326
- method: 'POST',
327
- body: {
328
- agreement: true,
329
- }
330
- }),
331
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
332
- dispatch(setPaymentStepBusy(true));
333
- await queryFulfilled;
334
- dispatch(setPaymentStepBusy(false));
335
- }
336
- }),
337
- completeRedirectionPayment: build.mutation<CheckoutResponse, void>({
338
- query: () => ({
339
- url: buildClientRequestUrl(checkout.completeRedirectionPayment, {
340
- useFormData: true
341
- }),
342
- method: 'POST',
343
- body: {
344
- agreement: true
345
- }
346
- }),
347
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
348
- dispatch(setPaymentStepBusy(true));
349
- await queryFulfilled;
350
- dispatch(setPaymentStepBusy(false));
351
- }
352
- }),
353
- applePaymentSelect: build.mutation<CheckoutResponse, ApplePaySelectParams>({
354
- query: ({ agreement, validationURL }) => ({
355
- url: buildClientRequestUrl(checkout.confirmationPaymentSelect, {
356
- useFormData: true
357
- }),
358
- method: 'POST',
359
- body: {
360
- agreement,
361
- validationURL
362
- }
363
- }),
364
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
365
- dispatch(setPaymentStepBusy(true));
366
- await queryFulfilled;
367
- dispatch(setPaymentStepBusy(false));
368
- }
369
- }),
370
- appleQuery: build.mutation<CheckoutResponse, ApplePayQueryParams>({
371
- query: ({ agreement, paymentToken }) => ({
372
- url: buildClientRequestUrl(checkout.confirmationQuery, {
373
- useFormData: true
374
- }),
375
- method: 'POST',
376
- body: {
377
- agreement,
378
- payment_token: paymentToken
379
- }
380
- }),
381
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
382
- dispatch(setPaymentStepBusy(true));
383
- await queryFulfilled;
384
- dispatch(setPaymentStepBusy(false));
385
- }
386
- }),
387
- completeConfirmation: build.mutation<CheckoutResponse, void>({
388
- query: () => ({
389
- url: buildClientRequestUrl(checkout.confirmationComplete, {
390
- useFormData: true
391
- }),
392
- method: 'POST',
393
- body: {
394
- agreement: true
395
- }
396
- }),
397
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
398
- dispatch(setPaymentStepBusy(true));
399
- await queryFulfilled;
400
- dispatch(setPaymentStepBusy(false));
401
- }
402
- }),
403
- setCompletePayOnDelivery: build.mutation<
404
- CheckoutResponse,
405
- PayOnDeliveryParams
406
- >({
407
- query: ({ paymentType }) => ({
408
- url: buildClientRequestUrl(
409
- `${checkout.fetchCheckout}?page=PayOnDeliveryPage`,
410
- { useFormData: true }
411
- ),
412
- method: 'POST',
413
- body: {
414
- agreement: '1',
415
- paymentType
416
- }
417
- }),
418
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
419
- dispatch(setPaymentStepBusy(true));
420
- await queryFulfilled;
421
- dispatch(setPaymentStepBusy(false));
422
- }
423
- }),
424
- setPayOnDeliveryChoice: build.mutation<CheckoutResponse, string>({
425
- query: (body) => ({
426
- url: buildClientRequestUrl(
427
- `${checkout.fetchCheckout}?page=PayOnDeliveryPaymentChoicePage`,
428
- { useFormData: true }
429
- ),
430
- method: 'POST',
431
- body: {
432
- payment_choice: body
433
- }
434
- }),
435
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
436
- dispatch(setPaymentStepBusy(true));
437
- await queryFulfilled;
438
- dispatch(setPaymentStepBusy(false));
439
- }
440
- }),
441
- completeLoyaltyPayment: build.mutation<CheckoutResponse, void>({
442
- query: () => ({
443
- url: buildClientRequestUrl(checkout.completeLoyaltyPayment, {
444
- useFormData: true
445
- }),
446
- method: 'POST',
447
- body: {
448
- agreement: true
449
- }
450
- }),
451
- async onQueryStarted(arg, { dispatch, queryFulfilled }) {
452
- dispatch(setPaymentStepBusy(true));
453
- await queryFulfilled;
454
- dispatch(setPaymentStepBusy(false));
455
- }
456
- }),
457
- getCheckoutLoyaltyBalance: build.query<CheckoutResponse, void>({
458
- query: () => ({
459
- url: buildClientRequestUrl(checkout.loyaltyMoneyUsage)
460
- })
461
- }),
462
- payWithLoyaltyBalance: build.mutation<any, string>({
463
- query: (amount) => ({
464
- url: buildClientRequestUrl(checkout.loyaltyMoneyUsage, {
465
- useFormData: true
466
- }),
467
- method: 'POST',
468
- body: {
469
- loyalty_amount_to_use: amount
470
- }
471
- })
472
- }),
473
- setOrderNote: build.mutation<CheckoutResponse, string>({
474
- query: (notes) => ({
475
- url: buildClientRequestUrl(checkout.setOrderNote, {
476
- useFormData: true
477
- }),
478
- method: 'POST',
479
- body: {
480
- notes
481
- }
482
- })
483
- })
484
- }),
485
- overrideExisting: false
486
- });
487
-
488
- export const {
489
- useFetchCheckoutQuery,
490
- useFetchCheckoutResultQuery,
491
- useGet3dRedirectFormQuery,
492
- useGetContractQuery,
493
- useCompleteCreditCardPaymentMutation,
494
- useCompleteFundsTransferMutation,
495
- useGuestLoginMutation,
496
- useSetDeliveryOptionMutation,
497
- useSetAddressesMutation,
498
- useSetShippingOptionMutation,
499
- useSetPaymentOptionMutation,
500
- useSetBinNumberMutation,
501
- useSetInstallmentOptionMutation,
502
- useSetFundsTransferOptionMutation,
503
- useSetRetailStoreMutation,
504
- useSetCreditPaymentOptionMutation,
505
- useConfirmationCreditPaymentMutation,
506
- useCompleteRedirectionPaymentMutation,
507
- useApplePaymentSelectMutation,
508
- useAppleQueryMutation,
509
- useCompleteConfirmationMutation,
510
- useSetCompletePayOnDeliveryMutation,
511
- useSetPayOnDeliveryChoiceMutation,
512
- useCompleteLoyaltyPaymentMutation,
513
- useGetCheckoutLoyaltyBalanceQuery,
514
- usePayWithLoyaltyBalanceMutation,
515
- useSetOrderNoteMutation
516
- } = checkoutApi;
1
+ import {
2
+ setBankAccounts,
3
+ setInstallmentOptions,
4
+ setPaymentStepBusy,
5
+ setSelectedBankAccountPk,
6
+ setSelectedCreditPaymentPk,
7
+ setShippingStepBusy
8
+ } from '../../redux/reducers/checkout';
9
+ import {
10
+ CheckoutContext,
11
+ GuestLoginFormParams,
12
+ Order,
13
+ PreOrder
14
+ } from '../../types';
15
+ import { buildClientRequestUrl } from '../../utils';
16
+ import { api } from './api';
17
+ import { checkout } from '../urls';
18
+ import { store } from 'redux/store';
19
+
20
+ interface CheckoutResponse {
21
+ pre_order?: PreOrder;
22
+ errors: {
23
+ non_field_errors: string;
24
+ };
25
+ context_list?: CheckoutContext[];
26
+ template_name?: string;
27
+ redirect_url?: string;
28
+ }
29
+
30
+ interface SetAddressesParams {
31
+ shippingAddressPk: number;
32
+ billingAddressPk: number;
33
+ }
34
+
35
+ interface SetRetailStoreParams {
36
+ retailStorePk: number;
37
+ billingAddressPk: number;
38
+ }
39
+
40
+ interface CompleteCreditCardParams {
41
+ card_holder: string;
42
+ card_cvv: string;
43
+ card_number: string;
44
+ card_month: string;
45
+ card_year: string;
46
+ use_three_d?: boolean;
47
+ }
48
+
49
+ interface GetContractResponse {
50
+ result: string;
51
+ }
52
+
53
+ interface ApplePaySelectParams {
54
+ agreement: boolean;
55
+ validationURL: string;
56
+ }
57
+
58
+ interface ApplePayQueryParams {
59
+ agreement: boolean;
60
+ paymentToken: string;
61
+ }
62
+
63
+ export interface PayOnDeliveryParams {
64
+ agreement: string;
65
+ paymentType: string;
66
+ }
67
+
68
+ export const checkoutApi = api.injectEndpoints({
69
+ endpoints: (build) => ({
70
+ fetchCheckout: build.query<CheckoutResponse, void>({
71
+ query: () => ({
72
+ url: buildClientRequestUrl(checkout.fetchCheckout, {})
73
+ }),
74
+ providesTags: ['Checkout']
75
+ }),
76
+ fetchCheckoutResult: build.query<{ order: Order }, string>({
77
+ query: (token: string) =>
78
+ buildClientRequestUrl(checkout.fetchCheckoutResult(token))
79
+ }),
80
+ get3dRedirectForm: build.query<{ result: string }, void>({
81
+ query: () =>
82
+ buildClientRequestUrl(checkout.get3dRedirectForm, {
83
+ responseType: 'text'
84
+ })
85
+ }),
86
+ getContract: build.query<GetContractResponse, string>({
87
+ query: (slug: string) =>
88
+ buildClientRequestUrl(checkout.getContract(slug), {
89
+ responseType: 'text'
90
+ })
91
+ }),
92
+ completeCreditCardPayment: build.mutation<
93
+ CheckoutResponse,
94
+ CompleteCreditCardParams
95
+ >({
96
+ query: ({
97
+ card_holder,
98
+ card_cvv,
99
+ card_number,
100
+ card_month,
101
+ card_year,
102
+ use_three_d = true
103
+ }) => ({
104
+ url: buildClientRequestUrl(checkout.completeCreditCardPayment, {
105
+ useFormData: true
106
+ }),
107
+ method: 'POST',
108
+ body: {
109
+ agreement: '1',
110
+ use_three_d: use_three_d ? '1' : '0',
111
+ card_cvv,
112
+ card_holder,
113
+ card_month,
114
+ card_number,
115
+ card_year
116
+ }
117
+ }),
118
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
119
+ dispatch(setPaymentStepBusy(true));
120
+ await queryFulfilled;
121
+ dispatch(setPaymentStepBusy(false));
122
+ },
123
+ invalidatesTags: ['Basket']
124
+ }),
125
+ completeFundsTransfer: build.mutation<CheckoutResponse, void>({
126
+ query: () => ({
127
+ url: buildClientRequestUrl(checkout.completeFundsTransfer, {
128
+ useFormData: true
129
+ }),
130
+ method: 'POST',
131
+ body: {
132
+ agreement: '1'
133
+ }
134
+ }),
135
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
136
+ dispatch(setPaymentStepBusy(true));
137
+ await queryFulfilled;
138
+ dispatch(setPaymentStepBusy(false));
139
+ },
140
+ invalidatesTags: ['Basket']
141
+ }),
142
+ guestLogin: build.mutation<CheckoutResponse, GuestLoginFormParams>({
143
+ query: ({ user_email, phone_number }) => ({
144
+ url: buildClientRequestUrl(checkout.guestLogin, {
145
+ useFormData: true
146
+ }),
147
+ method: 'POST',
148
+ body: {
149
+ user_email,
150
+ phone_number
151
+ }
152
+ }),
153
+ invalidatesTags: ['Checkout']
154
+ }),
155
+ setDeliveryOption: build.mutation<CheckoutResponse, number>({
156
+ query: (pk: number) => ({
157
+ url: buildClientRequestUrl(checkout.setDeliveryOption, {
158
+ useFormData: true
159
+ }),
160
+ method: 'POST',
161
+ body: {
162
+ delivery_option: String(pk)
163
+ }
164
+ }),
165
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
166
+ dispatch(setShippingStepBusy(true));
167
+ await queryFulfilled;
168
+ dispatch(setShippingStepBusy(false));
169
+ }
170
+ }),
171
+ setAddresses: build.mutation<CheckoutResponse, SetAddressesParams>({
172
+ query: ({ shippingAddressPk, billingAddressPk }) => ({
173
+ url: buildClientRequestUrl(checkout.setAddresses, {
174
+ useFormData: true
175
+ }),
176
+ method: 'POST',
177
+ body: {
178
+ shipping_address: String(shippingAddressPk),
179
+ billing_address: String(billingAddressPk)
180
+ }
181
+ }),
182
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
183
+ dispatch(setShippingStepBusy(true));
184
+ await queryFulfilled;
185
+ dispatch(setShippingStepBusy(false));
186
+ }
187
+ }),
188
+ setShippingOption: build.mutation<CheckoutResponse, number>({
189
+ query: (pk: number) => ({
190
+ url: buildClientRequestUrl(checkout.setShippingOption, {
191
+ useFormData: true
192
+ }),
193
+ method: 'POST',
194
+ body: {
195
+ shipping_option: String(pk)
196
+ }
197
+ }),
198
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
199
+ dispatch(setShippingStepBusy(true));
200
+ await queryFulfilled;
201
+ dispatch(setShippingStepBusy(false));
202
+ }
203
+ }),
204
+ setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
205
+ query: ({ retailStorePk, billingAddressPk }) => ({
206
+ url: buildClientRequestUrl(
207
+ '/orders/checkout?page=RetailStoreSelectionPage',
208
+ {
209
+ useFormData: true
210
+ }
211
+ ),
212
+ method: 'POST',
213
+ body: {
214
+ retail_store: Number(retailStorePk),
215
+ billing_address: Number(billingAddressPk)
216
+ }
217
+ })
218
+ }),
219
+ setPaymentOption: build.mutation<CheckoutResponse, number>({
220
+ query: (pk: number) => ({
221
+ url: buildClientRequestUrl(checkout.setPaymentOption, {
222
+ useFormData: true
223
+ }),
224
+ method: 'POST',
225
+ body: {
226
+ payment_option: String(pk)
227
+ }
228
+ }),
229
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
230
+ dispatch(setPaymentStepBusy(true));
231
+ dispatch(setInstallmentOptions([]));
232
+ dispatch(setBankAccounts([]));
233
+ dispatch(setSelectedBankAccountPk(null));
234
+ await queryFulfilled;
235
+ dispatch(setPaymentStepBusy(false));
236
+ }
237
+ }),
238
+ setBinNumber: build.mutation<CheckoutResponse, string>({
239
+ query: (binNumber: string) => {
240
+ const paymentOption =
241
+ store.getState().checkout?.preOrder?.payment_option;
242
+ const binNumberUrl =
243
+ paymentOption?.payment_type === 'masterpass'
244
+ ? checkout.setMasterpassBinNumber
245
+ : checkout.setBinNumber;
246
+
247
+ return {
248
+ url: buildClientRequestUrl(binNumberUrl, {
249
+ useFormData: true
250
+ }),
251
+ method: 'POST',
252
+ body: {
253
+ bin_number: binNumber
254
+ }
255
+ };
256
+ },
257
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
258
+ dispatch(setPaymentStepBusy(true));
259
+ await queryFulfilled;
260
+ dispatch(setPaymentStepBusy(false));
261
+ }
262
+ }),
263
+ setInstallmentOption: build.mutation<CheckoutResponse, number>({
264
+ query: (pk: number) => {
265
+ const paymentOption =
266
+ store.getState().checkout?.preOrder?.payment_option;
267
+ const installmentOption =
268
+ paymentOption?.payment_type === 'masterpass'
269
+ ? checkout.setMasterPassInstallmentOption
270
+ : checkout.setInstallmentOption;
271
+ return {
272
+ url: buildClientRequestUrl(installmentOption, {
273
+ useFormData: true
274
+ }),
275
+ method: 'POST',
276
+ body: {
277
+ installment: String(pk)
278
+ }
279
+ };
280
+ },
281
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
282
+ dispatch(setPaymentStepBusy(true));
283
+ await queryFulfilled;
284
+ dispatch(setPaymentStepBusy(false));
285
+ }
286
+ }),
287
+ setFundsTransferOption: build.mutation<CheckoutResponse, number>({
288
+ query: (pk: number) => ({
289
+ url: buildClientRequestUrl(checkout.setFundsTransferOption, {
290
+ useFormData: true
291
+ }),
292
+ method: 'POST',
293
+ body: {
294
+ bank_account: String(pk)
295
+ }
296
+ }),
297
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
298
+ dispatch(setPaymentStepBusy(true));
299
+ await queryFulfilled;
300
+ dispatch(setPaymentStepBusy(false));
301
+ dispatch(setSelectedBankAccountPk(arg));
302
+ }
303
+ }),
304
+ setCreditPaymentOption: build.mutation<CheckoutResponse, number>({
305
+ query: (pk: number) => ({
306
+ url: buildClientRequestUrl(checkout.setCreditPaymentOption, {
307
+ useFormData: true
308
+ }),
309
+ method: 'POST',
310
+ body: {
311
+ credit_payment_option: pk
312
+ }
313
+ }),
314
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
315
+ dispatch(setPaymentStepBusy(true));
316
+ await queryFulfilled;
317
+ dispatch(setPaymentStepBusy(false));
318
+ dispatch(setSelectedCreditPaymentPk(arg));
319
+ }
320
+ }),
321
+ confirmationCreditPayment: build.mutation<CheckoutResponse, void>({
322
+ query: () => ({
323
+ url: buildClientRequestUrl(checkout.confirmationCreditPayment, {
324
+ useFormData: true
325
+ }),
326
+ method: 'POST',
327
+ body: {
328
+ agreement: true,
329
+ }
330
+ }),
331
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
332
+ dispatch(setPaymentStepBusy(true));
333
+ await queryFulfilled;
334
+ dispatch(setPaymentStepBusy(false));
335
+ }
336
+ }),
337
+ completeRedirectionPayment: build.mutation<CheckoutResponse, void>({
338
+ query: () => ({
339
+ url: buildClientRequestUrl(checkout.completeRedirectionPayment, {
340
+ useFormData: true
341
+ }),
342
+ method: 'POST',
343
+ body: {
344
+ agreement: true
345
+ }
346
+ }),
347
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
348
+ dispatch(setPaymentStepBusy(true));
349
+ await queryFulfilled;
350
+ dispatch(setPaymentStepBusy(false));
351
+ }
352
+ }),
353
+ applePaymentSelect: build.mutation<CheckoutResponse, ApplePaySelectParams>({
354
+ query: ({ agreement, validationURL }) => ({
355
+ url: buildClientRequestUrl(checkout.confirmationPaymentSelect, {
356
+ useFormData: true
357
+ }),
358
+ method: 'POST',
359
+ body: {
360
+ agreement,
361
+ validationURL
362
+ }
363
+ }),
364
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
365
+ dispatch(setPaymentStepBusy(true));
366
+ await queryFulfilled;
367
+ dispatch(setPaymentStepBusy(false));
368
+ }
369
+ }),
370
+ appleQuery: build.mutation<CheckoutResponse, ApplePayQueryParams>({
371
+ query: ({ agreement, paymentToken }) => ({
372
+ url: buildClientRequestUrl(checkout.confirmationQuery, {
373
+ useFormData: true
374
+ }),
375
+ method: 'POST',
376
+ body: {
377
+ agreement,
378
+ payment_token: paymentToken
379
+ }
380
+ }),
381
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
382
+ dispatch(setPaymentStepBusy(true));
383
+ await queryFulfilled;
384
+ dispatch(setPaymentStepBusy(false));
385
+ }
386
+ }),
387
+ completeConfirmation: build.mutation<CheckoutResponse, void>({
388
+ query: () => ({
389
+ url: buildClientRequestUrl(checkout.confirmationComplete, {
390
+ useFormData: true
391
+ }),
392
+ method: 'POST',
393
+ body: {
394
+ agreement: true
395
+ }
396
+ }),
397
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
398
+ dispatch(setPaymentStepBusy(true));
399
+ await queryFulfilled;
400
+ dispatch(setPaymentStepBusy(false));
401
+ }
402
+ }),
403
+ setCompletePayOnDelivery: build.mutation<
404
+ CheckoutResponse,
405
+ PayOnDeliveryParams
406
+ >({
407
+ query: ({ paymentType }) => ({
408
+ url: buildClientRequestUrl(
409
+ `${checkout.fetchCheckout}?page=PayOnDeliveryPage`,
410
+ { useFormData: true }
411
+ ),
412
+ method: 'POST',
413
+ body: {
414
+ agreement: '1',
415
+ paymentType
416
+ }
417
+ }),
418
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
419
+ dispatch(setPaymentStepBusy(true));
420
+ await queryFulfilled;
421
+ dispatch(setPaymentStepBusy(false));
422
+ }
423
+ }),
424
+ setPayOnDeliveryChoice: build.mutation<CheckoutResponse, string>({
425
+ query: (body) => ({
426
+ url: buildClientRequestUrl(
427
+ `${checkout.fetchCheckout}?page=PayOnDeliveryPaymentChoicePage`,
428
+ { useFormData: true }
429
+ ),
430
+ method: 'POST',
431
+ body: {
432
+ payment_choice: body
433
+ }
434
+ }),
435
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
436
+ dispatch(setPaymentStepBusy(true));
437
+ await queryFulfilled;
438
+ dispatch(setPaymentStepBusy(false));
439
+ }
440
+ }),
441
+ completeLoyaltyPayment: build.mutation<CheckoutResponse, void>({
442
+ query: () => ({
443
+ url: buildClientRequestUrl(checkout.completeLoyaltyPayment, {
444
+ useFormData: true
445
+ }),
446
+ method: 'POST',
447
+ body: {
448
+ agreement: true
449
+ }
450
+ }),
451
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
452
+ dispatch(setPaymentStepBusy(true));
453
+ await queryFulfilled;
454
+ dispatch(setPaymentStepBusy(false));
455
+ }
456
+ }),
457
+ getCheckoutLoyaltyBalance: build.query<CheckoutResponse, void>({
458
+ query: () => ({
459
+ url: buildClientRequestUrl(checkout.loyaltyMoneyUsage)
460
+ })
461
+ }),
462
+ payWithLoyaltyBalance: build.mutation<any, string>({
463
+ query: (amount) => ({
464
+ url: buildClientRequestUrl(checkout.loyaltyMoneyUsage, {
465
+ useFormData: true
466
+ }),
467
+ method: 'POST',
468
+ body: {
469
+ loyalty_amount_to_use: amount
470
+ }
471
+ })
472
+ }),
473
+ setOrderNote: build.mutation<CheckoutResponse, string>({
474
+ query: (notes) => ({
475
+ url: buildClientRequestUrl(checkout.setOrderNote, {
476
+ useFormData: true
477
+ }),
478
+ method: 'POST',
479
+ body: {
480
+ notes
481
+ }
482
+ })
483
+ })
484
+ }),
485
+ overrideExisting: false
486
+ });
487
+
488
+ export const {
489
+ useFetchCheckoutQuery,
490
+ useFetchCheckoutResultQuery,
491
+ useGet3dRedirectFormQuery,
492
+ useGetContractQuery,
493
+ useCompleteCreditCardPaymentMutation,
494
+ useCompleteFundsTransferMutation,
495
+ useGuestLoginMutation,
496
+ useSetDeliveryOptionMutation,
497
+ useSetAddressesMutation,
498
+ useSetShippingOptionMutation,
499
+ useSetPaymentOptionMutation,
500
+ useSetBinNumberMutation,
501
+ useSetInstallmentOptionMutation,
502
+ useSetFundsTransferOptionMutation,
503
+ useSetRetailStoreMutation,
504
+ useSetCreditPaymentOptionMutation,
505
+ useConfirmationCreditPaymentMutation,
506
+ useCompleteRedirectionPaymentMutation,
507
+ useApplePaymentSelectMutation,
508
+ useAppleQueryMutation,
509
+ useCompleteConfirmationMutation,
510
+ useSetCompletePayOnDeliveryMutation,
511
+ useSetPayOnDeliveryChoiceMutation,
512
+ useCompleteLoyaltyPaymentMutation,
513
+ useGetCheckoutLoyaltyBalanceQuery,
514
+ usePayWithLoyaltyBalanceMutation,
515
+ useSetOrderNoteMutation
516
+ } = checkoutApi;