@tagadapay/plugin-sdk 3.1.12 → 3.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/build-cdn.js +397 -11
  2. package/dist/data/iso3166.d.ts +23 -33
  3. package/dist/data/iso3166.js +134 -198
  4. package/dist/data/languages.d.ts +5 -64
  5. package/dist/data/languages.js +23 -143
  6. package/dist/external-tracker.js +623 -3426
  7. package/dist/external-tracker.min.js +2 -25
  8. package/dist/external-tracker.min.js.map +4 -4
  9. package/dist/react/config/payment.d.ts +14 -4
  10. package/dist/react/config/payment.js +47 -9
  11. package/dist/react/hooks/useCheckout.d.ts +3 -0
  12. package/dist/react/hooks/useCheckout.js +4 -1
  13. package/dist/react/hooks/useISOData.js +1 -1
  14. package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
  15. package/dist/react/hooks/usePluginConfig.js +9 -10
  16. package/dist/react/providers/TagadaProvider.js +1 -1
  17. package/dist/tagada-react-sdk-minimal.min.js +36 -0
  18. package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
  19. package/dist/tagada-react-sdk.js +37821 -0
  20. package/dist/tagada-react-sdk.min.js +78 -0
  21. package/dist/tagada-react-sdk.min.js.map +7 -0
  22. package/dist/tagada-sdk.js +16044 -0
  23. package/dist/tagada-sdk.min.js +32 -0
  24. package/dist/tagada-sdk.min.js.map +7 -0
  25. package/dist/v2/cdn-react-minimal.d.ts +23 -0
  26. package/dist/v2/cdn-react-minimal.js +26 -0
  27. package/dist/v2/core/client.d.ts +4 -2
  28. package/dist/v2/core/client.js +5 -4
  29. package/dist/v2/core/config/environment.js +2 -1
  30. package/dist/v2/core/errors.d.ts +75 -0
  31. package/dist/v2/core/errors.js +104 -0
  32. package/dist/v2/core/funnelClient.d.ts +100 -10
  33. package/dist/v2/core/funnelClient.js +121 -27
  34. package/dist/v2/core/isoData.d.ts +4 -4
  35. package/dist/v2/core/isoData.js +7 -7
  36. package/dist/v2/core/pixelMapping.d.ts +49 -0
  37. package/dist/v2/core/pixelMapping.js +363 -0
  38. package/dist/v2/core/resources/apiClient.d.ts +2 -0
  39. package/dist/v2/core/resources/apiClient.js +52 -9
  40. package/dist/v2/core/resources/checkout.d.ts +99 -30
  41. package/dist/v2/core/resources/checkout.js +14 -0
  42. package/dist/v2/core/resources/customer.d.ts +20 -19
  43. package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
  44. package/dist/v2/core/resources/funnel.d.ts +17 -17
  45. package/dist/v2/core/resources/payments.d.ts +89 -13
  46. package/dist/v2/core/resources/payments.js +27 -9
  47. package/dist/v2/core/resources/postPurchases.d.ts +17 -0
  48. package/dist/v2/core/resources/postPurchases.js +20 -0
  49. package/dist/v2/core/types.d.ts +50 -12
  50. package/dist/v2/core/types.js +0 -3
  51. package/dist/v2/core/utils/checkout.d.ts +2 -2
  52. package/dist/v2/core/utils/checkout.js +7 -2
  53. package/dist/v2/core/utils/currency.d.ts +14 -0
  54. package/dist/v2/core/utils/currency.js +40 -0
  55. package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
  56. package/dist/v2/core/utils/deviceInfo.js +152 -76
  57. package/dist/v2/core/utils/index.d.ts +1 -0
  58. package/dist/v2/core/utils/index.js +2 -0
  59. package/dist/v2/core/utils/order.d.ts +13 -9
  60. package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
  61. package/dist/v2/core/utils/pluginConfig.js +36 -12
  62. package/dist/v2/index.d.ts +6 -3
  63. package/dist/v2/index.js +4 -2
  64. package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
  65. package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
  66. package/dist/v2/react/components/StripeExpressButton.js +171 -0
  67. package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
  68. package/dist/v2/react/components/WhopCheckout.js +237 -0
  69. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
  70. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
  71. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
  72. package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
  73. package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
  74. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
  75. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
  76. package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
  77. package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
  78. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
  79. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
  80. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
  81. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
  82. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
  83. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
  84. package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
  85. package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
  86. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
  87. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
  88. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
  89. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
  90. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
  91. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
  92. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
  93. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
  94. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
  95. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
  96. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
  97. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
  98. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
  99. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
  100. package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
  101. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
  102. package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
  103. package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
  104. package/dist/v2/react/hooks/useFunnel.js +8 -4
  105. package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
  106. package/dist/v2/react/hooks/useGeoLocation.js +4 -2
  107. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
  108. package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
  109. package/dist/v2/react/hooks/useISOData.d.ts +2 -5
  110. package/dist/v2/react/hooks/useISOData.js +26 -27
  111. package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
  112. package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
  113. package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
  114. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
  115. package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
  116. package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
  117. package/dist/v2/react/hooks/usePixelTracking.js +283 -504
  118. package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
  119. package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
  120. package/dist/v2/react/hooks/useRemappableParams.js +23 -23
  121. package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
  122. package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
  123. package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
  124. package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
  125. package/dist/v2/react/hooks/useStepConfig.js +14 -7
  126. package/dist/v2/react/hooks/useTranslation.js +23 -8
  127. package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
  128. package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
  129. package/dist/v2/react/index.d.ts +15 -1
  130. package/dist/v2/react/index.js +7 -0
  131. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
  132. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
  133. package/dist/v2/react/providers/TagadaProvider.js +74 -5
  134. package/dist/v2/standalone/external-tracker.d.ts +52 -46
  135. package/dist/v2/standalone/external-tracker.js +205 -98
  136. package/dist/v2/standalone/index.d.ts +40 -0
  137. package/dist/v2/standalone/index.js +148 -1
  138. package/dist/v2/standalone/payment-service.d.ts +134 -0
  139. package/dist/v2/standalone/payment-service.js +928 -0
  140. package/package.json +6 -4
  141. package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
  142. package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
  143. package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
  144. package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Minimal React SDK for CDN
