@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.
Files changed (116) hide show
  1. package/README.md +1129 -1129
  2. package/build-cdn.js +231 -228
  3. package/dist/data/iso3166.d.ts +23 -33
  4. package/dist/data/iso3166.js +134 -198
  5. package/dist/data/languages.d.ts +5 -64
  6. package/dist/data/languages.js +23 -143
  7. package/dist/external-tracker.js +968 -102
  8. package/dist/external-tracker.min.js +2 -2
  9. package/dist/external-tracker.min.js.map +4 -4
  10. package/dist/react/hooks/useISOData.js +1 -1
  11. package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
  12. package/dist/react/hooks/useShippingRates.d.ts +6 -0
  13. package/dist/react/hooks/useShippingRates.js +38 -0
  14. package/dist/react/providers/TagadaProvider.js +5 -5
  15. package/dist/react/services/apiService.d.ts +21 -0
  16. package/dist/react/services/apiService.js +10 -0
  17. package/dist/tagada-sdk.js +2079 -179
  18. package/dist/tagada-sdk.min.js +4 -2
  19. package/dist/tagada-sdk.min.js.map +4 -4
  20. package/dist/v2/core/client.d.ts +4 -2
  21. package/dist/v2/core/client.js +4 -3
  22. package/dist/v2/core/errors.d.ts +75 -0
  23. package/dist/v2/core/errors.js +104 -0
  24. package/dist/v2/core/funnelClient.d.ts +16 -15
  25. package/dist/v2/core/funnelClient.js +1 -1
  26. package/dist/v2/core/index.d.ts +1 -0
  27. package/dist/v2/core/index.js +2 -0
  28. package/dist/v2/core/pixelMapping.d.ts +49 -0
  29. package/dist/v2/core/pixelMapping.js +325 -0
  30. package/dist/v2/core/resources/apiClient.d.ts +2 -0
  31. package/dist/v2/core/resources/apiClient.js +52 -9
  32. package/dist/v2/core/resources/checkout.d.ts +89 -30
  33. package/dist/v2/core/resources/checkout.js +8 -0
  34. package/dist/v2/core/resources/customer.d.ts +20 -19
  35. package/dist/v2/core/resources/funnel.d.ts +17 -17
  36. package/dist/v2/core/resources/payments.d.ts +84 -13
  37. package/dist/v2/core/resources/payments.js +26 -9
  38. package/dist/v2/core/resources/shippingRates.d.ts +15 -0
  39. package/dist/v2/core/resources/shippingRates.js +11 -0
  40. package/dist/v2/core/types.d.ts +50 -12
  41. package/dist/v2/core/types.js +0 -3
  42. package/dist/v2/core/utils/checkout.d.ts +2 -2
  43. package/dist/v2/core/utils/checkout.js +7 -2
  44. package/dist/v2/core/utils/order.d.ts +11 -9
  45. package/dist/v2/core/utils/previewModeIndicator.js +101 -101
  46. package/dist/v2/index.d.ts +4 -2
  47. package/dist/v2/index.js +1 -1
  48. package/dist/v2/react/components/ApplePayButton.js +13 -4
  49. package/dist/v2/react/components/FunnelScriptInjector.js +51 -30
  50. package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
  51. package/dist/v2/react/components/WhopCheckout.js +231 -0
  52. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
  53. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
  54. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
  55. package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
  56. package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
  57. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
  58. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
  59. package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
  60. package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
  61. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
  62. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
  63. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
  64. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
  65. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
  66. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +13 -0
  67. package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
  68. package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
  69. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
  70. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
  71. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
  72. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
  73. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
  74. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
  75. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
  76. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
  77. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
  78. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
  79. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
  80. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
  81. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
  82. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
  83. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +6 -0
  84. package/dist/v2/react/hooks/useCheckoutQuery.js +45 -0
  85. package/dist/v2/react/hooks/useFunnel.d.ts +1 -2
  86. package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
  87. package/dist/v2/react/hooks/useGeoLocation.js +4 -2
  88. package/dist/v2/react/hooks/useGoogleAutocomplete.js +82 -33
  89. package/dist/v2/react/hooks/useISOData.js +1 -1
  90. package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
  91. package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
  92. package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
  93. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
  94. package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
  95. package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -43
  96. package/dist/v2/react/hooks/usePixelTracking.js +213 -407
  97. package/dist/v2/react/hooks/useShippingRatesQuery.d.ts +6 -0
  98. package/dist/v2/react/hooks/useShippingRatesQuery.js +47 -4
  99. package/dist/v2/react/hooks/useStepConfig.d.ts +2 -8
  100. package/dist/v2/react/hooks/useStepConfig.js +1 -1
  101. package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
  102. package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
  103. package/dist/v2/react/index.d.ts +7 -0
  104. package/dist/v2/react/index.js +4 -0
  105. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +2 -1
  106. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +3 -1
  107. package/dist/v2/react/providers/TagadaProvider.js +76 -7
  108. package/dist/v2/standalone/external-tracker.d.ts +52 -46
  109. package/dist/v2/standalone/external-tracker.js +205 -98
  110. package/dist/v2/standalone/index.d.ts +22 -0
  111. package/dist/v2/standalone/index.js +125 -0
  112. package/package.json +112 -112
  113. package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
  114. package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
  115. package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
  116. 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, any>;
