@tagadapay/plugin-sdk 3.1.12 → 3.1.22
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 +129 -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 +968 -101
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/tagada-sdk.js +12066 -0
- package/dist/tagada-sdk.min.js +50 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +4 -3
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +2 -0
- package/dist/v2/core/index.d.ts +1 -0
- package/dist/v2/core/index.js +2 -0
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +325 -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 +89 -30
- package/dist/v2/core/resources/checkout.js +8 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +84 -13
- package/dist/v2/core/resources/payments.js +26 -9
- 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/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/order.d.ts +11 -9
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +28 -0
- package/dist/v2/index.d.ts +3 -1
- package/dist/v2/index.js +1 -1
- package/dist/v2/react/components/FunnelScriptInjector.js +21 -0
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +231 -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 +13 -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/useCheckoutQuery.d.ts +6 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +45 -0
- package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
- package/dist/v2/react/hooks/useGeoLocation.js +4 -2
- package/dist/v2/react/hooks/useISOData.js +1 -1
- 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 +212 -514
- package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
- 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 +7 -0
- package/dist/v2/react/index.js +4 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +2 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +3 -1
- package/dist/v2/react/providers/TagadaProvider.js +71 -2
- 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 +22 -0
- package/dist/v2/standalone/index.js +126 -1
- package/package.json +3 -3
- 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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Shared between all resource clients
|
|
4
4
|
*/
|
|
5
5
|
import axios from 'axios';
|
|
6
|
+
import { TagadaApiError, TagadaAuthError, TagadaNetworkError, TagadaCircuitBreakerError, TagadaError, TagadaErrorCode, } from '../errors';
|
|
6
7
|
export class ApiClient {
|
|
7
8
|
constructor(config) {
|
|
8
9
|
this.currentToken = null;
|
|
@@ -61,12 +62,15 @@ export class ApiClient {
|
|
|
61
62
|
console.error('[SDK] Request error:', error);
|
|
62
63
|
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
63
64
|
});
|
|
64
|
-
// Response interceptor
|
|
65
|
-
this.axios.interceptors.response.use((response) => {
|
|
66
|
-
// console.log('[SDK] Response status:', response.status);
|
|
67
|
-
return response;
|
|
68
|
-
}, (error) => {
|
|
65
|
+
// Response interceptor — maps Axios errors to structured TagadaError subtypes
|
|
66
|
+
this.axios.interceptors.response.use((response) => response, (error) => {
|
|
69
67
|
console.error('[SDK] Response error:', error.message);
|
|
68
|
+
if (error instanceof TagadaError) {
|
|
69
|
+
return Promise.reject(error);
|
|
70
|
+
}
|
|
71
|
+
if (axios.isAxiosError(error)) {
|
|
72
|
+
return Promise.reject(this.toTagadaError(error));
|
|
73
|
+
}
|
|
70
74
|
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
71
75
|
});
|
|
72
76
|
}
|
|
@@ -146,10 +150,7 @@ export class ApiClient {
|
|
|
146
150
|
}
|
|
147
151
|
history.count++;
|
|
148
152
|
if (history.count > this.MAX_REQUESTS) {
|
|
149
|
-
|
|
150
|
-
// Add a property to identify this as a circuit breaker error
|
|
151
|
-
error.isCircuitBreaker = true;
|
|
152
|
-
throw error;
|
|
153
|
+
throw new TagadaCircuitBreakerError(`Circuit Breaker: Too many requests to ${key} (${history.count} in ${this.WINDOW_MS}ms)`);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
cleanupHistory() {
|
|
@@ -160,4 +161,46 @@ export class ApiClient {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
/** Convert an AxiosError into the appropriate TagadaError subclass. */
|
|
165
|
+
toTagadaError(error) {
|
|
166
|
+
const status = error.response?.status;
|
|
167
|
+
const data = error.response?.data;
|
|
168
|
+
const serverMessage = data?.message ??
|
|
169
|
+
data?.error ??
|
|
170
|
+
error.message;
|
|
171
|
+
// No response at all → network-level failure
|
|
172
|
+
if (!error.response) {
|
|
173
|
+
if (error.code === 'ECONNABORTED') {
|
|
174
|
+
return new TagadaApiError('Request timed out', 0, {
|
|
175
|
+
code: TagadaErrorCode.TIMEOUT,
|
|
176
|
+
retryable: true,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return new TagadaNetworkError(serverMessage);
|
|
180
|
+
}
|
|
181
|
+
// Auth failures
|
|
182
|
+
if (status === 401 || status === 403) {
|
|
183
|
+
return new TagadaAuthError(serverMessage, status);
|
|
184
|
+
}
|
|
185
|
+
// Rate-limited
|
|
186
|
+
if (status === 429) {
|
|
187
|
+
return new TagadaApiError(serverMessage, 429, {
|
|
188
|
+
code: TagadaErrorCode.RATE_LIMITED,
|
|
189
|
+
retryable: true,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// Not found
|
|
193
|
+
if (status === 404) {
|
|
194
|
+
return new TagadaApiError(serverMessage, 404, {
|
|
195
|
+
code: TagadaErrorCode.NOT_FOUND,
|
|
196
|
+
retryable: false,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// Generic API error
|
|
200
|
+
return new TagadaApiError(serverMessage, status ?? 0, {
|
|
201
|
+
code: data?.code ?? TagadaErrorCode.API_ERROR,
|
|
202
|
+
details: data,
|
|
203
|
+
retryable: (status ?? 0) >= 500,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
163
206
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
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';
|
|
6
7
|
export interface CheckoutLineItem {
|
|
7
8
|
externalProductId?: string | null;
|
|
@@ -91,7 +92,7 @@ export interface Store {
|
|
|
91
92
|
chargeCurrencies: string[];
|
|
92
93
|
upsells: Upsell[];
|
|
93
94
|
emailDomains: string[];
|
|
94
|
-
integrations:
|
|
95
|
+
integrations: unknown[];
|
|
95
96
|
}
|
|
96
97
|
export interface CheckoutSession {
|
|
97
98
|
id: string;
|
|
@@ -106,7 +107,56 @@ export interface CheckoutSession {
|
|
|
106
107
|
updatedAt: string;
|
|
107
108
|
lastActiveDate: string;
|
|
108
109
|
selectedPresentmentCurrency: string;
|
|
109
|
-
|
|
110
|
+
shippingRate?: {
|
|
111
|
+
id: string;
|
|
112
|
+
[key: string]: unknown;
|
|
113
|
+
} | null;
|
|
114
|
+
shippingRateId?: string;
|
|
115
|
+
sessionLineItems?: Array<{
|
|
116
|
+
isOrderBump?: boolean;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}>;
|
|
119
|
+
customer?: {
|
|
120
|
+
email?: string;
|
|
121
|
+
firstName?: string;
|
|
122
|
+
lastName?: string;
|
|
123
|
+
currency?: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
};
|
|
126
|
+
shippingAddress?: {
|
|
127
|
+
firstName?: string;
|
|
128
|
+
lastName?: string;
|
|
129
|
+
address1?: string;
|
|
130
|
+
address2?: string;
|
|
131
|
+
city?: string;
|
|
132
|
+
state?: string;
|
|
133
|
+
postal?: string;
|
|
134
|
+
country?: string;
|
|
135
|
+
phone?: string;
|
|
136
|
+
[key: string]: unknown;
|
|
137
|
+
};
|
|
138
|
+
billingAddress?: {
|
|
139
|
+
firstName?: string;
|
|
140
|
+
lastName?: string;
|
|
141
|
+
address1?: string;
|
|
142
|
+
address2?: string;
|
|
143
|
+
city?: string;
|
|
144
|
+
state?: string;
|
|
145
|
+
postal?: string;
|
|
146
|
+
country?: string;
|
|
147
|
+
phone?: string;
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
};
|
|
150
|
+
metadata?: {
|
|
151
|
+
cartCustomAttributes?: Array<{
|
|
152
|
+
name?: string;
|
|
153
|
+
value?: string;
|
|
154
|
+
[key: string]: unknown;
|
|
155
|
+
}>;
|
|
156
|
+
clubProductId?: string;
|
|
157
|
+
[key: string]: unknown;
|
|
158
|
+
};
|
|
159
|
+
[key: string]: unknown;
|
|
110
160
|
}
|
|
111
161
|
export interface CheckoutSummaryItem {
|
|
112
162
|
id: string;
|
|
@@ -129,7 +179,7 @@ export interface CheckoutSummaryItem {
|
|
|
129
179
|
amount: number;
|
|
130
180
|
adjustedAmount: number;
|
|
131
181
|
currency: string;
|
|
132
|
-
adjustments:
|
|
182
|
+
adjustments: CheckoutSessionPreviewAdjustment[];
|
|
133
183
|
recurring: boolean;
|
|
134
184
|
interval?: 'day' | 'week' | 'month' | 'year';
|
|
135
185
|
intervalCount?: number;
|
|
@@ -169,6 +219,7 @@ export interface CheckoutSummary {
|
|
|
169
219
|
}[];
|
|
170
220
|
}
|
|
171
221
|
export interface CheckoutSessionPreviewAdjustment {
|
|
222
|
+
id?: string;
|
|
172
223
|
type: 'Promotion' | 'Tax' | 'Shipping';
|
|
173
224
|
description: string;
|
|
174
225
|
level: 'Order' | 'LineItem';
|
|
@@ -205,7 +256,7 @@ export interface CheckoutSessionPreviewItem {
|
|
|
205
256
|
intervalCount?: number;
|
|
206
257
|
totalBillingCycles?: number;
|
|
207
258
|
unitAmountAfterFirstCycle?: number;
|
|
208
|
-
subscriptionSettings?:
|
|
259
|
+
subscriptionSettings?: Record<string, unknown>;
|
|
209
260
|
orderLineItemProduct: {
|
|
210
261
|
name: string | null;
|
|
211
262
|
} | null;
|
|
@@ -221,13 +272,22 @@ export interface CheckoutSessionPreview {
|
|
|
221
272
|
totalAdjustedAmount: number;
|
|
222
273
|
totalPromotionAmount: number;
|
|
223
274
|
}
|
|
275
|
+
export interface PromotionAction {
|
|
276
|
+
id: string;
|
|
277
|
+
adjustmentAmount?: Record<string, {
|
|
278
|
+
amount: number;
|
|
279
|
+
[key: string]: unknown;
|
|
280
|
+
}>;
|
|
281
|
+
adjustmentPercentage?: number;
|
|
282
|
+
[key: string]: unknown;
|
|
283
|
+
}
|
|
224
284
|
export interface Promotion {
|
|
225
285
|
id: string;
|
|
226
286
|
name: string;
|
|
227
287
|
description: string | null;
|
|
228
288
|
type: string;
|
|
229
|
-
rules:
|
|
230
|
-
actions:
|
|
289
|
+
rules: Record<string, unknown>[];
|
|
290
|
+
actions: PromotionAction[];
|
|
231
291
|
}
|
|
232
292
|
export interface CheckoutData {
|
|
233
293
|
checkoutSession: CheckoutSession;
|
|
@@ -236,14 +296,6 @@ export interface CheckoutData {
|
|
|
236
296
|
summary: CheckoutSummary;
|
|
237
297
|
availablePromotions: Promotion[];
|
|
238
298
|
}
|
|
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
299
|
export declare class CheckoutResource {
|
|
248
300
|
private apiClient;
|
|
249
301
|
constructor(apiClient: ApiClient);
|
|
@@ -300,9 +352,9 @@ export declare class CheckoutResource {
|
|
|
300
352
|
funnelVariantId?: string;
|
|
301
353
|
navigationEvent?: string | {
|
|
302
354
|
type: string;
|
|
303
|
-
data?:
|
|
355
|
+
data?: Record<string, unknown>;
|
|
304
356
|
};
|
|
305
|
-
navigationOptions?:
|
|
357
|
+
navigationOptions?: Record<string, unknown>;
|
|
306
358
|
}, getFunnelSessionId?: () => string | null | undefined): Promise<{
|
|
307
359
|
checkoutToken: string;
|
|
308
360
|
customerId: string;
|
|
@@ -338,8 +390,8 @@ export declare class CheckoutResource {
|
|
|
338
390
|
* Update checkout address
|
|
339
391
|
*/
|
|
340
392
|
updateAddress(checkoutSessionId: string, data: {
|
|
341
|
-
shippingAddress:
|
|
342
|
-
billingAddress?:
|
|
393
|
+
shippingAddress: Partial<OrderAddress>;
|
|
394
|
+
billingAddress?: Partial<OrderAddress>;
|
|
343
395
|
}): Promise<{
|
|
344
396
|
success: boolean;
|
|
345
397
|
errors?: Record<string, {
|
|
@@ -353,8 +405,8 @@ export declare class CheckoutResource {
|
|
|
353
405
|
* Set checkout info
|
|
354
406
|
*/
|
|
355
407
|
setCheckoutInfo(checkoutSessionId: string, data: {
|
|
356
|
-
shippingAddress:
|
|
357
|
-
billingAddress?:
|
|
408
|
+
shippingAddress: Partial<OrderAddress>;
|
|
409
|
+
billingAddress?: Partial<OrderAddress>;
|
|
358
410
|
differentBillingAddress?: boolean;
|
|
359
411
|
}): Promise<{
|
|
360
412
|
success: boolean;
|
|
@@ -370,32 +422,39 @@ export declare class CheckoutResource {
|
|
|
370
422
|
*/
|
|
371
423
|
applyPromotionCode(checkoutSessionId: string, code: string): Promise<{
|
|
372
424
|
success: boolean;
|
|
373
|
-
error?:
|
|
425
|
+
error?: string;
|
|
374
426
|
}>;
|
|
375
427
|
/**
|
|
376
428
|
* Remove promotion
|
|
377
429
|
*/
|
|
378
430
|
removePromotion(checkoutSessionId: string, promotionId: string): Promise<{
|
|
379
431
|
success: boolean;
|
|
380
|
-
error?:
|
|
432
|
+
error?: string;
|
|
381
433
|
}>;
|
|
382
434
|
/**
|
|
383
435
|
* Get applied promotions
|
|
384
436
|
*/
|
|
385
437
|
getAppliedPromotions(checkoutSessionId: string): Promise<Promotion[]>;
|
|
438
|
+
/**
|
|
439
|
+
* Replace all session line items (full rewrite)
|
|
440
|
+
*/
|
|
441
|
+
replaceSessionLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
442
|
+
success: boolean;
|
|
443
|
+
error?: string;
|
|
444
|
+
}>;
|
|
386
445
|
/**
|
|
387
446
|
* Update line items
|
|
388
447
|
*/
|
|
389
448
|
updateLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
390
449
|
success: boolean;
|
|
391
|
-
error?:
|
|
450
|
+
error?: string;
|
|
392
451
|
}>;
|
|
393
452
|
/**
|
|
394
453
|
* Add line items
|
|
395
454
|
*/
|
|
396
455
|
addLineItems(checkoutSessionId: string, lineItems: CheckoutLineItem[]): Promise<{
|
|
397
456
|
success: boolean;
|
|
398
|
-
error?:
|
|
457
|
+
error?: string;
|
|
399
458
|
}>;
|
|
400
459
|
/**
|
|
401
460
|
* Remove line items
|
|
@@ -405,21 +464,21 @@ export declare class CheckoutResource {
|
|
|
405
464
|
quantity?: number;
|
|
406
465
|
}[]): Promise<{
|
|
407
466
|
success: boolean;
|
|
408
|
-
error?:
|
|
467
|
+
error?: string;
|
|
409
468
|
}>;
|
|
410
469
|
/**
|
|
411
470
|
* Set item quantity
|
|
412
471
|
*/
|
|
413
472
|
setItemQuantity(checkoutSessionId: string, variantId: string, quantity: number, priceId?: string): Promise<{
|
|
414
473
|
success: boolean;
|
|
415
|
-
error?:
|
|
474
|
+
error?: string;
|
|
416
475
|
}>;
|
|
417
476
|
/**
|
|
418
477
|
* Toggle order bump
|
|
419
478
|
*/
|
|
420
479
|
toggleOrderBump(checkoutSessionId: string, orderBumpOfferId: string, selected: boolean): Promise<{
|
|
421
480
|
success: boolean;
|
|
422
|
-
error?:
|
|
481
|
+
error?: string;
|
|
423
482
|
}>;
|
|
424
483
|
/**
|
|
425
484
|
* Update customer
|
|
@@ -429,7 +488,7 @@ export declare class CheckoutResource {
|
|
|
429
488
|
acceptsMarketing?: boolean;
|
|
430
489
|
}): Promise<{
|
|
431
490
|
success: boolean;
|
|
432
|
-
error?:
|
|
491
|
+
error?: string;
|
|
433
492
|
}>;
|
|
434
493
|
/**
|
|
435
494
|
* Update customer and session info
|
|
@@ -439,8 +498,8 @@ export declare class CheckoutResource {
|
|
|
439
498
|
email: string;
|
|
440
499
|
acceptsMarketing?: boolean;
|
|
441
500
|
};
|
|
442
|
-
shippingAddress:
|
|
443
|
-
billingAddress?:
|
|
501
|
+
shippingAddress: Partial<OrderAddress>;
|
|
502
|
+
billingAddress?: Partial<OrderAddress>;
|
|
444
503
|
differentBillingAddress?: boolean;
|
|
445
504
|
}): Promise<{
|
|
446
505
|
success: boolean;
|
|
@@ -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
|
*/
|
|
@@ -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
|
}
|