@tagadapay/plugin-sdk 3.1.22 → 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 (76) hide show
  1. package/build-cdn.js +274 -6
  2. package/dist/external-tracker.js +236 -3906
  3. package/dist/external-tracker.min.js +2 -25
  4. package/dist/external-tracker.min.js.map +4 -4
  5. package/dist/react/config/payment.d.ts +14 -4
  6. package/dist/react/config/payment.js +47 -9
  7. package/dist/react/hooks/useCheckout.d.ts +3 -0
  8. package/dist/react/hooks/useCheckout.js +4 -1
  9. package/dist/react/hooks/usePluginConfig.js +9 -10
  10. package/dist/react/providers/TagadaProvider.js +1 -1
  11. package/dist/tagada-react-sdk-minimal.min.js +36 -0
  12. package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
  13. package/dist/tagada-react-sdk.js +37821 -0
  14. package/dist/tagada-react-sdk.min.js +78 -0
  15. package/dist/tagada-react-sdk.min.js.map +7 -0
  16. package/dist/tagada-sdk.js +10309 -6331
  17. package/dist/tagada-sdk.min.js +4 -22
  18. package/dist/tagada-sdk.min.js.map +4 -4
  19. package/dist/v2/cdn-react-minimal.d.ts +23 -0
  20. package/dist/v2/cdn-react-minimal.js +26 -0
  21. package/dist/v2/core/client.js +1 -1
  22. package/dist/v2/core/config/environment.js +2 -1
  23. package/dist/v2/core/funnelClient.d.ts +98 -10
  24. package/dist/v2/core/funnelClient.js +121 -27
  25. package/dist/v2/core/index.d.ts +0 -1
  26. package/dist/v2/core/index.js +0 -2
  27. package/dist/v2/core/isoData.d.ts +4 -4
  28. package/dist/v2/core/isoData.js +7 -7
  29. package/dist/v2/core/pixelMapping.js +64 -26
  30. package/dist/v2/core/resources/checkout.d.ts +10 -0
  31. package/dist/v2/core/resources/checkout.js +6 -0
  32. package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
  33. package/dist/v2/core/resources/payments.d.ts +7 -2
  34. package/dist/v2/core/resources/payments.js +1 -0
  35. package/dist/v2/core/resources/postPurchases.d.ts +17 -0
  36. package/dist/v2/core/resources/postPurchases.js +20 -0
  37. package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
  38. package/dist/v2/core/utils/deviceInfo.js +152 -76
  39. package/dist/v2/core/utils/order.d.ts +2 -0
  40. package/dist/v2/core/utils/pluginConfig.js +18 -22
  41. package/dist/v2/index.d.ts +4 -3
  42. package/dist/v2/index.js +4 -2
  43. package/dist/v2/react/components/FunnelScriptInjector.js +145 -77
  44. package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
  45. package/dist/v2/react/components/StripeExpressButton.js +171 -0
  46. package/dist/v2/react/components/WhopCheckout.js +7 -1
  47. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +21 -3
  48. package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
  49. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +10 -0
  50. package/dist/v2/react/hooks/useCheckoutQuery.js +21 -13
  51. package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
  52. package/dist/v2/react/hooks/useFunnel.js +8 -4
  53. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
  54. package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
  55. package/dist/v2/react/hooks/useISOData.d.ts +2 -5
  56. package/dist/v2/react/hooks/useISOData.js +25 -26
  57. package/dist/v2/react/hooks/usePaymentPolling.d.ts +2 -2
  58. package/dist/v2/react/hooks/usePixelTracking.js +151 -70
  59. package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
  60. package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
  61. package/dist/v2/react/hooks/useRemappableParams.js +23 -23
  62. package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
  63. package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
  64. package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
  65. package/dist/v2/react/hooks/useStepConfig.js +14 -7
  66. package/dist/v2/react/hooks/useTranslation.js +23 -8
  67. package/dist/v2/react/index.d.ts +8 -1
  68. package/dist/v2/react/index.js +3 -0
  69. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +1 -0
  70. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +9 -1
  71. package/dist/v2/react/providers/TagadaProvider.js +4 -4
  72. package/dist/v2/standalone/index.d.ts +21 -3
  73. package/dist/v2/standalone/index.js +25 -3
  74. package/dist/v2/standalone/payment-service.d.ts +134 -0
  75. package/dist/v2/standalone/payment-service.js +928 -0
  76. package/package.json +4 -2
@@ -17,13 +17,23 @@ export declare const PAYMENT_CONFIGS: Record<string, PaymentConfig>;
17
17
  */
18
18
  export declare function getPaymentConfig(environment?: string): PaymentConfig;
