@tagadapay/plugin-sdk 3.1.11 → 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/README.md +1129 -1129
- package/build-cdn.js +231 -228
- 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 -102
- 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/react/hooks/useShippingRates.d.ts +6 -0
- package/dist/react/hooks/useShippingRates.js +38 -0
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/services/apiService.d.ts +21 -0
- package/dist/react/services/apiService.js +10 -0
- package/dist/tagada-sdk.js +2079 -179
- package/dist/tagada-sdk.min.js +4 -2
- package/dist/tagada-sdk.min.js.map +4 -4
- 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 +16 -15
- package/dist/v2/core/funnelClient.js +1 -1
- 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/resources/shippingRates.d.ts +15 -0
- package/dist/v2/core/resources/shippingRates.js +11 -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/order.d.ts +11 -9
- package/dist/v2/core/utils/previewModeIndicator.js +101 -101
- package/dist/v2/index.d.ts +4 -2
- package/dist/v2/index.js +1 -1
- package/dist/v2/react/components/ApplePayButton.js +13 -4
- package/dist/v2/react/components/FunnelScriptInjector.js +51 -30
- 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/useFunnel.d.ts +1 -2
- 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.js +82 -33
- 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 -43
- package/dist/v2/react/hooks/usePixelTracking.js +213 -407
- package/dist/v2/react/hooks/useShippingRatesQuery.d.ts +6 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +47 -4
- package/dist/v2/react/hooks/useStepConfig.d.ts +2 -8
- package/dist/v2/react/hooks/useStepConfig.js +1 -1
- 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 +76 -7
- 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 +125 -0
- package/package.json +112 -112
- 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
|
* 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
|
}
|
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
* Axios-based API client for payment endpoints
|
|
4
4
|
*/
|
|
5
5
|
import { ApiClient } from './apiClient';
|
|
6
|
+
import type { Order } from '../types';
|
|
6
7
|
export interface Payment {
|
|
7
8
|
id: string;
|
|
8
9
|
status: string;
|
|
9
10
|
subStatus: string;
|
|
10
|
-
requireAction: 'none' | 'redirect' | 'error' | 'radar';
|
|
11
|
+
requireAction: 'none' | 'redirect' | 'redirect_to_payment' | 'error' | 'radar';
|
|
11
12
|
requireActionData?: {
|
|
12
|
-
type: 'redirect' | 'threeds_auth' | 'processor_auth' | 'error' | 'stripe_radar' | 'finix_radar' | 'radar';
|
|
13
|
+
type: 'redirect' | 'redirect_to_payment' | 'threeds_auth' | 'processor_auth' | 'error' | 'stripe_radar' | 'finix_radar' | 'radar' | 'kesspay_auth' | 'trustflow_auth' | 'mastercard_auth';
|
|
13
14
|
url?: string;
|
|
14
15
|
processed: boolean;
|
|
15
16
|
processorId?: string;
|
|
16
17
|
metadata?: {
|
|
17
|
-
type: 'redirect' | 'stripe_radar' | 'finix_radar';
|
|
18
|
+
type: 'redirect' | 'redirect_to_payment' | 'stripe_radar' | 'finix_radar';
|
|
18
19
|
redirect?: {
|
|
19
20
|
redirectUrl: string;
|
|
20
21
|
returnUrl: string;
|
|
@@ -42,12 +43,15 @@ export interface Payment {
|
|
|
42
43
|
order?: {
|
|
43
44
|
id: string;
|
|
44
45
|
checkoutSessionId: string;
|
|
46
|
+
amount?: number;
|
|
47
|
+
currency?: string;
|
|
48
|
+
[key: string]: unknown;
|
|
45
49
|
};
|
|
46
50
|
}
|
|
47
51
|
export interface PaymentResponse {
|
|
48
52
|
paymentId: string;
|
|
49
53
|
payment: Payment;
|
|
50
|
-
order?:
|
|
54
|
+
order?: Order | null;
|
|
51
55
|
}
|
|
52
56
|
export interface PaymentInstrumentResponse {
|
|
53
57
|
id: string;
|
|
@@ -94,6 +98,16 @@ export interface PaymentOptions {
|
|
|
94
98
|
* If neither is set, the store's selectedPaymentFlowId will be used
|
|
95
99
|
*/
|
|
96
100
|
paymentFlowId?: string;
|
|
101
|
+
/**
|
|
102
|
+
* For alternative payment methods (APM)
|
|
103
|
+
* Processor ID to use for the payment
|
|
104
|
+
*/
|
|
105
|
+
processorId?: string;
|
|
106
|
+
/**
|
|
107
|
+
* For alternative payment methods (APM)
|
|
108
|
+
* Payment method type (e.g., 'klarna', 'afterpay', 'paypal')
|
|
109
|
+
*/
|
|
110
|
+
paymentMethod?: string;
|
|
97
111
|
/** @deprecated Use onPaymentSuccess instead - this will be removed in v3 */
|
|
98
112
|
onSuccess?: (response: PaymentResponse) => void;
|
|
99
113
|
/** @deprecated Use onPaymentFailed instead - this will be removed in v3 */
|
|
@@ -138,28 +152,83 @@ export interface ApplePayToken {
|
|
|
138
152
|
brand: string;
|
|
139
153
|
};
|
|
140
154
|
}
|
|
155
|
+
/** Token response from BasisTheory SDK */
|
|
156
|
+
export interface BasisTheoryTokenResponse {
|
|
157
|
+
id: string;
|
|
158
|
+
type: string;
|
|
159
|
+
enrichments?: {
|
|
160
|
+
cardDetails?: {
|
|
161
|
+
bin?: string;
|
|
162
|
+
last4?: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** External BasisTheory SDK instance shape (from @basis-theory/basis-theory-react) */
|
|
167
|
+
export interface BasisTheoryInstance {
|
|
168
|
+
tokens: {
|
|
169
|
+
create(data: Record<string, unknown>): Promise<BasisTheoryTokenResponse>;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export interface GooglePayToken {
|
|
173
|
+
id: string;
|
|
174
|
+
type: string;
|
|
175
|
+
card: {
|
|
176
|
+
bin: string;
|
|
177
|
+
last4: string;
|
|
178
|
+
expiration_month: number;
|
|
179
|
+
expiration_year: number;
|
|
180
|
+
brand: string;
|
|
181
|
+
};
|
|
182
|
+
details?: {
|
|
183
|
+
auth_method?: string;
|
|
184
|
+
[key: string]: unknown;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
export interface PaymentInstrumentInput {
|
|
188
|
+
type: string;
|
|
189
|
+
token?: string;
|
|
190
|
+
card?: {
|
|
191
|
+
maskedCardNumber?: string;
|
|
192
|
+
expirationMonth?: number;
|
|
193
|
+
expirationYear?: number;
|
|
194
|
+
bin?: string;
|
|
195
|
+
last4?: string;
|
|
196
|
+
brand?: string;
|
|
197
|
+
};
|
|
198
|
+
dpanType?: string;
|
|
199
|
+
authMethod?: string;
|
|
200
|
+
provider?: string;
|
|
201
|
+
paymentMethod?: string;
|
|
202
|
+
processorId?: string;
|
|
203
|
+
[key: string]: unknown;
|
|
204
|
+
}
|
|
141
205
|
export declare class PaymentsResource {
|
|
142
206
|
private apiClient;
|
|
143
207
|
constructor(apiClient: ApiClient);
|
|
144
208
|
/**
|
|
145
209
|
* Create payment instrument
|
|
146
210
|
*/
|
|
147
|
-
createPaymentInstrument(paymentInstrumentData:
|
|
211
|
+
createPaymentInstrument(paymentInstrumentData: PaymentInstrumentInput): Promise<PaymentInstrumentResponse>;
|
|
148
212
|
/**
|
|
149
213
|
* Create card payment instrument
|
|
150
214
|
*/
|
|
151
|
-
createCardPaymentInstrument(basisTheory:
|
|
152
|
-
cardData: CardPaymentMethod): Promise<PaymentInstrumentResponse>;
|
|
215
|
+
createCardPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, cardData: CardPaymentMethod): Promise<PaymentInstrumentResponse>;
|
|
153
216
|
/**
|
|
154
217
|
* Create Apple Pay payment instrument
|
|
155
218
|
*/
|
|
156
|
-
createApplePayPaymentInstrument(basisTheory:
|
|
157
|
-
applePayToken: ApplePayToken): Promise<PaymentInstrumentResponse>;
|
|
219
|
+
createApplePayPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, applePayToken: ApplePayToken): Promise<PaymentInstrumentResponse>;
|
|
158
220
|
/**
|
|
159
221
|
* Create Google Pay payment instrument
|
|
160
222
|
*/
|
|
161
|
-
createGooglePayPaymentInstrument(basisTheory:
|
|
162
|
-
|
|
223
|
+
createGooglePayPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, googlePayToken: GooglePayToken): Promise<PaymentInstrumentResponse>;
|
|
224
|
+
/**
|
|
225
|
+
* Create APM payment instrument (Klarna, Afterpay, PayPal, etc.)
|
|
226
|
+
*/
|
|
227
|
+
createApmPaymentInstrument(apmData: {
|
|
228
|
+
provider: string;
|
|
229
|
+
paymentMethod: string;
|
|
230
|
+
processorId: string;
|
|
231
|
+
}): Promise<PaymentInstrumentResponse>;
|
|
163
232
|
/**
|
|
164
233
|
* Helper function to format expiry date
|
|
165
234
|
*/
|
|
@@ -171,6 +240,8 @@ export declare class PaymentsResource {
|
|
|
171
240
|
initiatedBy?: 'customer' | 'merchant';
|
|
172
241
|
source?: 'upsell' | 'checkout' | 'offer' | 'missing_club' | 'forced';
|
|
173
242
|
paymentFlowId?: string;
|
|
243
|
+
processorId?: string;
|
|
244
|
+
paymentMethod?: string;
|
|
174
245
|
}): Promise<PaymentResponse>;
|
|
175
246
|
/**
|
|
176
247
|
* Get card payment instruments for customer
|
|
@@ -200,7 +271,7 @@ export declare class PaymentsResource {
|
|
|
200
271
|
transactionId?: string;
|
|
201
272
|
message?: string;
|
|
202
273
|
success?: boolean;
|
|
203
|
-
error?:
|
|
274
|
+
error?: string;
|
|
204
275
|
}>;
|
|
205
276
|
saveRadarSession(data: {
|
|
206
277
|
orderId?: string;
|
|
@@ -226,5 +297,5 @@ export declare class PaymentsResource {
|
|
|
226
297
|
paymentId: string;
|
|
227
298
|
status: 'succeeded' | 'failed' | 'pending';
|
|
228
299
|
paymentIntentId: string;
|
|
229
|
-
}): Promise<
|
|
300
|
+
}): Promise<Payment>;
|
|
230
301
|
}
|
|
@@ -17,8 +17,7 @@ export class PaymentsResource {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create card payment instrument
|
|
19
19
|
*/
|
|
20
|
-
async createCardPaymentInstrument(basisTheory,
|
|
21
|
-
cardData) {
|
|
20
|
+
async createCardPaymentInstrument(basisTheory, cardData) {
|
|
22
21
|
if (!basisTheory) {
|
|
23
22
|
throw new Error('Payment processor not initialized');
|
|
24
23
|
}
|
|
@@ -55,8 +54,7 @@ export class PaymentsResource {
|
|
|
55
54
|
/**
|
|
56
55
|
* Create Apple Pay payment instrument
|
|
57
56
|
*/
|
|
58
|
-
async createApplePayPaymentInstrument(basisTheory,
|
|
59
|
-
applePayToken) {
|
|
57
|
+
async createApplePayPaymentInstrument(basisTheory, applePayToken) {
|
|
60
58
|
if (!basisTheory) {
|
|
61
59
|
throw new Error('Payment processor not initialized');
|
|
62
60
|
}
|
|
@@ -81,9 +79,7 @@ export class PaymentsResource {
|
|
|
81
79
|
/**
|
|
82
80
|
* Create Google Pay payment instrument
|
|
83
81
|
*/
|
|
84
|
-
async createGooglePayPaymentInstrument(basisTheory,
|
|
85
|
-
googlePayToken // Token from Basis Theory Google Pay tokenization
|
|
86
|
-
) {
|
|
82
|
+
async createGooglePayPaymentInstrument(basisTheory, googlePayToken) {
|
|
87
83
|
if (!basisTheory) {
|
|
88
84
|
throw new Error('Payment processor not initialized');
|
|
89
85
|
}
|
|
@@ -106,6 +102,21 @@ export class PaymentsResource {
|
|
|
106
102
|
const response = await this.apiClient.post('/api/v1/payment/create-payment-instrument', { paymentInstrumentData });
|
|
107
103
|
return response;
|
|
108
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Create APM payment instrument (Klarna, Afterpay, PayPal, etc.)
|
|
107
|
+
*/
|
|
108
|
+
async createApmPaymentInstrument(apmData) {
|
|
109
|
+
console.log('Creating APM payment instrument:', apmData);
|
|
110
|
+
const paymentInstrumentData = {
|
|
111
|
+
type: 'apm',
|
|
112
|
+
provider: apmData.provider,
|
|
113
|
+
paymentMethod: apmData.paymentMethod,
|
|
114
|
+
processorId: apmData.processorId,
|
|
115
|
+
};
|
|
116
|
+
const response = await this.apiClient.post('/api/v1/payment/create-payment-instrument', { paymentInstrumentData });
|
|
117
|
+
console.log('APM payment instrument created:', response);
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
109
120
|
/**
|
|
110
121
|
* Helper function to format expiry date
|
|
111
122
|
*/
|
|
@@ -124,15 +135,21 @@ export class PaymentsResource {
|
|
|
124
135
|
*/
|
|
125
136
|
async processPaymentDirect(checkoutSessionId, paymentInstrumentId, threedsSessionId, options = {}) {
|
|
126
137
|
console.log('[PaymentsResource] processPaymentDirect START', options.paymentFlowId ? `(flow: ${options.paymentFlowId})` : '');
|
|
138
|
+
console.log('[PaymentsResource] Full options object:', JSON.stringify(options, null, 2));
|
|
139
|
+
console.log('[PaymentsResource] processorId:', options.processorId, 'paymentMethod:', options.paymentMethod);
|
|
127
140
|
try {
|
|
128
|
-
const
|
|
141
|
+
const requestBody = {
|
|
129
142
|
checkoutSessionId,
|
|
130
143
|
paymentInstrumentId,
|
|
131
144
|
...(threedsSessionId && { threedsSessionId }),
|
|
132
145
|
...(options.initiatedBy && { initiatedBy: options.initiatedBy }),
|
|
133
146
|
...(options.source && { source: options.source }),
|
|
134
147
|
...(options.paymentFlowId && { paymentFlowId: options.paymentFlowId }),
|
|
135
|
-
|
|
148
|
+
...(options.processorId && { processorId: options.processorId }),
|
|
149
|
+
...(options.paymentMethod && { paymentMethod: options.paymentMethod }),
|
|
150
|
+
};
|
|
151
|
+
console.log('[PaymentsResource] Request body being sent:', JSON.stringify(requestBody, null, 2));
|
|
152
|
+
const response = await this.apiClient.post('/api/public/v1/checkout/pay-v2', requestBody);
|
|
136
153
|
console.log('[PaymentsResource] processPaymentDirect SUCCESS:', response);
|
|
137
154
|
return response;
|
|
138
155
|
}
|
|
@@ -19,6 +19,16 @@ export interface ShippingRatesResponse {
|
|
|
19
19
|
rates: ShippingRate[];
|
|
20
20
|
forceCheckoutSessionRefetch?: boolean;
|
|
21
21
|
}
|
|
22
|
+
export interface ShippingRatesPreviewParams {
|
|
23
|
+
countryCode: string;
|
|
24
|
+
stateCode?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ShippingRatesPreviewResponse {
|
|
27
|
+
rates: ShippingRate[];
|
|
28
|
+
pickupPoint?: {
|
|
29
|
+
apiKey: string | null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
22
32
|
export declare class ShippingRatesResource {
|
|
23
33
|
private apiClient;
|
|
24
34
|
constructor(apiClient: ApiClient);
|
|
@@ -33,4 +43,9 @@ export declare class ShippingRatesResource {
|
|
|
33
43
|
success: boolean;
|
|
34
44
|
error?: any;
|
|
35
45
|
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Preview shipping rates for a country without updating session
|
|
48
|
+
* Useful for showing rates before user enters email
|
|
49
|
+
*/
|
|
50
|
+
previewShippingRates(sessionId: string, params: ShippingRatesPreviewParams): Promise<ShippingRatesPreviewResponse>;
|
|
36
51
|
}
|
|
@@ -20,4 +20,15 @@ export class ShippingRatesResource {
|
|
|
20
20
|
shippingRateId,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Preview shipping rates for a country without updating session
|
|
25
|
+
* Useful for showing rates before user enters email
|
|
26
|
+
*/
|
|
27
|
+
async previewShippingRates(sessionId, params) {
|
|
28
|
+
const queryParams = new URLSearchParams({ countryCode: params.countryCode });
|
|
29
|
+
if (params.stateCode) {
|
|
30
|
+
queryParams.set('stateCode', params.stateCode);
|
|
31
|
+
}
|
|
32
|
+
return this.apiClient.get(`/api/v1/checkout-sessions/${sessionId}/shipping-rates/preview?${queryParams.toString()}`);
|
|
33
|
+
}
|
|
23
34
|
}
|
package/dist/v2/core/types.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types for the Tagada Pay SDK Core
|
|
3
3
|
*/
|
|
4
|
+
export type DeepPartial<T> = {
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
6
|
+
};
|
|
4
7
|
export type Environment = 'production' | 'development' | 'local';
|
|
5
8
|
export interface ApiConfig {
|
|
6
9
|
baseUrl: string;
|
|
@@ -86,6 +89,40 @@ export interface PickupPoint {
|
|
|
86
89
|
opening_hours?: string;
|
|
87
90
|
extra_info?: string;
|
|
88
91
|
}
|
|
92
|
+
export interface Subscription {
|
|
93
|
+
id: string;
|
|
94
|
+
status: string;
|
|
95
|
+
planName?: string;
|
|
96
|
+
interval?: string;
|
|
97
|
+
intervalCount?: number;
|
|
98
|
+
currentPeriodEnd?: string;
|
|
99
|
+
currentPeriodStart?: string;
|
|
100
|
+
cancelAtPeriodEnd?: boolean;
|
|
101
|
+
trialEnd?: string | null;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|
|
104
|
+
export interface DeviceGeoData {
|
|
105
|
+
city?: string;
|
|
106
|
+
regionName?: string;
|
|
107
|
+
country?: string;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
export interface DeviceInfo {
|
|
111
|
+
userAgent?: string;
|
|
112
|
+
ip?: string;
|
|
113
|
+
country?: string;
|
|
114
|
+
browser?: string;
|
|
115
|
+
browserVersion?: string;
|
|
116
|
+
os?: string;
|
|
117
|
+
osVersion?: string;
|
|
118
|
+
geoData?: DeviceGeoData;
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}
|
|
121
|
+
export interface PromotionCode {
|
|
122
|
+
id: string;
|
|
123
|
+
code: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
89
126
|
export interface OrderItem {
|
|
90
127
|
id: string;
|
|
91
128
|
productId: string;
|
|
@@ -141,15 +178,16 @@ export interface Order {
|
|
|
141
178
|
paidAmount: number;
|
|
142
179
|
status: string;
|
|
143
180
|
createdAt: string;
|
|
144
|
-
metadata?: Record<string,
|
|
181
|
+
metadata?: Record<string, unknown>;
|
|
145
182
|
items: OrderItem[];
|
|
146
183
|
summaries?: OrderSummary[];
|
|
147
184
|
shippingAddress?: OrderAddress;
|
|
148
185
|
billingAddress?: OrderAddress;
|
|
149
|
-
pickupAddress?: PickupPoint;
|
|
186
|
+
pickupAddress?: PickupPoint | null;
|
|
187
|
+
customer?: Customer;
|
|
150
188
|
checkoutSession?: {
|
|
151
189
|
returnUrl?: string;
|
|
152
|
-
[key: string]:
|
|
190
|
+
[key: string]: unknown;
|
|
153
191
|
};
|
|
154
192
|
relatedOrders?: Order[];
|
|
155
193
|
}
|
|
@@ -161,7 +199,7 @@ export interface PaymentSummary {
|
|
|
161
199
|
createdAt: string;
|
|
162
200
|
updatedAt?: string;
|
|
163
201
|
provider?: string;
|
|
164
|
-
metadata?: Record<string,
|
|
202
|
+
metadata?: Record<string, unknown>;
|
|
165
203
|
}
|
|
166
204
|
export interface PromotionSummary {
|
|
167
205
|
id: string;
|
|
@@ -188,10 +226,10 @@ export interface OrderWithRelations extends Order {
|
|
|
188
226
|
checkoutSession?: {
|
|
189
227
|
id?: string;
|
|
190
228
|
returnUrl?: string;
|
|
191
|
-
[key: string]:
|
|
229
|
+
[key: string]: unknown;
|
|
192
230
|
};
|
|
193
231
|
promotions?: PromotionSummary[];
|
|
194
|
-
subscriptions?:
|
|
232
|
+
subscriptions?: Subscription[];
|
|
195
233
|
adjustments: OrderAdjustmentSummary[];
|
|
196
234
|
}
|
|
197
235
|
export interface CustomerAddress {
|
|
@@ -225,7 +263,7 @@ export interface CustomerOrderSummary {
|
|
|
225
263
|
externalOrderId: string | null;
|
|
226
264
|
billingAddress: CustomerAddress;
|
|
227
265
|
shippingAddress: Omit<CustomerAddress, 'email'>;
|
|
228
|
-
pickupAddress:
|
|
266
|
+
pickupAddress: PickupPoint | null;
|
|
229
267
|
taxesIncluded: boolean;
|
|
230
268
|
draft: boolean;
|
|
231
269
|
checkoutSessionId: string | null;
|
|
@@ -235,7 +273,7 @@ export interface CustomerOrderSummary {
|
|
|
235
273
|
paymentInstrumentId: string | null;
|
|
236
274
|
refundedAt: string | null;
|
|
237
275
|
refundedAmount: number | null;
|
|
238
|
-
metadata?: Record<string,
|
|
276
|
+
metadata?: Record<string, unknown>;
|
|
239
277
|
}
|
|
240
278
|
export interface CustomerInfos {
|
|
241
279
|
customer: {
|
|
@@ -255,12 +293,12 @@ export interface CustomerInfos {
|
|
|
255
293
|
acceptsMarketing: boolean;
|
|
256
294
|
createdAt: string;
|
|
257
295
|
updatedAt: string;
|
|
258
|
-
metadata: Record<string,
|
|
259
|
-
device:
|
|
296
|
+
metadata: Record<string, unknown>;
|
|
297
|
+
device: DeviceInfo | null;
|
|
260
298
|
orders: CustomerOrderSummary[];
|
|
261
|
-
subscriptions:
|
|
299
|
+
subscriptions: Subscription[];
|
|
262
300
|
};
|
|
263
|
-
promotionCodes:
|
|
301
|
+
promotionCodes: PromotionCode[];
|
|
264
302
|
}
|
|
265
303
|
export interface SessionInitResponse {
|
|
266
304
|
store: Store;
|
package/dist/v2/core/types.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Checkout Utility Functions
|
|
3
3
|
* Pure functions for checkout data manipulation
|
|
4
4
|
*/
|
|
5
|
-
import type { CheckoutData,
|
|
6
|
-
export type { CheckoutData,
|
|
5
|
+
import type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, Promotion } from '../resources/checkout';
|
|
6
|
+
export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, Promotion };
|
|
7
7
|
export declare class CheckoutUtils {
|
|
8
8
|
/**
|
|
9
9
|
* Get checkout session ID
|
|
@@ -13,13 +13,18 @@ export class CheckoutUtils {
|
|
|
13
13
|
* Get checkout line items
|
|
14
14
|
*/
|
|
15
15
|
static getLineItems(checkoutData) {
|
|
16
|
-
|
|
16
|
+
const lineItems = checkoutData.checkoutSession?.lineItems;
|
|
17
|
+
if (!Array.isArray(lineItems)) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return lineItems;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Get checkout total
|
|
20
24
|
*/
|
|
21
25
|
static getTotal(checkoutData) {
|
|
22
|
-
|
|
26
|
+
const totalPrice = checkoutData.checkoutSession?.totalPrice;
|
|
27
|
+
return typeof totalPrice === 'number' ? totalPrice : 0;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* Check if customer is club member
|