44
- device: any | null;
44
+ metadata: Record<string, unknown>;
45
+ device: DeviceInfo | null;
45
46
  orders: CustomerOrderSummary[];
46
- subscriptions: any[];
47
+ subscriptions: CoreSubscription[];
47
48
  };
48
- promotionCodes: any[];
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, any>;
57
- items: any[];
58
- summaries?: any[];
59
- shippingAddress?: any;
60
- billingAddress?: any;
61
- pickupAddress?: any;
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]: any;
65
+ [key: string]: unknown;
65
66
  };
66
- relatedOrders?: any[];
67
- customer?: any;
68
- store?: any;
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?: any[];
74
- promotions?: any[];
75
- subscriptions?: any[];
76
- adjustments: any[];
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, any>;
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]: any;
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]: any;
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]: any;
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]: any;
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]: any;
237
+ [key: string]: unknown;
238
238
  };
239
239
  order: {
240
240
  id: string;
241
241
  amount: number;
242
242
  currency: string;
243
- [key: string]: any;
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]: any;
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]: any;
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]: any;
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]: any;
274
+ [key: string]: unknown;
275
275
  };
276
276
  }
277
277
  export interface FormSubmitActionData extends FunnelActionResources {
278
278
  form?: {
279
- [key: string]: any;
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<any>;
308
+ data: NextAction<FunnelActionResources>;
309
309
  }) | ({
310
310
  type: FunnelActionType.BUTTON_CLICK;
311
- data: NextAction<any>;
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?: any;
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, any>;
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, any>;
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?: any;
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?: any;
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: any): Promise<PaymentInstrumentResponse>;
211
+ createPaymentInstrument(paymentInstrumentData: PaymentInstrumentInput): Promise<PaymentInstrumentResponse>;
148
212
  /**
149
213
  * Create card payment instrument
150
214
  */
151
- createCardPaymentInstrument(basisTheory: any, // BasisTheory instance from @basis-theory/basis-theory-react
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: any, // BasisTheory instance from @basis-theory/basis-theory-react
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: any, // BasisTheory instance from @basis-theory/basis-theory-react
162
- googlePayToken: any): Promise<PaymentInstrumentResponse>;
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?: any;
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<any>;
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, // BasisTheory instance from @basis-theory/basis-theory-react
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, // BasisTheory instance from @basis-theory/basis-theory-react
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, // BasisTheory instance from @basis-theory/basis-theory-react
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 response = await this.apiClient.post('/api/public/v1/checkout/pay-v2', {
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
  }
@@ -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, any>;
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]: any;
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, any>;
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]: any;
229
+ [key: string]: unknown;
192
230
  };
193
231
  promotions?: PromotionSummary[];
194
- subscriptions?: any[];
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: any | null;
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, any>;
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, any>;
259
- device: any | null;
296
+ metadata: Record<string, unknown>;
297
+ device: DeviceInfo | null;
260
298
  orders: CustomerOrderSummary[];
261
- subscriptions: any[];
299
+ subscriptions: Subscription[];
262
300
  };
263
- promotionCodes: any[];
301
+ promotionCodes: PromotionCode[];
264
302
  }
265
303
  export interface SessionInitResponse {
266
304
  store: Store;
@@ -1,4 +1 @@
1
- /**
2
- * Types for the Tagada Pay SDK Core
3
- */
4
1
  export {};
@@ -2,8 +2,8 @@
2
2
  * Checkout Utility Functions
3
3
  * Pure functions for checkout data manipulation
4
4
  */
5
- import type { CheckoutData, CheckoutSession, CheckoutLineItem, CheckoutInitParams, Promotion } from '../resources/checkout';
6
- export type { CheckoutData, CheckoutSession, CheckoutLineItem, CheckoutInitParams, Promotion, };
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
- return checkoutData.checkoutSession?.lineItems || [];
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
- return checkoutData.checkoutSession?.totalPrice || 0;
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