@tagadapay/plugin-sdk 3.1.22 → 3.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-cdn.js +274 -6
- package/dist/external-tracker.js +476 -6774
- package/dist/external-tracker.min.js +2 -25
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/config/payment.d.ts +14 -4
- package/dist/react/config/payment.js +47 -9
- package/dist/react/hooks/useCheckout.d.ts +3 -0
- package/dist/react/hooks/useCheckout.js +11 -3
- package/dist/react/hooks/usePluginConfig.js +9 -10
- package/dist/react/providers/TagadaProvider.js +1 -1
- package/dist/tagada-react-sdk-minimal.min.js +36 -0
- package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
- package/dist/tagada-react-sdk.js +37988 -0
- package/dist/tagada-react-sdk.min.js +78 -0
- package/dist/tagada-react-sdk.min.js.map +7 -0
- package/dist/tagada-sdk.js +7847 -6420
- package/dist/tagada-sdk.min.js +4 -22
- package/dist/tagada-sdk.min.js.map +4 -4
- package/dist/v2/cdn-react-minimal.d.ts +23 -0
- package/dist/v2/cdn-react-minimal.js +26 -0
- package/dist/v2/core/client.js +2 -1
- package/dist/v2/core/config/environment.js +2 -1
- package/dist/v2/core/funnelClient.d.ts +106 -10
- package/dist/v2/core/funnelClient.js +122 -28
- package/dist/v2/core/index.d.ts +0 -1
- package/dist/v2/core/index.js +0 -2
- package/dist/v2/core/isoData.d.ts +4 -4
- package/dist/v2/core/isoData.js +7 -7
- package/dist/v2/core/pixelMapping.js +64 -26
- package/dist/v2/core/resources/apiClient.d.ts +18 -14
- package/dist/v2/core/resources/apiClient.js +151 -109
- package/dist/v2/core/resources/checkout.d.ts +10 -0
- package/dist/v2/core/resources/checkout.js +6 -0
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
- package/dist/v2/core/resources/index.d.ts +1 -1
- package/dist/v2/core/resources/index.js +1 -1
- package/dist/v2/core/resources/offers.js +4 -4
- package/dist/v2/core/resources/payments.d.ts +8 -2
- package/dist/v2/core/resources/payments.js +1 -0
- package/dist/v2/core/resources/postPurchases.d.ts +17 -0
- package/dist/v2/core/resources/postPurchases.js +20 -0
- package/dist/v2/core/utils/currency.d.ts +3 -0
- package/dist/v2/core/utils/currency.js +40 -2
- package/dist/v2/core/utils/deviceInfo.d.ts +1 -10
- package/dist/v2/core/utils/deviceInfo.js +153 -76
- package/dist/v2/core/utils/order.d.ts +2 -0
- package/dist/v2/core/utils/pluginConfig.js +18 -22
- package/dist/v2/core/utils/previewMode.js +12 -0
- package/dist/v2/index.d.ts +4 -3
- package/dist/v2/index.js +4 -2
- package/dist/v2/react/components/ApplePayButton.js +39 -16
- package/dist/v2/react/components/FunnelScriptInjector.js +145 -77
- package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
- package/dist/v2/react/components/StripeExpressButton.js +170 -0
- package/dist/v2/react/components/WhopCheckout.js +7 -1
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +1 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +21 -3
- package/dist/v2/react/hooks/useApiQuery.d.ts +1 -1
- package/dist/v2/react/hooks/useApiQuery.js +1 -1
- package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +10 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +27 -15
- package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
- package/dist/v2/react/hooks/useFunnel.js +8 -4
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
- package/dist/v2/react/hooks/useISOData.d.ts +2 -5
- package/dist/v2/react/hooks/useISOData.js +25 -26
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +2 -2
- package/dist/v2/react/hooks/usePixelTracking.js +151 -70
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
- package/dist/v2/react/hooks/usePreviewOffer.js +1 -1
- package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
- package/dist/v2/react/hooks/useRemappableParams.js +23 -23
- package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
- package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
- package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
- package/dist/v2/react/hooks/useStepConfig.js +14 -7
- package/dist/v2/react/hooks/useTranslation.js +23 -8
- package/dist/v2/react/index.d.ts +8 -1
- package/dist/v2/react/index.js +3 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +8 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +106 -10
- package/dist/v2/react/providers/TagadaProvider.js +5 -5
- package/dist/v2/standalone/index.d.ts +21 -3
- package/dist/v2/standalone/index.js +25 -3
- package/dist/v2/standalone/payment-service.d.ts +134 -0
- package/dist/v2/standalone/payment-service.js +929 -0
- 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
|
-
*
|
|
20
|
+
* Determine if the current hostname should use production BasisTheory.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
|
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
|
-
*
|
|
47
|
+
* Determine if the current hostname should use production BasisTheory.
|
|
49
48
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
|
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
|
|
97
|
+
* Get BasisTheory tenant ID based on hostname detection.
|
|
98
|
+
* Not affected by tagadaClientEnv overrides.
|
|
60
99
|
*/
|
|
61
100
|
export function getBasisTheoryTenantId() {
|
|
62
|
-
const
|
|
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,
|
|
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',
|
|
@@ -148,9 +151,14 @@ export function useCheckout(options = {}) {
|
|
|
148
151
|
setIsLoading(true);
|
|
149
152
|
setError(null);
|
|
150
153
|
try {
|
|
154
|
+
// Only send currency when explicitly set via URL param or persisted storage.
|
|
155
|
+
// Otherwise let the backend use the session's own selectedPresentmentCurrency.
|
|
156
|
+
const urlCurrency = new URLSearchParams(window.location.search).get('currency');
|
|
157
|
+
const storedCurrency = localStorage.getItem('tgd_currency');
|
|
158
|
+
const explicitCurrency = urlCurrency?.toUpperCase() || storedCurrency?.toUpperCase() || undefined;
|
|
151
159
|
const queryParams = new URLSearchParams();
|
|
152
|
-
if (
|
|
153
|
-
queryParams.set('currency',
|
|
160
|
+
if (explicitCurrency) {
|
|
161
|
+
queryParams.set('currency', explicitCurrency);
|
|
154
162
|
}
|
|
155
163
|
const url = `/api/v1/checkout-sessions/${checkoutToken}/v2${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
156
164
|
const response = await apiService.fetch(url, {
|
|
@@ -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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
124
|
-
|
|
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 = {
|