3
+ *
4
+ * This is a slim bundle for use with TagadaStudio's esbuild mode.
5
+ * Only includes essential hooks needed for checkout pages.
6
+ *
7
+ * Full SDK is much larger due to TanStack Query, ISO data, etc.
8
+ * This minimal version keeps the bundle small (~100KB vs ~9MB).
9
+ */
10
+ export { TagadaProvider, useTagadaContext } from './react/providers/TagadaProvider';
11
+ export { useCheckoutQuery as useCheckout } from './react/hooks/useCheckoutQuery';
12
+ export { useShippingRatesQuery as useShippingRates } from './react/hooks/useShippingRatesQuery';
13
+ export { useDiscountsQuery as useDiscounts } from './react/hooks/useDiscountsQuery';
14
+ export { useOrderBumpQuery as useOrderBump } from './react/hooks/useOrderBumpQuery';
15
+ export { useOrderQuery as useOrder } from './react/hooks/useOrderQuery';
16
+ export { usePostPurchasesQuery as usePostPurchases } from './react/hooks/usePostPurchasesQuery';
17
+ export { usePaymentQuery as usePayment } from './react/hooks/usePaymentQuery';
18
+ export { useThreeds } from './react/hooks/useThreeds';
19
+ export { useCurrency } from './react/hooks/useCurrency';
20
+ export { usePluginConfig } from './react/hooks/usePluginConfig';
21
+ export { useFunnel } from './react/hooks/useFunnel';
22
+ export { formatMoney } from './core/utils/currency';
23
+ export type { FunnelContextValue } from './react/hooks/useFunnel';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Minimal React SDK for CDN
3
+ *
4
+ * This is a slim bundle for use with TagadaStudio's esbuild mode.
5
+ * Only includes essential hooks needed for checkout pages.
6
+ *
7
+ * Full SDK is much larger due to TanStack Query, ISO data, etc.
8
+ * This minimal version keeps the bundle small (~100KB vs ~9MB).
9
+ */
10
+ // Provider (essential)
11
+ export { TagadaProvider, useTagadaContext } from './react/providers/TagadaProvider';
12
+ // Core checkout hooks (essential for commerce)
13
+ export { useCheckoutQuery as useCheckout } from './react/hooks/useCheckoutQuery';
14
+ export { useShippingRatesQuery as useShippingRates } from './react/hooks/useShippingRatesQuery';
15
+ export { useDiscountsQuery as useDiscounts } from './react/hooks/useDiscountsQuery';
16
+ export { useOrderBumpQuery as useOrderBump } from './react/hooks/useOrderBumpQuery';
17
+ export { useOrderQuery as useOrder } from './react/hooks/useOrderQuery';
18
+ export { usePostPurchasesQuery as usePostPurchases } from './react/hooks/usePostPurchasesQuery';
19
+ export { usePaymentQuery as usePayment } from './react/hooks/usePaymentQuery';
20
+ export { useThreeds } from './react/hooks/useThreeds';
21
+ // Utility hooks (commonly used)
22
+ export { useCurrency } from './react/hooks/useCurrency';
23
+ export { usePluginConfig } from './react/hooks/usePluginConfig';
24
+ export { useFunnel } from './react/hooks/useFunnel';
25
+ // Essential utilities
26
+ export { formatMoney } from './core/utils/currency';
@@ -1,11 +1,11 @@
1
1
  import { FunnelClient } from './funnelClient';
