@tagadapay/plugin-sdk 3.1.12 → 3.1.24
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.
- package/build-cdn.js +397 -11
- package/dist/data/iso3166.d.ts +23 -33
- package/dist/data/iso3166.js +134 -198
- package/dist/data/languages.d.ts +5 -64
- package/dist/data/languages.js +23 -143
- package/dist/external-tracker.js +623 -3426
- package/dist/external-tracker.min.js +2 -25
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/config/payment.d.ts +14 -4
- package/dist/react/config/payment.js +47 -9
- package/dist/react/hooks/useCheckout.d.ts +3 -0
- package/dist/react/hooks/useCheckout.js +4 -1
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/react/hooks/usePluginConfig.js +9 -10
- package/dist/react/providers/TagadaProvider.js +1 -1
- package/dist/tagada-react-sdk-minimal.min.js +36 -0
- package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
- package/dist/tagada-react-sdk.js +37821 -0
- package/dist/tagada-react-sdk.min.js +78 -0
- package/dist/tagada-react-sdk.min.js.map +7 -0
- package/dist/tagada-sdk.js +16044 -0
- package/dist/tagada-sdk.min.js +32 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/cdn-react-minimal.d.ts +23 -0
- package/dist/v2/cdn-react-minimal.js +26 -0
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +5 -4
- package/dist/v2/core/config/environment.js +2 -1
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +100 -10
- package/dist/v2/core/funnelClient.js +121 -27
- package/dist/v2/core/isoData.d.ts +4 -4
- package/dist/v2/core/isoData.js +7 -7
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +363 -0
- package/dist/v2/core/resources/apiClient.d.ts +2 -0
- package/dist/v2/core/resources/apiClient.js +52 -9
- package/dist/v2/core/resources/checkout.d.ts +99 -30
- package/dist/v2/core/resources/checkout.js +14 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +89 -13
- package/dist/v2/core/resources/payments.js +27 -9
- package/dist/v2/core/resources/postPurchases.d.ts +17 -0
- package/dist/v2/core/resources/postPurchases.js +20 -0
- package/dist/v2/core/types.d.ts +50 -12
- package/dist/v2/core/types.js +0 -3
- package/dist/v2/core/utils/checkout.d.ts +2 -2
- package/dist/v2/core/utils/checkout.js +7 -2
- package/dist/v2/core/utils/currency.d.ts +14 -0
- package/dist/v2/core/utils/currency.js +40 -0
- package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
- package/dist/v2/core/utils/deviceInfo.js +152 -76
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/order.d.ts +13 -9
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +36 -12
- package/dist/v2/index.d.ts +6 -3
- package/dist/v2/index.js +4 -2
- package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
- package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
- package/dist/v2/react/components/StripeExpressButton.js +171 -0
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +237 -0
- package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
- package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
- package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
- package/dist/v2/react/hooks/useFunnel.js +8 -4
- package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
- package/dist/v2/react/hooks/useGeoLocation.js +4 -2
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
- package/dist/v2/react/hooks/useISOData.d.ts +2 -5
- package/dist/v2/react/hooks/useISOData.js +26 -27
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
- package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
- package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
- package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
- package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
- package/dist/v2/react/hooks/usePixelTracking.js +283 -504
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
- package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
- package/dist/v2/react/hooks/useRemappableParams.js +23 -23
- package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
- package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
- package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
- package/dist/v2/react/hooks/useStepConfig.js +14 -7
- package/dist/v2/react/hooks/useTranslation.js +23 -8
- package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
- package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
- package/dist/v2/react/index.d.ts +15 -1
- package/dist/v2/react/index.js +7 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
- package/dist/v2/react/providers/TagadaProvider.js +74 -5
- package/dist/v2/standalone/external-tracker.d.ts +52 -46
- package/dist/v2/standalone/external-tracker.js +205 -98
- package/dist/v2/standalone/index.d.ts +40 -0
- package/dist/v2/standalone/index.js +148 -1
- package/dist/v2/standalone/payment-service.d.ts +134 -0
- package/dist/v2/standalone/payment-service.js +928 -0
- package/package.json +6 -4
- package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
- package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
- package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
- package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Checkout Resource Client
|
|
3
3
|
* Axios-based API client for checkout endpoints
|
|
4
4
|
*/
|
|
5
|
+
import type { OrderAddress } from '../types';
|
|
5
6
|
import { ApiClient } from './apiClient';
|
|
7
|
+
export type PaymentMethodName = 'paypal' | 'card' | 'klarna' | 'zelle';
|
|
6
8
|
export interface CheckoutLineItem {
|
|
7
9
|
externalProductId?: string | null;
|
|
8
10
|
externalVariantId?: string | null;
|
|
@@ -25,6 +27,7 @@ export interface CheckoutInitParams {
|
|
|
25
27
|
currency?: string;
|
|
26
28
|
locale?: string;
|
|
27
29
|
};
|
|
30
|
+
enabledOrderBumpOfferIds?: string[];
|
|
28
31
|
}
|
|
29
32
|
export interface UpsellTrigger {
|
|
30
33
|
id: string;
|
|
@@ -91,7 +94,7 @@ export interface Store {
|
|
|
91
94
|
chargeCurrencies: string[];
|
|
92
95
|
upsells: Upsell[];
|
|
93
96
|
emailDomains: string[];
|
|
94
|
-
integrations:
|
|
97
|
+
integrations: unknown[];
|
|
95
98
|
}
|
|
96
99
|
export interface CheckoutSession {
|
|
97
100
|
id: string;
|
|
@@ -106,7 +109,56 @@ export interface CheckoutSession {
|
|
|
106
109
|
updatedAt: string;
|
|
107
110
|
lastActiveDate: string;
|
|
108
111
|
selectedPresentmentCurrency: string;
|
|
109
|
-
|
|
112
|
+
shippingRate?: {
|
|
113
|
+
id: string;
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
} | null;
|
|
116
|
+
shippingRateId?: string;
|
|
117
|
+
sessionLineItems?: Array<{
|
|
118
|
+
isOrderBump?: boolean;
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}>;
|
|
121
|
+
customer?: {
|
|
122
|
+
email?: string;
|
|
123
|
+
firstName?: string;
|
|
124
|
+
lastName?: string;
|
|
125
|
+
currency?: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
};
|
|
128
|
+
shippingAddress?: {
|
|
129
|
+
firstName?: string;
|
|
130
|
+
lastName?: string;
|
|
131
|
+
address1?: string;
|
|
132
|
+
address2?: string;
|
|
133
|
+
city?: string;
|
|
134
|
+
state?: string;
|
|
135
|
+
postal?: string;
|
|
136
|
+
country?: string;
|
|
137
|
+
phone?: string;
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
billingAddress?: {
|
|
141
|
+
firstName?: string;
|
|
142
|
+
lastName?: string;
|
|
143
|
+
address1?: string;
|
|
144
|
+
address2?: string;
|
|
145
|
+
city?: string;
|
|
146
|
+
state?: string;
|
|
147
|
+
postal?: string;
|
|
148
|
+
country?: string;
|
|
149
|
+
phone?: string;
|
|
150
|
+
[key: string]: unknown;
|
|
151
|
+
};
|
|
152
|
+
metadata?: {
|
|
153
|
+
cartCustomAttributes?: Array<{
|
|
154
|
+
name?: string;
|
|
155
|
+
value?: string;
|
|
156
|
+
[key: string]: unknown;
|
|
157
|
+
}>;
|
|
158
|
+
clubProductId?: string;
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
[key: string]: unknown;
|
|
110
162
|
}
|
|
111
163
|
export interface CheckoutSummaryItem {
|
|
112
164
|
id: string;
|
|
@@ -129,12 +181,13 @@ export interface CheckoutSummaryItem {
|
|
|
129
181
|
amount: number;
|
|
130
182
|
adjustedAmount: number;
|
|
131
183
|
currency: string;
|
|
132
|
-
adjustments:
|
|
184
|
+
adjustments: CheckoutSessionPreviewAdjustment[];
|
|
133
185
|
recurring: boolean;
|
|
134
186
|
interval?: 'day' | 'week' | 'month' | 'year';
|
|
135
187
|
intervalCount?: number;
|
|
136
188
|
totalBillingCycles?: number;
|
|
137
189
|
unitAmountAfterFirstCycle?: number;
|
|
190
|
+
properties?: Record<string, unknown>;
|
|
138
191
|
orderLineItemProduct: {
|
|
139
192
|
name: string;
|
|
140
193
|
};
|
|
@@ -169,6 +222,7 @@ export interface CheckoutSummary {
|
|
|
169
222
|
}[];
|
|
170
223
|
}
|
|
171
224
|
export interface CheckoutSessionPreviewAdjustment {
|
|
225
|
+
id?: string;
|
|
172
226
|
type: 'Promotion' | 'Tax' | 'Shipping';
|
|
173
227
|
description: string;
|
|
174
228
|
level: 'Order' | 'LineItem';
|
|
@@ -205,7 +259,8 @@ export interface CheckoutSessionPreviewItem {
|
|
|
205
259
|
intervalCount?: number;
|
|
206
260
|
totalBillingCycles?: number;
|
|
207
261
|
unitAmountAfterFirstCycle?: number;
|
|
208
|
-
subscriptionSettings?:
|
|
262
|
+
subscriptionSettings?: Record<string, unknown>;
|
|
263
|
+
properties?: Record<string, unknown>;
|
|
209
264
|
orderLineItemProduct: {
|
|
210
265
|
name: string | null;
|
|
211
266
|
} | null;
|
|
@@ -221,13 +276,22 @@ export interface CheckoutSessionPreview {
|
|
|
221
276
|
totalAdjustedAmount: number;
|
|
222
277
|
totalPromotionAmount: number;
|
|
223
278
|
}
|
|
279
|
+
export interface PromotionAction {
|
|
280
|
+
id: string;
|
|
281
|
+
adjustmentAmount?: Record<string, {
|
|
282
|
+
amount: number;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}>;
|
|
285
|
+
adjustmentPercentage?: number;
|
|
286
|
+
[key: string]: unknown;
|
|
287
|
+
}
|
|
224
288
|
export interface Promotion {
|
|
225
289
|
id: string;
|
|
226
290
|
name: string;
|
|
227
291
|
description: string | null;
|
|
228
292
|
type: string;
|
|
229
|
-
rules:
|
|
230
|
-
actions:
|
|
293
|
+
rules: Record<string, unknown>[];
|
|
294
|
+
actions: PromotionAction[];
|
|
231
295
|
}
|
|
232
296
|
export interface CheckoutData {
|
|
233
297
|
checkoutSession: CheckoutSession;
|
|
@@ -236,14 +300,6 @@ export interface CheckoutData {
|
|
|
236
300
|
summary: CheckoutSummary;
|
|
237
301
|
availablePromotions: Promotion[];
|
|
238
302
|
}
|
|
239
|
-
export interface Promotion {
|
|
240
|
-
id: string;
|
|
241
|
-
name: string;
|
|
242
|
-
description: string | null;
|
|
243
|
-
type: string;
|
|
244
|
-
rules: any[];
|
|
245
|
-
actions: any[];
|
|
246
|
-
}
|
|
247
303
|
export declare class CheckoutResource {
|
|
248
304
|
private apiClient;
|
|
249
305
|
constructor(apiClient: ApiClient);
|
|
@@ -300,9 +356,9 @@ export declare class CheckoutResource {
|
|
|
300
356
|
funnelVariantId?: string;
|
|
301
357
|
navigationEvent?: string | {
|
|
302
358
|
type: string;
|
|
303
|
-
data?:
|
|
359
|
+
data?: Record<string, unknown>;
|
|
304
360
|
};
|
|
305
|
-
navigationOptions?:
|
|
361
|
+
navigationOptions?: Record<string, unknown>;
|
|
306
362
|
}, getFunnelSessionId?: () => string | null | undefined): Promise<{
|
|
307
363
|
checkoutToken: string;
|
|
308
364
|
customerId: string;
|
|
@@ -338,8 +394,8 @@ export declare class CheckoutResource {
|
|
|
338
394
|
* Update checkout address
|
|
339
395
|
*/
|
|
340
396
|
updateAddress(checkoutSessionId: string, data: {
|
|
341
|
-
shippingAddress:
|
|
342
|
-
billingAddress?:
|
|
397
|
+
shippingAddress: Partial<OrderAddress>;
|
|
398
|
+
billingAddress?: Partial<OrderAddress>;
|
|
343
399
|
}): Promise<{
|
|
344
400
|
success: boolean;
|
|
345
401
|
errors?: Record<string, {
|
|
@@ -353,8 +409,8 @@ export declare class CheckoutResource {
|
|
|
353
409
|
* Set checkout info
|
|
354
410
|
*/
|
|
355
411
|
setCheckoutInfo(checkoutSessionId: string, data: {
|
|
356
|
-
shippingAddress:
|
|
357
|
-
billingAddress?:
|
|
412
|
+
shippingAddress: Partial<OrderAddress>;
|
|
413
|
+
billingAddress?: Partial<OrderAddress>;
|
|
358
414
|
differentBillingAddress?: boolean;
|
|
359
415
|
}): Promise<{
|
|
360
416
|
success: boolean;
|
|
@@ -370,32 +426,39 @@ export declare class CheckoutResource {
|
|
|
370
426
|
*/
|
|
371
427
|
applyPromotionCode(checkoutSessionId: string, code: string): Promise<{
|
|
372
428
|
success: boolean;
|
|
373
|
-
error?:
|
|
429
|
+
error?: string;
|
|
374
430
|
}>;
|
|
375
431
|
/**
|
|
376
432
|
* Remove promotion
|
|
377
433
|
*/
|
|
378
434
|
removePromotion(checkoutSessionId: string, promotionId: string): Promise<{
|
|
379
435
|
success: boolean;
|
|
380
|
-
error?:
|
|
436
|
+
error?: string;
|
|
381
437
|
}>;
|
|
382
438
|
/**
|
|
383
439
|
* Get applied promotions
|
|
384
440
|
*/
|
|
385
441
|
getAppliedPromotions(checkoutSessionId: string): Promise<Promotion[]>;
|
|
442
|
+
/**
|
|
443
|
+
* Replace all session line items (full rewrite)
|
|
444
|
+
*/
|
|
445
|
+
replaceSessionLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
446
|
+
success: boolean;
|
|
447
|
+
error?: string;
|
|
448
|
+
}>;
|
|
386
449
|
/**
|
|
387
450
|
* Update line items
|
|
388
451
|
*/
|
|
389
452
|
updateLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
390
453
|
success: boolean;
|
|
391
|
-
error?:
|
|
454
|
+
error?: string;
|
|
392
455
|
}>;
|
|
393
456
|
/**
|
|
394
457
|
* Add line items
|
|
395
458
|
*/
|
|
396
459
|
addLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
397
460
|
success: boolean;
|
|
398
|
-
error?:
|
|
461
|
+
error?: string;
|
|
399
462
|
}>;
|
|
400
463
|
/**
|
|
401
464
|
* Remove line items
|
|
@@ -405,21 +468,21 @@ export declare class CheckoutResource {
|
|
|
405
468
|
quantity?: number;
|
|
406
469
|
}[]): Promise<{
|
|
407
470
|
success: boolean;
|
|
408
|
-
error?:
|
|
471
|
+
error?: string;
|
|
409
472
|
}>;
|
|
410
473
|
/**
|
|
411
474
|
* Set item quantity
|
|
412
475
|
*/
|
|
413
476
|
setItemQuantity(checkoutSessionId: string, variantId: string, quantity: number, priceId?: string): Promise<{
|
|
414
477
|
success: boolean;
|
|
415
|
-
error?:
|
|
478
|
+
error?: string;
|
|
416
479
|
}>;
|
|
417
480
|
/**
|
|
418
481
|
* Toggle order bump
|
|
419
482
|
*/
|
|
420
483
|
toggleOrderBump(checkoutSessionId: string, orderBumpOfferId: string, selected: boolean): Promise<{
|
|
421
484
|
success: boolean;
|
|
422
|
-
error?:
|
|
485
|
+
error?: string;
|
|
423
486
|
}>;
|
|
424
487
|
/**
|
|
425
488
|
* Update customer
|
|
@@ -429,7 +492,7 @@ export declare class CheckoutResource {
|
|
|
429
492
|
acceptsMarketing?: boolean;
|
|
430
493
|
}): Promise<{
|
|
431
494
|
success: boolean;
|
|
432
|
-
error?:
|
|
495
|
+
error?: string;
|
|
433
496
|
}>;
|
|
434
497
|
/**
|
|
435
498
|
* Update customer and session info
|
|
@@ -439,8 +502,8 @@ export declare class CheckoutResource {
|
|
|
439
502
|
email: string;
|
|
440
503
|
acceptsMarketing?: boolean;
|
|
441
504
|
};
|
|
442
|
-
shippingAddress:
|
|
443
|
-
billingAddress?:
|
|
505
|
+
shippingAddress: Partial<OrderAddress>;
|
|
506
|
+
billingAddress?: Partial<OrderAddress>;
|
|
444
507
|
differentBillingAddress?: boolean;
|
|
445
508
|
}): Promise<{
|
|
446
509
|
success: boolean;
|
|
@@ -460,4 +523,10 @@ export declare class CheckoutResource {
|
|
|
460
523
|
success: boolean;
|
|
461
524
|
preview: CheckoutSessionPreview;
|
|
462
525
|
}>;
|
|
526
|
+
/**
|
|
527
|
+
* Set selected payment method for a checkout session
|
|
528
|
+
*/
|
|
529
|
+
setPaymentMethod(checkoutSessionId: string, paymentMethodName: PaymentMethodName): Promise<{
|
|
530
|
+
success: boolean;
|
|
531
|
+
}>;
|
|
463
532
|
}
|
|
@@ -147,6 +147,14 @@ export class CheckoutResource {
|
|
|
147
147
|
async getAppliedPromotions(checkoutSessionId) {
|
|
148
148
|
return this.apiClient.get(`/api/v1/checkout-sessions/${checkoutSessionId}/promotions`);
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Replace all session line items (full rewrite)
|
|
152
|
+
*/
|
|
153
|
+
async replaceSessionLineItems(checkoutSessionId, lineItems) {
|
|
154
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/line-items`, {
|
|
155
|
+
lineItems,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
150
158
|
/**
|
|
151
159
|
* Update line items
|
|
152
160
|
*/
|
|
@@ -205,4 +213,10 @@ export class CheckoutResource {
|
|
|
205
213
|
async previewCheckoutSession(params) {
|
|
206
214
|
return this.apiClient.post('/api/v1/checkout-sessions/preview', params);
|
|
207
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Set selected payment method for a checkout session
|
|
218
|
+
*/
|
|
219
|
+
async setPaymentMethod(checkoutSessionId, paymentMethodName) {
|
|
220
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/payment-method`, { paymentMethodName });
|
|
221
|
+
}
|
|
208
222
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Handles customer-related API operations
|
|
4
4
|
*/
|
|
5
5
|
import { ApiClient } from './apiClient';
|
|
6
|
+
import type { Subscription as CoreSubscription, DeviceInfo, PromotionCode, OrderAddress, OrderSummary, PromotionSummary, PaymentSummary, OrderAdjustmentSummary } from '../types';
|
|
6
7
|
export interface CustomerAddress {
|
|
7
8
|
firstName: string | null;
|
|
8
9
|
lastName: string | null;
|
|
@@ -40,12 +41,12 @@ export interface CustomerInfos {
|
|
|
40
41
|
acceptsMarketing: boolean;
|
|
41
42
|
createdAt: string;
|
|
42
43
|
updatedAt: string;
|
|
43
|
-
metadata: Record<string,
|
|
44
|
-
device:
|
|
44
|
+
metadata: Record<string, unknown>;
|
|
45
|
+
device: DeviceInfo | null;
|
|
45
46
|
orders: CustomerOrderSummary[];
|
|
46
|
-
subscriptions:
|
|
47
|
+
subscriptions: CoreSubscription[];
|
|
47
48
|
};
|
|
48
|
-
promotionCodes:
|
|
49
|
+
promotionCodes: PromotionCode[];
|
|
49
50
|
}
|
|
50
51
|
export interface OrderWithRelations {
|
|
51
52
|
id: string;
|
|
@@ -53,27 +54,27 @@ export interface OrderWithRelations {
|
|
|
53
54
|
paidAmount: number;
|
|
54
55
|
status: string;
|
|
55
56
|
createdAt: string;
|
|
56
|
-
metadata?: Record<string,
|
|
57
|
-
items:
|
|
58
|
-
summaries?:
|
|
59
|
-
shippingAddress?:
|
|
60
|
-
billingAddress?:
|
|
61
|
-
pickupAddress?:
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
items: Record<string, unknown>[];
|
|
59
|
+
summaries?: OrderSummary[];
|
|
60
|
+
shippingAddress?: OrderAddress | null;
|
|
61
|
+
billingAddress?: OrderAddress | null;
|
|
62
|
+
pickupAddress?: Record<string, unknown> | null;
|
|
62
63
|
checkoutSession?: {
|
|
63
64
|
returnUrl?: string;
|
|
64
|
-
[key: string]:
|
|
65
|
+
[key: string]: unknown;
|
|
65
66
|
};
|
|
66
|
-
relatedOrders?:
|
|
67
|
-
customer?:
|
|
68
|
-
store?:
|
|
67
|
+
relatedOrders?: OrderWithRelations[];
|
|
68
|
+
customer?: Record<string, unknown>;
|
|
69
|
+
store?: Record<string, unknown>;
|
|
69
70
|
account?: {
|
|
70
71
|
id: string;
|
|
71
72
|
name?: string;
|
|
72
73
|
};
|
|
73
|
-
payments?:
|
|
74
|
-
promotions?:
|
|
75
|
-
subscriptions?:
|
|
76
|
-
adjustments:
|
|
74
|
+
payments?: PaymentSummary[];
|
|
75
|
+
promotions?: PromotionSummary[];
|
|
76
|
+
subscriptions?: CoreSubscription[];
|
|
77
|
+
adjustments: OrderAdjustmentSummary[];
|
|
77
78
|
}
|
|
78
79
|
export interface Subscription {
|
|
79
80
|
id: string;
|
|
@@ -127,7 +128,7 @@ export declare class CustomerResource {
|
|
|
127
128
|
firstName?: string;
|
|
128
129
|
lastName?: string;
|
|
129
130
|
acceptsMarketing?: boolean;
|
|
130
|
-
metadata?: Record<string,
|
|
131
|
+
metadata?: Record<string, unknown>;
|
|
131
132
|
}): Promise<CustomerInfos>;
|
|
132
133
|
/**
|
|
133
134
|
* Get customer orders
|
|
@@ -31,14 +31,14 @@ export declare enum FunnelActionType {
|
|
|
31
31
|
* Data structures for specific action types
|
|
32
32
|
*/
|
|
33
33
|
export type NextAction<T> = T & {
|
|
34
|
-
[key: string]:
|
|
34
|
+
[key: string]: unknown;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Base resource data type - all resources must have an id and optional metadata
|
|
38
38
|
*/
|
|
39
39
|
export interface FunnelResourceData {
|
|
40
40
|
id: string;
|
|
41
|
-
[key: string]:
|
|
41
|
+
[key: string]: unknown;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Resource metadata for tracking, versioning, and relationships
|
|
@@ -57,7 +57,7 @@ export interface ResourceMetadata {
|
|
|
57
57
|
/** Related resource IDs (for relationships) */
|
|
58
58
|
relatedTo?: string[];
|
|
59
59
|
/** Custom metadata */
|
|
60
|
-
[key: string]:
|
|
60
|
+
[key: string]: unknown;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Wrapped resource with metadata
|
|
@@ -220,7 +220,7 @@ export interface FunnelActionResources<TCustom = {}> {
|
|
|
220
220
|
* Legacy top-level data (backward compatible)
|
|
221
221
|
* Will be automatically migrated to resources by orchestrator
|
|
222
222
|
*/
|
|
223
|
-
[key: string]:
|
|
223
|
+
[key: string]: unknown;
|
|
224
224
|
}
|
|
225
225
|
export interface DirectNavigationActionData extends FunnelActionResources {
|
|
226
226
|
targetStepId: string;
|
|
@@ -234,13 +234,13 @@ export interface PaymentSuccessActionData extends FunnelActionResources {
|
|
|
234
234
|
status: string;
|
|
235
235
|
transactionId?: string;
|
|
236
236
|
timestamp?: string;
|
|
237
|
-
[key: string]:
|
|
237
|
+
[key: string]: unknown;
|
|
238
238
|
};
|
|
239
239
|
order: {
|
|
240
240
|
id: string;
|
|
241
241
|
amount: number;
|
|
242
242
|
currency: string;
|
|
243
|
-
[key: string]:
|
|
243
|
+
[key: string]: unknown;
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
246
|
export interface PaymentFailedActionData extends FunnelActionResources {
|
|
@@ -248,21 +248,21 @@ export interface PaymentFailedActionData extends FunnelActionResources {
|
|
|
248
248
|
id: string;
|
|
249
249
|
status: string;
|
|
250
250
|
error?: string;
|
|
251
|
-
[key: string]:
|
|
251
|
+
[key: string]: unknown;
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
export interface OfferAcceptedActionData extends FunnelActionResources {
|
|
255
255
|
offer: {
|
|
256
256
|
accepted: boolean;
|
|
257
257
|
offerId?: string;
|
|
258
|
-
[key: string]:
|
|
258
|
+
[key: string]: unknown;
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
export interface OfferDeclinedActionData extends FunnelActionResources {
|
|
262
262
|
offer: {
|
|
263
263
|
declined: boolean;
|
|
264
264
|
offerId?: string;
|
|
265
|
-
[key: string]:
|
|
265
|
+
[key: string]: unknown;
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
export interface CartUpdatedActionData extends FunnelActionResources {
|
|
@@ -271,12 +271,12 @@ export interface CartUpdatedActionData extends FunnelActionResources {
|
|
|
271
271
|
itemIds?: string[];
|
|
272
272
|
variantIds?: string[];
|
|
273
273
|
total?: number;
|
|
274
|
-
[key: string]:
|
|
274
|
+
[key: string]: unknown;
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
277
|
export interface FormSubmitActionData extends FunnelActionResources {
|
|
278
278
|
form?: {
|
|
279
|
-
[key: string]:
|
|
279
|
+
[key: string]: unknown;
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
@@ -305,10 +305,10 @@ export type FunnelAction = BaseFunnelAction & (({
|
|
|
305
305
|
data: NextAction<BackNavigationActionData>;
|
|
306
306
|
}) | ({
|
|
307
307
|
type: FunnelActionType.CONTINUE_CLICKED;
|
|
308
|
-
data: NextAction<
|
|
308
|
+
data: NextAction<FunnelActionResources>;
|
|
309
309
|
}) | ({
|
|
310
310
|
type: FunnelActionType.BUTTON_CLICK;
|
|
311
|
-
data: NextAction<
|
|
311
|
+
data: NextAction<FunnelActionResources>;
|
|
312
312
|
}) | ({
|
|
313
313
|
type: FunnelActionType.FORM_SUBMIT;
|
|
314
314
|
data: NextAction<FormSubmitActionData>;
|
|
@@ -340,7 +340,7 @@ export type FunnelAction = BaseFunnelAction & (({
|
|
|
340
340
|
export interface FunnelNavigationAction {
|
|
341
341
|
type: 'redirect' | 'replace' | 'push' | 'external' | 'none';
|
|
342
342
|
url?: string;
|
|
343
|
-
data?:
|
|
343
|
+
data?: Record<string, unknown>;
|
|
344
344
|
}
|
|
345
345
|
export interface FunnelNavigationResult {
|
|
346
346
|
stepId?: string;
|
|
@@ -424,12 +424,12 @@ export interface SimpleFunnelContext<TCustom = {}> {
|
|
|
424
424
|
* - Available at runtime as context.static
|
|
425
425
|
* - Example: context.static.offer.id for statically configured offers
|
|
426
426
|
*/
|
|
427
|
-
static?: Record<string,
|
|
427
|
+
static?: Record<string, unknown>;
|
|
428
428
|
/**
|
|
429
429
|
* Legacy/Custom metadata
|
|
430
430
|
* For backward compatibility and flexible unstructured data
|
|
431
431
|
*/
|
|
432
|
-
metadata?: Record<string,
|
|
432
|
+
metadata?: Record<string, unknown>;
|
|
433
433
|
script?: string;
|
|
434
434
|
}
|
|
435
435
|
export interface FunnelInitializeRequest {
|
|
@@ -603,7 +603,7 @@ export declare class FunnelResource {
|
|
|
603
603
|
getSession(sessionId: string, currentUrl?: string, includeDebugData?: boolean): Promise<{
|
|
604
604
|
success: boolean;
|
|
605
605
|
context?: SimpleFunnelContext;
|
|
606
|
-
debugData?:
|
|
606
|
+
debugData?: Record<string, unknown>;
|
|
607
607
|
error?: string;
|
|
608
608
|
}>;
|
|
609
609
|
}
|