19
19
  /**
20
- * Get BasisTheory API key and tenant ID based on environment detection
20
+ * Determine if the current hostname should use production BasisTheory.
21
21
  *
22
- * Uses detectEnvironment() to determine if production or test keys should be used.
23
- * No environment variables - keys are hardcoded for consistency.
22
+ * BT key selection is based ONLY on hostname never on tagadaClientEnv overrides.
23
+ * tagadaClientEnv controls which API server the SDK talks to, but BasisTheory
24
+ * tokens must always match the backend's BT tenant.
25
+ *
26
+ * Production BT: *.tagadapay.com, custom domains (e.g. checkout.myboost.club)
27
+ * Test BT: *.tagadapay.dev, app-dev.tagadapay.com, localhost, vercel.app, etc.
28
+ */
29
+ export declare function isProductionBasisTheory(): boolean;
30
+ /**
31
+ * Get BasisTheory API key based on hostname detection.
32
+ * Not affected by tagadaClientEnv overrides.
24
33
  */
25
34
  export declare function getBasisTheoryApiKey(): string;
26
35
  /**
27
- * Get BasisTheory tenant ID based on environment detection
36
+ * Get BasisTheory tenant ID based on hostname detection.
37
+ * Not affected by tagadaClientEnv overrides.
28
38
  */
29
39
  export declare function getBasisTheoryTenantId(): string;
@@ -42,24 +42,62 @@ export const PAYMENT_CONFIGS = {
42
42
  export function getPaymentConfig(environment = 'local') {
43
43
  return PAYMENT_CONFIGS[environment] || PAYMENT_CONFIGS.default || PAYMENT_CONFIGS.local;
44
44
  }
45
- import { detectEnvironment } from '../../v2/core/config/environment';
46
45
  import { getBasisTheoryKeys } from '../../config/basisTheory';
47
46
  /**
48
- * Get BasisTheory API key and tenant ID based on environment detection
47
+ * Determine if the current hostname should use production BasisTheory.
49
48
  *
50
- * Uses detectEnvironment() to determine if production or test keys should be used.
51
- * No environment variables - keys are hardcoded for consistency.
49
+ * BT key selection is based ONLY on hostname never on tagadaClientEnv overrides.
50
+ * tagadaClientEnv controls which API server the SDK talks to, but BasisTheory
51
+ * tokens must always match the backend's BT tenant.
52
+ *
53
+ * Production BT: *.tagadapay.com, custom domains (e.g. checkout.myboost.club)
54
+ * Test BT: *.tagadapay.dev, app-dev.tagadapay.com, localhost, vercel.app, etc.
55
+ */
56
+ export function isProductionBasisTheory() {
57
+ if (typeof window === 'undefined')
58
+ return false;
59
+ const hostname = window.location.hostname;
60
+ // Dev backend under tagadapay.com — uses test BT
61
+ if (hostname.includes('app-dev.tagadapay.com') || hostname.includes('cdn-dev.tagadapay.com')) {
62
+ return false;
63
+ }
64
+ // Production and preprod share the same production BT tenant
65
+ if (hostname.includes('tagadapay.com'))
66
+ return true;
67
+ // Dev/staging domains use test BT
68
+ if (hostname.includes('tagadapay.dev'))
69
+ return false;
70
+ // Local development — test BT
71
+ if (hostname === 'localhost' ||
72
+ hostname.startsWith('127.') ||
73
+ hostname.startsWith('192.168.') ||
74
+ hostname.startsWith('10.') ||
75
+ hostname.includes('.local') ||
76
+ hostname === '' ||
77
+ hostname === '0.0.0.0' ||
78
+ hostname.includes('ngrok') ||
79
+ hostname.includes('.loclx.io') ||
80
+ hostname.includes('vercel.app') ||
81
+ hostname.includes('netlify.app')) {
82
+ return false;
83
+ }
84
+ // Custom checkout domains (e.g. checkout.myboost.club) use production BT
85
+ // to match the production backend's BT tenant
86
+ return true;
87
+ }
88
+ /**
89
+ * Get BasisTheory API key based on hostname detection.
90
+ * Not affected by tagadaClientEnv overrides.
52
91
  */
53
92
  export function getBasisTheoryApiKey() {
54
- const isProduction = detectEnvironment() === 'production';
55
- const keys = getBasisTheoryKeys(isProduction);
93
+ const keys = getBasisTheoryKeys(isProductionBasisTheory());
56
94
  return keys.apiKey;
57
95
  }
58
96
  /**
59
- * Get BasisTheory tenant ID based on environment detection
97
+ * Get BasisTheory tenant ID based on hostname detection.
98
+ * Not affected by tagadaClientEnv overrides.
60
99
  */
61
100
  export function getBasisTheoryTenantId() {
62
- const isProduction = detectEnvironment() === 'production';
63
- const keys = getBasisTheoryKeys(isProduction);
101
+ const keys = getBasisTheoryKeys(isProductionBasisTheory());
64
102
  return keys.tenantId;
65
103
  }
@@ -19,6 +19,7 @@ export interface CheckoutInitParams {
19
19
  currency?: string;
20
20
  locale?: string;
21
21
  };
22
+ enabledOrderBumpOfferIds?: string[];
22
23
  }