2
2
  import { ApiClient } from './resources/apiClient';
3
- import { AuthState, Currency, Customer, Environment, EnvironmentConfig, Locale, Session, Store } from './types';
3
+ import { AuthState, Currency, Customer, DeepPartial, Environment, EnvironmentConfig, Locale, Session, Store } from './types';
4
4
  import { EventBus } from './utils/eventBus';
5
5
  import { PluginConfig, RawPluginConfig } from './utils/pluginConfig';
6
6
  export interface TagadaClientConfig {
7
7
  environment?: Environment;
8
- customApiConfig?: Partial<EnvironmentConfig>;
8
+ customApiConfig?: DeepPartial<EnvironmentConfig>;
9
9
  debugMode?: boolean;
10
10
  localConfig?: string;
11
11
  rawPluginConfig?: RawPluginConfig;
@@ -22,6 +22,8 @@ export interface TagadaClientConfig {
22
22
  */
23
23
  funnel?: boolean | {
24
24
  autoRedirect?: boolean;
25
+ /** Skip automatic funnel initialization (use when caller handles init explicitly) */
26
+ skipAutoInit?: boolean;
25
27
  };
26
28
  };
27
29
  }
@@ -506,7 +506,7 @@ export class TagadaClient {
506
506
  if (this.state.debugMode) {
507
507
  console.log(`[TagadaClient ${this.instanceId}] Initializing session...`, { sessionId: sessionData.sessionId });
508
508
  }
509
- const deviceInfo = collectDeviceInfo();
509
+ const deviceInfo = await collectDeviceInfo();
510
510
  const urlParams = getUrlParams();
511
511
  const browserLocale = getBrowserLocale();
512
512
  // 🎯 Check draft mode from URL, localStorage, or cookie
@@ -620,9 +620,10 @@ export class TagadaClient {
620
620
  customer: response.customer ?? null,
621
621
  auth: authState
622
622
  });
