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