23
24
  export interface CheckoutSession {
24
25
  id: string;
@@ -173,6 +174,7 @@ export interface CheckoutSessionPreviewItem {
173
174
  totalBillingCycles?: number;
174
175
  unitAmountAfterFirstCycle?: number;
175
176
  subscriptionSettings?: any;
177
+ properties?: Record<string, unknown>;
176
178
  orderLineItemProduct: {
177
179
  name: string | null;
178
180
  } | null;
@@ -215,6 +217,7 @@ export interface CheckoutSummaryItem {
215
217
  intervalCount?: number;
216
218
  totalBillingCycles?: number;
217
219
  unitAmountAfterFirstCycle?: number;
220
+ properties?: Record<string, unknown>;
218
221
  orderLineItemProduct: {
219
222
  name: string;
220
223
  };
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { getAssignedOrderBumpOfferIds } from '../../v2/core/funnelClient';
2
3
  import { useCurrency } from '../hooks/useCurrency';
3
4
  import { useTagadaContext } from '../providers/TagadaProvider';
4
5
  import { collectTrackingData } from '../utils/trackingUtils';
@@ -86,15 +87,17 @@ export function useCheckout(options = {}) {
86
87
  localStorage: trackingData.localStorageData,
87
88
  cookies: trackingData.trackingCookiesData,
88
89
  };
90
+ const enabledOrderBumpOfferIds = params.enabledOrderBumpOfferIds ?? getAssignedOrderBumpOfferIds();
89
91
  const requestBody = {
90
92
  ...params,
91
- storeId: params.storeId || storeId, // Use storeId from params or from usePluginConfig
93
+ storeId: params.storeId || storeId,
92
94
  returnUrl: params.returnUrl || window.location.origin,
93
95
  customer: {
94
96
  ...params.customer,
95
97
  currency: params.customer?.currency || currentCurrency,
96
98
  },
97
99
  customerMetadata: enhancedCustomerMetadata,
100
+ ...(enabledOrderBumpOfferIds && { enabledOrderBumpOfferIds }),
98
101
  };
99
102
  const response = await apiService.fetch('/api/v1/checkout/session/init', {
100
103
  method: 'POST',
@@ -110,18 +110,17 @@ const loadProductionConfig = async () => {
110
110
  const storeId = document.querySelector('meta[name="x-plugin-store-id"]')?.getAttribute('content') || undefined;
111
111
  const accountId = document.querySelector('meta[name="x-plugin-account-id"]')?.getAttribute('content') || undefined;
112
112
  const basePath = document.querySelector('meta[name="x-plugin-base-path"]')?.getAttribute('content') || '/';
113
- // Get deployment config from meta tags
114
113
  let config = {};
115
- try {
116
- const configMeta = document.querySelector('meta[name="x-plugin-config"]');
117
- const encodedConfig = configMeta?.getAttribute('content');
118
- if (encodedConfig) {
119
- const decodedConfig = decodeURIComponent(encodedConfig);
120
- config = JSON.parse(decodedConfig);
121
- }
114
+ if (typeof window !== 'undefined' && window.__TAGADA_PLUGIN_CONFIG__) {
115
+ config = window.__TAGADA_PLUGIN_CONFIG__;
122
116
  }
123
- catch {
124
- // Deployment config is optional
117
+ else {
118
+ try {
119
+ const encoded = document.querySelector('meta[name="x-plugin-config"]')?.getAttribute('content');
120
+ if (encoded)
121
+ config = JSON.parse(decodeURIComponent(encoded));
122
+ }
123
+ catch { /* fallback for old deployments */ }
125
124
  }
126
125
  console.log('🚀 Plugin config loaded from meta tags (no HEAD request needed):', {
127
126
  storeId,
@@ -221,7 +221,7 @@ rawPluginConfig, }) {
221
221
  }
222
222
  setIsLoading(true);
223
223
  try {
224
- const deviceInfo = collectDeviceInfo();
224
+ const deviceInfo = await collectDeviceInfo();
225
225
  const urlParams = getUrlParams();
226
226
  const browserLocale = getBrowserLocale();
227
227
  const sessionInitData = {