623
- // Auto-initialize funnel if enabled
624
- // This runs after we have all required data: auth.session, store, accountId
625
- if (this.funnel && sessionData.customerId && response.store?.id) {
623
+ // Auto-initialize funnel if enabled (skip when caller handles init explicitly)
624
+ const funnelFeature = this.config.features?.funnel;
625
+ const skipAutoInit = typeof funnelFeature === 'object' && funnelFeature.skipAutoInit;
626
+ if (this.funnel && !skipAutoInit && sessionData.customerId && response.store?.id) {
626
627
  const accountId = response.store.accountId || this.state.pluginConfig?.accountId || sessionData.accountId || '';
627
628
  if (accountId) {
628
629
  // Get funnelId from URL or config
@@ -199,7 +199,8 @@ export function detectEnvironment() {
199
199
  hostname.includes('ngrok-free.dev') ||
200
200
  hostname.includes('ngrok-free.app') ||
201
201
  hostname.includes('ngrok.io') ||
202
- hostname.includes('ngrok.app')) {
202
+ hostname.includes('ngrok.app') ||
203
+ hostname.includes('.loclx.io')) {
203
204
  console.log('[SDK] detectEnvironment() - returning LOCAL');
204
205
  // For local development, allow override via window.__TAGADA_ENV__ (injected by dev server)
205
206
  if (typeof window !== 'undefined' && window?.__TAGADA_ENV__?.TAGADA_ENVIRONMENT) {
@@ -0,0 +1,75 @@
1
+ /**
2
+ * TagadaPay SDK Error Types
3
+ *
4
+ * Structured error hierarchy for programmatic error handling.
5
+ * All SDK errors extend TagadaError, which extends native Error.
6
+ */
7
+ export declare const TagadaErrorCode: {
8
+ readonly NETWORK_ERROR: "network_error";
9
+ readonly API_ERROR: "api_error";
10
+ readonly AUTH_REQUIRED: "auth_required";
11
+ readonly TOKEN_EXPIRED: "token_expired";
12
+ readonly NOT_FOUND: "not_found";
13
+ readonly VALIDATION_ERROR: "validation_error";
14
+ readonly CIRCUIT_BREAKER: "circuit_breaker";
15
+ readonly PAYMENT_FAILED: "payment_failed";
16
+ readonly CARD_DECLINED: "card_declined";
17
+ readonly SESSION_EXPIRED: "session_expired";
18
+ readonly RATE_LIMITED: "rate_limited";
19
+ readonly TIMEOUT: "timeout";
20
+ readonly UNKNOWN: "unknown";
21
+ };
22
+ export type TagadaErrorCodeValue = typeof TagadaErrorCode[keyof typeof TagadaErrorCode];
23
+ export interface TagadaErrorOptions {
24
+ code: TagadaErrorCodeValue | string;
25
+ statusCode?: number;
26
+ retryable?: boolean;
27
+ details?: Record<string, unknown>;
28
+ }
29
+ /**
30
+ * Base error class for all TagadaPay SDK errors.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * try {
35
+ * await checkout.applyPromotionCode(sessionId, 'SAVE10');
36
+ * } catch (err) {
37
+ * if (err instanceof TagadaError) {
38
+ * console.log(err.code); // 'not_found'
39
+ * console.log(err.statusCode); // 404
40
+ * console.log(err.retryable); // false
41
+ * }
42
+ * }
43
+ * ```
44
+ */
45
+ export declare class TagadaError extends Error {
46
+ readonly code: string;
47
+ readonly statusCode?: number;
48
+ readonly retryable: boolean;
49
+ readonly details?: Record<string, unknown>;
50
+ constructor(message: string, options: TagadaErrorOptions);
51
+ }
52
+ /** API returned a non-2xx response with an error body. */
53
+ export declare class TagadaApiError extends TagadaError {
54
+ constructor(message: string, statusCode: number, options?: {
55
+ code?: string;
56
+ details?: Record<string, unknown>;
57
+ retryable?: boolean;
58
+ });
59
+ }
60
+ /** Network-level failure (no response received). */
61
+ export declare class TagadaNetworkError extends TagadaError {
62
+ constructor(message?: string);
63
+ }
64
+ /** 401/403 — authentication or authorization failure. */
65
+ export declare class TagadaAuthError extends TagadaError {
66
+ constructor(message?: string, statusCode?: number);
67
+ }
68
+ /** Input validation failed (client-side or 400 from server). */
69
+ export declare class TagadaValidationError extends TagadaError {
70
+ constructor(message: string, details?: Record<string, unknown>);
71
+ }
72
+ /** Circuit breaker tripped — too many requests in a short window. */
73
+ export declare class TagadaCircuitBreakerError extends TagadaError {
74
+ constructor(message: string);
75
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * TagadaPay SDK Error Types
3
+ *
4
+ * Structured error hierarchy for programmatic error handling.
5
+ * All SDK errors extend TagadaError, which extends native Error.
6
+ */
7
+ export const TagadaErrorCode = {
8
+ NETWORK_ERROR: 'network_error',
9
+ API_ERROR: 'api_error',
10
+ AUTH_REQUIRED: 'auth_required',
11
+ TOKEN_EXPIRED: 'token_expired',
12
+ NOT_FOUND: 'not_found',
13
+ VALIDATION_ERROR: 'validation_error',
14
+ CIRCUIT_BREAKER: 'circuit_breaker',
15
+ PAYMENT_FAILED: 'payment_failed',
16
+ CARD_DECLINED: 'card_declined',
17
+ SESSION_EXPIRED: 'session_expired',
18
+ RATE_LIMITED: 'rate_limited',
19
+ TIMEOUT: 'timeout',
20
+ UNKNOWN: 'unknown',
21
+ };
22
+ /**
23
+ * Base error class for all TagadaPay SDK errors.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * try {
28
+ * await checkout.applyPromotionCode(sessionId, 'SAVE10');
29
+ * } catch (err) {
30
+ * if (err instanceof TagadaError) {
31
+ * console.log(err.code); // 'not_found'
32
+ * console.log(err.statusCode); // 404
33
+ * console.log(err.retryable); // false
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ export class TagadaError extends Error {
39
+ constructor(message, options) {
40
+ super(message);
41
+ this.name = 'TagadaError';
42
+ this.code = options.code;
43
+ this.statusCode = options.statusCode;
44
+ this.retryable = options.retryable ?? false;
45
+ this.details = options.details;
46
+ // Maintain proper prototype chain for instanceof checks
47
+ Object.setPrototypeOf(this, new.target.prototype);
48
+ }
49
+ }
50
+ /** API returned a non-2xx response with an error body. */
51
+ export class TagadaApiError extends TagadaError {
52
+ constructor(message, statusCode, options) {
53
+ super(message, {
54
+ code: options?.code ?? TagadaErrorCode.API_ERROR,
55
+ statusCode,
56
+ retryable: options?.retryable ?? (statusCode >= 500),
57
+ details: options?.details,
58
+ });
59
+ this.name = 'TagadaApiError';
60
+ }
61
+ }
62
+ /** Network-level failure (no response received). */
63
+ export class TagadaNetworkError extends TagadaError {
64
+ constructor(message = 'Network request failed') {
65
+ super(message, {
66
+ code: TagadaErrorCode.NETWORK_ERROR,
67
+ retryable: true,
68
+ });
69
+ this.name = 'TagadaNetworkError';
70
+ }
71
+ }
72
+ /** 401/403 — authentication or authorization failure. */
73
+ export class TagadaAuthError extends TagadaError {
74
+ constructor(message = 'Authentication required', statusCode = 401) {
75
+ super(message, {
76
+ code: TagadaErrorCode.AUTH_REQUIRED,
77
+ statusCode,
78
+ retryable: false,
79
+ });
80
+ this.name = 'TagadaAuthError';
81
+ }
82
+ }
83
+ /** Input validation failed (client-side or 400 from server). */
84
+ export class TagadaValidationError extends TagadaError {
85
+ constructor(message, details) {
86
+ super(message, {
87
+ code: TagadaErrorCode.VALIDATION_ERROR,
88
+ statusCode: 400,
89
+ retryable: false,
90
+ details,
91
+ });
92
+ this.name = 'TagadaValidationError';
93
+ }
94
+ }
95
+ /** Circuit breaker tripped — too many requests in a short window. */
96
+ export class TagadaCircuitBreakerError extends TagadaError {
97
+ constructor(message) {
98
+ super(message, {
99
+ code: TagadaErrorCode.CIRCUIT_BREAKER,
100
+ retryable: false,
101
+ });
102
+ this.name = 'TagadaCircuitBreakerError';
103
+ }
104
+ }
@@ -65,6 +65,8 @@ export interface GTMTrackingConfig extends BaseTrackingConfig {
65
65
  AddToCart: boolean;
66
66
  ViewContent: boolean;
67
67
  };
68
+ googleAdsConversionId?: string;
69
+ googleAdsConversionLabel?: string;
68
70
  }
69
71
  /**
70
72
  * Union of all tracking configs.
@@ -83,14 +85,79 @@ export type PixelsConfig = {
83
85
  [TrackingProvider.GTM]?: GTMTrackingConfig[];
84
86
  };
85
87
  /**
86
- * Runtime step configuration injected from the CRM
87
- * Contains payment flows, static resources, scripts, and tracking configs
88
+ * Payment method configuration entry.
89
+ *
90
+ * Key pattern in paymentSetupConfig:
91
+ * "{method}" or "{method}:{provider}"
92
+ * e.g. "card", "apple_pay:stripe", "paypal:tagada", "klarna:stripe"
93
+ *
94
+ * `method` = what (universal payment method: card, apple_pay, klarna, ideal...)
95
+ * `provider` = who (processor family: tagada, stripe, airwallex, adyen...)
96
+ *
97
+ * @deprecated PaymentSetupMethod — use PaymentMethodConfig instead
88
98
  */
99
+ export interface ExpressMethodState {
100
+ enabled: boolean;
101
+ }
102
+ export type PaymentSetupMethod = PaymentMethodConfig;
103
+ export interface PaymentMethodConfig {
104
+ enabled: boolean;
105
+ /** Universal payment method identifier */
106
+ method: string;
107
+ /** Provider / processor family */
108
+ provider: string;
109
+ /** Render as express checkout button above the form */
110
+ express?: boolean;
111
+ /** Card routing via payment flow (cascade, fraud, processor selection) */
112
+ paymentFlowId?: string;
113
+ /** Direct processor routing for APMs and express methods */
114
+ processorId?: string;
115
+ /** Tagada integration record ID for native integrations */
116
+ integrationId?: string;
117
+ supportedCountries?: string[];
118
+ presentmentCurrencies?: string[];
119
+ recurring?: boolean;
120
+ /** Present only on express_checkout:proc_id entries */
121
+ publishableKey?: string;
122
+ /** Present only on express_checkout:proc_id entries — map of apmKey → state */
123
+ methods?: Record<string, ExpressMethodState>;
124
+ /** Present only on crypto integration entries — map of providerId → provider state */
125
+ providers?: Record<string, {
126
+ enabled?: boolean;
127
+ label?: string;
128
+ min?: number;
129
+ note?: string;
130
+ }>;
131
+ metadata?: Record<string, any>;
132
+ }
133
+ export type PaymentSetupConfig = Record<string, PaymentMethodConfig>;
134
+ /** Get all enabled entries from a paymentSetupConfig */
135
+ export declare function getEnabledMethods(config: PaymentSetupConfig | undefined): PaymentMethodConfig[];
136
+ /** Get all express methods (for rendering above the payment form) */
137
+ export declare function getExpressMethods(config: PaymentSetupConfig | undefined): PaymentMethodConfig[];
138
+ /** Group enabled express methods by processorId (one Express Element per processor) */
139
+ export declare function getExpressMethodsByProcessor(config: PaymentSetupConfig | undefined): Record<string, PaymentMethodConfig[]>;
140
+ /** Find a specific method entry by method name (returns first match) */
141
+ export declare function findMethod(config: PaymentSetupConfig | undefined, method: string): PaymentMethodConfig | undefined;
142
+ /** Check if a specific method is enabled (any provider) */
143
+ export declare function isMethodEnabled(config: PaymentSetupConfig | undefined, method: string): boolean;
89
144
  export interface RuntimeStepConfig {
90
145
  payment?: {
91
146
  paymentFlowId?: string;
92
147
  };
148
+ paymentSetupConfig?: PaymentSetupConfig;
149
+ orderBumps?: {
150
+ mode: 'inherit' | 'custom';
151
+ enabledOfferIds?: string[];
152
+ };
153
+ upsellOffers?: {
154
+ mode: 'inherit' | 'custom';
155
+ enabledUpsellIds?: string[];
156
+ };
157
+ /** @deprecated Use `resources` instead */
93
158
  staticResources?: Record<string, string>;
159
+ /** Typed resource bindings (replaces staticResources) */
160
+ resources?: Record<string, string>;
94
161
  scripts?: Array<{
95
162
  name: string;
96
163
  enabled: boolean;
@@ -108,14 +175,20 @@ export interface LocalFunnelConfig {
108
175
  funnelId?: string;
109
176
  /** Step ID to simulate */
110
177
  stepId?: string;
111
- /** Static resources (offer ID, product ID, etc.) */
178
+ /** @deprecated Use `resources` instead */
112
179
  staticResources?: Record<string, string>;
180
+ /** Resource bindings (offer ID, product ID, etc.) */
181
+ resources?: Record<string, string>;
113
182
  /** Payment flow ID override */
114
183
  paymentFlowId?: string;
115
184
  /** Custom scripts for local testing */
116
185
  scripts?: RuntimeStepConfig['scripts'];
117
186
  /** Pixel tracking config */
118
187
  pixels?: RuntimeStepConfig['pixels'];
188
+ /** Order bump filtering config for local testing */
189
+ orderBumps?: RuntimeStepConfig['orderBumps'];
190
+ /** Upsell offer filtering config for local testing */
191
+ upsellOffers?: RuntimeStepConfig['upsellOffers'];
119
192
  }
120
193
  /**
121
194
  * Load local funnel config from /config/funnel.local.json (for local dev only)
@@ -152,13 +225,22 @@ export declare function getLocalFunnelConfig(): LocalFunnelConfig | null;
152
225
  */
153
226
  export declare function getAssignedStepConfig(): RuntimeStepConfig | undefined;
154
227
  /**
155
- * Get the assigned payment flow ID from step config or legacy injection
156
- * Returns undefined if not available
228
+ * Get the assigned payment flow ID from step config or legacy injection.
229
+ * Resolution order:
230
+ * 1. paymentSetupConfig.card.paymentFlowId (per-method, most specific)
231
+ * 2. stepConfig.payment.paymentFlowId (per-step level)
232
+ * 3. window.__TGD_PAYMENT_FLOW_ID__ (legacy injection)
233
+ * 4. meta[name="x-payment-flow-id"] (legacy meta tag)
157
234
  */
158
235
  export declare function getAssignedPaymentFlowId(): string | undefined;
159
236
  /**
160
- * Get the assigned static resources from step config
161
- * Returns undefined if not available
237
+ * Get resource bindings from step config.
238
+ * Reads from `resources` (new) with `staticResources` (legacy) as fallback, merged.
239
+ */
240
+ export declare function getAssignedResources(): Record<string, string> | undefined;
241
+ /**
242
+ * @deprecated Use `getAssignedResources()` instead.
243
+ * Kept for backward compatibility — reads from both `resources` and `staticResources`.
162
244
  */
163
245
  export declare function getAssignedStaticResources(): Record<string, string> | undefined;
164
246
  /**
@@ -166,11 +248,19 @@ export declare function getAssignedStaticResources(): Record<string, string> | u
166
248
  * Returns only enabled scripts, filtered by position if specified
167
249
  */
168
250
  export declare function getAssignedScripts(position?: 'head-start' | 'head-end' | 'body-start' | 'body-end'): RuntimeStepConfig['scripts'];
251
+ export declare function getAssignedPixels(): PixelsConfig | undefined;
169
252
  /**
170
- * Get assigned pixel tracking configuration (normalized to arrays)
171
- * Always returns arrays of PixelConfig for consistent consumption.
253
+ * Get the enabled order bump offer IDs from step config.
254
+ * Returns undefined when mode is 'inherit' (use all store bumps).
255
+ * Returns the explicit list when mode is 'custom'.
172
256
  */
173
- export declare function getAssignedPixels(): PixelsConfig | undefined;
257
+ export declare function getAssignedOrderBumpOfferIds(): string[] | undefined;
258
+ /**
259
+ * Get the enabled upsell offer IDs from step config.
260
+ * Returns undefined when mode is 'inherit' (use all store upsells).
261
+ * Returns the explicit list when mode is 'custom'.
262
+ */
263
+ export declare function getAssignedUpsellOfferIds(): string[] | undefined;
174
264
  export interface FunnelClientConfig {
175
265
  apiClient: ApiClient;
176
266
  debugMode?: boolean;