@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.
- package/build-cdn.js +397 -11
- 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 +623 -3426
- 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 +4 -1
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -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 +37821 -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 +16044 -0
- package/dist/tagada-sdk.min.js +32 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/cdn-react-minimal.d.ts +23 -0
- package/dist/v2/cdn-react-minimal.js +26 -0
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +5 -4
- package/dist/v2/core/config/environment.js +2 -1
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +100 -10
- package/dist/v2/core/funnelClient.js +121 -27
- package/dist/v2/core/isoData.d.ts +4 -4
- package/dist/v2/core/isoData.js +7 -7
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +363 -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 +99 -30
- package/dist/v2/core/resources/checkout.js +14 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +89 -13
- package/dist/v2/core/resources/payments.js +27 -9
- package/dist/v2/core/resources/postPurchases.d.ts +17 -0
- package/dist/v2/core/resources/postPurchases.js +20 -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/currency.d.ts +14 -0
- package/dist/v2/core/utils/currency.js +40 -0
- package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
- package/dist/v2/core/utils/deviceInfo.js +152 -76
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/order.d.ts +13 -9
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +36 -12
- package/dist/v2/index.d.ts +6 -3
- package/dist/v2/index.js +4 -2
- package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
- package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
- package/dist/v2/react/components/StripeExpressButton.js +171 -0
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +237 -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 +31 -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/useApplePayCheckout.js +8 -8
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
- package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
- package/dist/v2/react/hooks/useFunnel.js +8 -4
- 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.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 +26 -27
- 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 -48
- package/dist/v2/react/hooks/usePixelTracking.js +283 -504
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
- 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/useShippingRatesQuery.js +13 -5
- 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/hooks/useWhopPaymentPolling.d.ts +30 -0
- package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
- package/dist/v2/react/index.d.ts +15 -1
- package/dist/v2/react/index.js +7 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
- package/dist/v2/react/providers/TagadaProvider.js +74 -5
- 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 +40 -0
- package/dist/v2/standalone/index.js +148 -1
- package/dist/v2/standalone/payment-service.d.ts +134 -0
- package/dist/v2/standalone/payment-service.js +928 -0
- package/package.json +6 -4
- 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
|
@@ -1,44 +1,159 @@
|
|
|
1
|
-
import { UAParser } from '@ua-parser-js/pro-enterprise';
|
|
2
|
-
import { isBot, isChromeFamily, isStandalonePWA, isAppleSilicon, } from '@ua-parser-js/pro-enterprise/helpers';
|
|
3
|
-
/**
|
|
4
|
-
* Get screen resolution
|
|
5
|
-
*/
|
|
6
1
|
function getScreenResolution() {
|
|
7
|
-
return {
|
|
8
|
-
width: window.screen.width,
|
|
9
|
-
height: window.screen.height,
|
|
10
|
-
};
|
|
2
|
+
return { width: window.screen.width, height: window.screen.height };
|
|
11
3
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Get timezone
|
|
14
|
-
*/
|
|
15
4
|
function getTimeZone() {
|
|
16
5
|
try {
|
|
17
6
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
18
7
|
}
|
|
19
|
-
catch
|
|
20
|
-
console.error('Failed to get timezone:', error);
|
|
8
|
+
catch {
|
|
21
9
|
return 'UTC';
|
|
22
10
|
}
|
|
23
11
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Get browser locale
|
|
26
|
-
*/
|
|
27
12
|
export function getBrowserLocale() {
|
|
28
13
|
try {
|
|
29
14
|
return navigator.language || 'en-US';
|
|
30
15
|
}
|
|
31
|
-
catch
|
|
32
|
-
console.error('Failed to get browser locale:', error);
|
|
16
|
+
catch {
|
|
33
17
|
return 'en-US';
|
|
34
18
|
}
|
|
35
19
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Lightweight UA parsing — no third-party library needed
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
const UA = typeof navigator !== 'undefined' ? navigator.userAgent : '';
|
|
24
|
+
/** Extract first match's groups from a UA string */
|
|
25
|
+
function match(ua, ...patterns) {
|
|
26
|
+
for (const p of patterns) {
|
|
27
|
+
const m = ua.match(p);
|
|
28
|
+
if (m)
|
|
29
|
+
return m;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function parseBrowser(ua) {
|
|
34
|
+
// Order matters — more specific first
|
|
35
|
+
const tests = [
|
|
36
|
+
[/EdgA?\/([\d.]+)/i, 'Edge'],
|
|
37
|
+
[/OPR\/([\d.]+)/i, 'Opera'],
|
|
38
|
+
[/Brave\/([\d.]+)/i, 'Brave'],
|
|
39
|
+
[/Vivaldi\/([\d.]+)/i, 'Vivaldi'],
|
|
40
|
+
[/SamsungBrowser\/([\d.]+)/i, 'Samsung Internet'],
|
|
41
|
+
[/UCBrowser\/([\d.]+)/i, 'UC Browser'],
|
|
42
|
+
[/Firefox\/([\d.]+)/i, 'Firefox'],
|
|
43
|
+
[/CriOS\/([\d.]+)/i, 'Chrome'], // Chrome on iOS
|
|
44
|
+
[/FxiOS\/([\d.]+)/i, 'Firefox'], // Firefox on iOS
|
|
45
|
+
[/Chrome\/([\d.]+)/i, 'Chrome'],
|
|
46
|
+
[/Version\/([\d.]+).*Safari/i, 'Safari'],
|
|
47
|
+
[/Safari\/([\d.]+)/i, 'Safari'],
|
|
48
|
+
];
|
|
49
|
+
for (const [re, name] of tests) {
|
|
50
|
+
const m = ua.match(re);
|
|
51
|
+
if (m) {
|
|
52
|
+
const version = m[1] || '';
|
|
53
|
+
return { name, version, major: version.split('.')[0] || '' };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { name: '', version: '', major: '' };
|
|
57
|
+
}
|
|
58
|
+
function parseOS(ua) {
|
|
59
|
+
const m = match(ua, /Windows NT ([\d.]+)/i) ||
|
|
60
|
+
match(ua, /Mac OS X ([\d_.]+)/i) ||
|
|
61
|
+
match(ua, /Android ([\d.]+)/i) ||
|
|
62
|
+
match(ua, /iPhone OS ([\d_]+)/i) ||
|
|
63
|
+
match(ua, /iPad.*OS ([\d_]+)/i) ||
|
|
64
|
+
match(ua, /CrOS[\w ]*\/([\d.]+)/i) ||
|
|
65
|
+
match(ua, /Linux/i);
|
|
66
|
+
if (!m)
|
|
67
|
+
return { name: '', version: '' };
|
|
68
|
+
const raw = m[0];
|
|
69
|
+
const version = (m[1] || '').replace(/_/g, '.');
|
|
70
|
+
if (/Windows/i.test(raw)) {
|
|
71
|
+
const ntMap = {
|
|
72
|
+
'10.0': '10', '6.3': '8.1', '6.2': '8', '6.1': '7', '6.0': 'Vista', '5.1': 'XP',
|
|
73
|
+
};
|
|
74
|
+
return { name: 'Windows', version: ntMap[version] || version };
|
|
75
|
+
}
|
|
76
|
+
if (/Mac OS X/i.test(raw))
|
|
77
|
+
return { name: 'macOS', version };
|
|
78
|
+
if (/Android/i.test(raw))
|
|
79
|
+
return { name: 'Android', version };
|
|
80
|
+
if (/iPhone|iPad/i.test(raw))
|
|
81
|
+
return { name: 'iOS', version };
|
|
82
|
+
if (/CrOS/i.test(raw))
|
|
83
|
+
return { name: 'Chrome OS', version };
|
|
84
|
+
if (/Linux/i.test(raw))
|
|
85
|
+
return { name: 'Linux', version: '' };
|
|
86
|
+
return { name: '', version: '' };
|
|
87
|
+
}
|
|
88
|
+
function parseDevice(ua) {
|
|
89
|
+
if (/iPad/i.test(ua))
|
|
90
|
+
return { type: 'tablet', vendor: 'Apple', model: 'iPad' };
|
|
91
|
+
if (/iPhone/i.test(ua))
|
|
92
|
+
return { type: 'mobile', vendor: 'Apple', model: 'iPhone' };
|
|
93
|
+
if (/iPod/i.test(ua))
|
|
94
|
+
return { type: 'mobile', vendor: 'Apple', model: 'iPod' };
|
|
95
|
+
if (/Android/i.test(ua)) {
|
|
96
|
+
const m = ua.match(/Android[\s\d.]+;\s*([^)]+?)(?:\s+Build)/i);
|
|
97
|
+
const mobile = /Mobile/i.test(ua);
|
|
98
|
+
return { type: mobile ? 'mobile' : 'tablet', model: m?.[1]?.trim() };
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
function parseEngine(ua) {
|
|
103
|
+
const m = match(ua, /AppleWebKit\/([\d.]+)/i) ||
|
|
104
|
+
match(ua, /Gecko\/([\d.]+)/i) ||
|
|
105
|
+
match(ua, /Trident\/([\d.]+)/i) ||
|
|
106
|
+
match(ua, /Presto\/([\d.]+)/i);
|
|
107
|
+
if (!m)
|
|
108
|
+
return { name: '', version: '' };
|
|
109
|
+
const raw = m[0];
|
|
110
|
+
const version = m[1] || '';
|
|
111
|
+
if (/AppleWebKit/i.test(raw))
|
|
112
|
+
return { name: 'WebKit', version };
|
|
113
|
+
if (/Gecko/i.test(raw))
|
|
114
|
+
return { name: 'Gecko', version };
|
|
115
|
+
if (/Trident/i.test(raw))
|
|
116
|
+
return { name: 'Trident', version };
|
|
117
|
+
if (/Presto/i.test(raw))
|
|
118
|
+
return { name: 'Presto', version };
|
|
119
|
+
return { name: '', version: '' };
|
|
120
|
+
}
|
|
121
|
+
function parseCPU(ua) {
|
|
122
|
+
if (/x86_64|x64|amd64|Win64/i.test(ua))
|
|
123
|
+
return { architecture: 'amd64' };
|
|
124
|
+
if (/ia32|x86/i.test(ua))
|
|
125
|
+
return { architecture: 'ia32' };
|
|
126
|
+
if (/aarch64|arm64/i.test(ua))
|
|
127
|
+
return { architecture: 'arm64' };
|
|
128
|
+
if (/arm/i.test(ua))
|
|
129
|
+
return { architecture: 'arm' };
|
|
130
|
+
return { architecture: '' };
|
|
131
|
+
}
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
// Flags
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
function detectIsBot() {
|
|
136
|
+
if (navigator.webdriver)
|
|
137
|
+
return true;
|
|
138
|
+
return /bot|crawl|spider|slurp|Googlebot|bingbot|yandex|baidu|duckduck|facebookexternalhit|Twitterbot|linkedinbot|embedly|quora|pinterest|redditbot|Slackbot|Discordbot|WhatsApp|TelegramBot|Applebot/i.test(UA);
|
|
139
|
+
}
|
|
140
|
+
function detectIsChromeFamily(browserName) {
|
|
141
|
+
return /Chrome|Chromium|Edge|Brave|Opera|Vivaldi|Arc/i.test(browserName);
|
|
142
|
+
}
|
|
143
|
+
function detectIsStandalonePWA() {
|
|
144
|
+
return window.matchMedia('(display-mode: standalone)').matches
|
|
145
|
+
|| navigator.standalone === true;
|
|
146
|
+
}
|
|
147
|
+
function detectIsAppleSilicon(osName) {
|
|
148
|
+
if (!/mac/i.test(osName))
|
|
149
|
+
return false;
|
|
150
|
+
return navigator.maxTouchPoints > 0;
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// Main
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
39
155
|
export function collectDeviceInfo() {
|
|
40
156
|
if (typeof window === 'undefined') {
|
|
41
|
-
// Server-side fallback
|
|
42
157
|
return {
|
|
43
158
|
userAgent: {
|
|
44
159
|
name: '',
|
|
@@ -50,75 +165,36 @@ export function collectDeviceInfo() {
|
|
|
50
165
|
},
|
|
51
166
|
screenResolution: { width: 0, height: 0 },
|
|
52
167
|
timeZone: 'UTC',
|
|
53
|
-
flags: {
|
|
54
|
-
isBot: false,
|
|
55
|
-
isChromeFamily: false,
|
|
56
|
-
isStandalonePWA: false,
|
|
57
|
-
isAppleSilicon: false,
|
|
58
|
-
},
|
|
168
|
+
flags: { isBot: false, isChromeFamily: false, isStandalonePWA: false, isAppleSilicon: false },
|
|
59
169
|
};
|
|
60
170
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
171
|
+
const browser = parseBrowser(UA);
|
|
172
|
+
const os = parseOS(UA);
|
|
173
|
+
const device = parseDevice(UA);
|
|
174
|
+
const engine = parseEngine(UA);
|
|
175
|
+
const cpu = parseCPU(UA);
|
|
64
176
|
let flags;
|
|
65
177
|
try {
|
|
66
178
|
flags = {
|
|
67
|
-
isBot:
|
|
68
|
-
isChromeFamily:
|
|
69
|
-
isStandalonePWA:
|
|
70
|
-
isAppleSilicon:
|
|
179
|
+
isBot: detectIsBot(),
|
|
180
|
+
isChromeFamily: detectIsChromeFamily(browser.name),
|
|
181
|
+
isStandalonePWA: detectIsStandalonePWA(),
|
|
182
|
+
isAppleSilicon: detectIsAppleSilicon(os.name),
|
|
71
183
|
};
|
|
72
184
|
}
|
|
73
|
-
catch
|
|
74
|
-
|
|
75
|
-
flags = {
|
|
76
|
-
isBot: false,
|
|
77
|
-
isChromeFamily: false,
|
|
78
|
-
isStandalonePWA: false,
|
|
79
|
-
isAppleSilicon: false,
|
|
80
|
-
};
|
|
185
|
+
catch {
|
|
186
|
+
flags = { isBot: false, isChromeFamily: false, isStandalonePWA: false, isAppleSilicon: false };
|
|
81
187
|
}
|
|
82
188
|
return {
|
|
83
|
-
userAgent: {
|
|
84
|
-
name: result.ua,
|
|
85
|
-
browser: {
|
|
86
|
-
major: result.browser.major || '',
|
|
87
|
-
name: result.browser.name || '',
|
|
88
|
-
version: result.browser.version || '',
|
|
89
|
-
type: result.browser.type,
|
|
90
|
-
},
|
|
91
|
-
os: {
|
|
92
|
-
name: result.os.name || '',
|
|
93
|
-
version: result.os.version || '',
|
|
94
|
-
},
|
|
95
|
-
device: result.device.model || result.device.type || result.device.vendor
|
|
96
|
-
? {
|
|
97
|
-
model: result.device.model,
|
|
98
|
-
type: result.device.type,
|
|
99
|
-
vendor: result.device.vendor,
|
|
100
|
-
}
|
|
101
|
-
: undefined,
|
|
102
|
-
engine: {
|
|
103
|
-
name: result.engine.name || '',
|
|
104
|
-
version: result.engine.version || '',
|
|
105
|
-
},
|
|
106
|
-
cpu: {
|
|
107
|
-
architecture: result.cpu.architecture || '',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
189
|
+
userAgent: { name: UA, browser, os, device, engine, cpu },
|
|
110
190
|
screenResolution: getScreenResolution(),
|
|
111
191
|
timeZone: getTimeZone(),
|
|
112
192
|
flags,
|
|
113
193
|
};
|
|
114
194
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Get URL parameters for session initialization
|
|
117
|
-
*/
|
|
118
195
|
export function getUrlParams() {
|
|
119
|
-
if (typeof window === 'undefined')
|
|
196
|
+
if (typeof window === 'undefined')
|
|
120
197
|
return {};
|
|
121
|
-
}
|
|
122
198
|
const params = new URLSearchParams(window.location.search);
|
|
123
199
|
return {
|
|
124
200
|
locale: params.get('locale') || undefined,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Order Utility Functions
|
|
3
3
|
* Pure functions for order data manipulation
|
|
4
4
|
*/
|
|
5
|
+
import type { OrderSummary, PromotionSummary, PaymentSummary, Subscription, OrderAddress } from '../types';
|
|
5
6
|
export interface OrderLineItem {
|
|
6
7
|
id: string;
|
|
7
8
|
orderId: string;
|
|
@@ -23,6 +24,7 @@ export interface OrderLineItem {
|
|
|
23
24
|
totalBillingCycles: number;
|
|
24
25
|
unitAmountAfterFirstCycle: number;
|
|
25
26
|
subscriptionSettings?: Record<string, unknown> | null;
|
|
27
|
+
properties?: Record<string, unknown>;
|
|
26
28
|
orderLineItemProduct: {
|
|
27
29
|
id: string;
|
|
28
30
|
name: string;
|
|
@@ -45,6 +47,7 @@ export interface OrderLineItem {
|
|
|
45
47
|
}
|
|
46
48
|
export interface Order {
|
|
47
49
|
id: string;
|
|
50
|
+
orderNumber: number;
|
|
48
51
|
storeId: string;
|
|
49
52
|
accountId: string;
|
|
50
53
|
createdAt: string;
|
|
@@ -95,7 +98,7 @@ export interface Order {
|
|
|
95
98
|
paymentInstrumentId: string;
|
|
96
99
|
refundedAt?: string | null;
|
|
97
100
|
refundedAmount?: number | null;
|
|
98
|
-
metadata?:
|
|
101
|
+
metadata?: Record<string, unknown>;
|
|
99
102
|
customer?: {
|
|
100
103
|
id: string;
|
|
101
104
|
email: string;
|
|
@@ -105,27 +108,28 @@ export interface Order {
|
|
|
105
108
|
lastOrderId: string;
|
|
106
109
|
accountId: string;
|
|
107
110
|
storeId: string;
|
|
108
|
-
billingAddress?:
|
|
109
|
-
shippingAddress?:
|
|
111
|
+
billingAddress?: OrderAddress | null;
|
|
112
|
+
shippingAddress?: OrderAddress | null;
|
|
110
113
|
currency: string;
|
|
111
114
|
locale: string;
|
|
112
115
|
draft: boolean;
|
|
113
116
|
acceptsMarketing: boolean;
|
|
114
117
|
createdAt: string;
|
|
115
118
|
updatedAt: string;
|
|
116
|
-
metadata?:
|
|
119
|
+
metadata?: Record<string, unknown>;
|
|
117
120
|
device?: Record<string, unknown> | null;
|
|
118
121
|
};
|
|
119
122
|
items: OrderLineItem[];
|
|
120
|
-
summaries?:
|
|
121
|
-
promotions?:
|
|
123
|
+
summaries?: OrderSummary[];
|
|
124
|
+
promotions?: PromotionSummary[];
|
|
122
125
|
checkoutSession?: {
|
|
123
126
|
id: string;
|
|
124
127
|
selectedPresentmentCurrency?: string;
|
|
125
|
-
|
|
128
|
+
returnUrl?: string;
|
|
129
|
+
[key: string]: unknown;
|
|
126
130
|
};
|
|
127
|
-
payments?:
|
|
128
|
-
subscriptions?:
|
|
131
|
+
payments?: PaymentSummary[];
|
|
132
|
+
subscriptions?: Subscription[];
|
|
129
133
|
store?: {
|
|
130
134
|
name: string;
|
|
131
135
|
chargeCurrencies: string[];
|
|
@@ -22,6 +22,14 @@ export type RawPluginConfig<TConfig = Record<string, any>> = {
|
|
|
22
22
|
basePath?: string;
|
|
23
23
|
config?: any;
|
|
24
24
|
} & TConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Synchronously get plugin config from meta tags
|
|
27
|
+
* This is a lightweight sync alternative to loadPluginConfig
|
|
28
|
+
* Use this when you need immediate config access (e.g., in CDN bundles)
|
|
29
|
+
*
|
|
30
|
+
* @returns Plugin config from meta tags or defaults
|
|
31
|
+
*/
|
|
32
|
+
export declare function getPluginConfig(): PluginConfig;
|
|
25
33
|
/**
|
|
26
34
|
* Core plugin config loading function
|
|
27
35
|
*
|
|
@@ -154,9 +154,44 @@ const loadStaticResources = async () => {
|
|
|
154
154
|
* Helper to get content from meta tag
|
|
155
155
|
*/
|
|
156
156
|
const getMetaContent = (name) => {
|
|
157
|
+
if (typeof document === 'undefined')
|
|
158
|
+
return undefined;
|
|
157
159
|
const metaTag = document.querySelector(`meta[name="${name}"]`);
|
|
158
160
|
return metaTag?.getAttribute('content') || undefined;
|
|
159
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* Read config from window global (preferred) or fall back to x-plugin-config meta tag
|
|
164
|
+
* (retrocompat with old deployments that still inject the meta tag).
|
|
165
|
+
*/
|
|
166
|
+
const readWindowConfig = () => {
|
|
167
|
+
if (typeof window !== 'undefined' && window.__TAGADA_PLUGIN_CONFIG__) {
|
|
168
|
+
return window.__TAGADA_PLUGIN_CONFIG__;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const encoded = getMetaContent('x-plugin-config');
|
|
172
|
+
if (encoded)
|
|
173
|
+
return JSON.parse(decodeURIComponent(encoded));
|
|
174
|
+
}
|
|
175
|
+
catch { /* ignore */ }
|
|
176
|
+
return {};
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Synchronously get plugin config from meta tags
|
|
180
|
+
* This is a lightweight sync alternative to loadPluginConfig
|
|
181
|
+
* Use this when you need immediate config access (e.g., in CDN bundles)
|
|
182
|
+
*
|
|
183
|
+
* @returns Plugin config from meta tags or defaults
|
|
184
|
+
*/
|
|
185
|
+
export function getPluginConfig() {
|
|
186
|
+
if (typeof document === 'undefined') {
|
|
187
|
+
return { basePath: '/', config: {} };
|
|
188
|
+
}
|
|
189
|
+
const storeId = getMetaContent('x-plugin-store-id');
|
|
190
|
+
const accountId = getMetaContent('x-plugin-account-id');
|
|
191
|
+
const basePath = getMetaContent('x-plugin-base-path') || '/';
|
|
192
|
+
const config = readWindowConfig();
|
|
193
|
+
return { storeId, accountId, basePath, config };
|
|
194
|
+
}
|
|
160
195
|
/**
|
|
161
196
|
* Load production config from meta tags (HIGHEST PRIORITY)
|
|
162
197
|
* Meta tags are injected by the plugin middleware during HTML serving
|
|
@@ -178,18 +213,7 @@ const loadProductionConfig = async () => {
|
|
|
178
213
|
return null;
|
|
179
214
|
}
|
|
180
215
|
const basePath = getMetaContent('x-plugin-base-path') || '/';
|
|
181
|
-
|
|
182
|
-
let config = {};
|
|
183
|
-
try {
|
|
184
|
-
const encodedConfig = getMetaContent('x-plugin-config');
|
|
185
|
-
if (encodedConfig) {
|
|
186
|
-
const decodedConfig = decodeURIComponent(encodedConfig);
|
|
187
|
-
config = JSON.parse(decodedConfig);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
console.warn('⚠️ Failed to parse plugin config from meta tag:', error);
|
|
192
|
-
}
|
|
216
|
+
const config = readWindowConfig();
|
|
193
217
|
// Final validation
|
|
194
218
|
if (!accountId) {
|
|
195
219
|
console.warn('⚠️ Plugin config: Account ID not found in meta tags');
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export * from './core/utils/pluginConfig';
|
|
|
13
13
|
export * from './core/utils/previewMode';
|
|
14
14
|
export { injectPreviewModeIndicator, isIndicatorInjected, removePreviewModeIndicator } from './core/utils/previewModeIndicator';
|
|
15
15
|
export * from './core/utils/products';
|
|
16
|
-
export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedStepConfig, getLocalFunnelConfig, loadLocalFunnelConfig } from './core/funnelClient';
|
|
17
|
-
export type { LocalFunnelConfig, PixelsConfig, RuntimeStepConfig } from './core/funnelClient';
|
|
16
|
+
export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedResources, getAssignedStepConfig, getAssignedOrderBumpOfferIds, getAssignedUpsellOfferIds, getLocalFunnelConfig, getEnabledMethods, getExpressMethods, getExpressMethodsByProcessor, findMethod, isMethodEnabled, loadLocalFunnelConfig } from './core/funnelClient';
|
|
17
|
+
export type { LocalFunnelConfig, PaymentMethodConfig, PaymentSetupConfig, PaymentSetupMethod, PixelsConfig, RuntimeStepConfig } from './core/funnelClient';
|
|
18
18
|
export * from './core/pathRemapping';
|
|
19
19
|
export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, CheckoutSessionPreview, Promotion } from './core/resources/checkout';
|
|
20
20
|
export type { Order, OrderLineItem } from './core/utils/order';
|
|
@@ -28,8 +28,9 @@ export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './co
|
|
|
28
28
|
export type { StoreConfig } from './core/resources/storeConfig';
|
|
29
29
|
export { FunnelActionType } from './core/resources/funnel';
|
|
30
30
|
export type { BackNavigationActionData, CartUpdatedActionData, DirectNavigationActionData, FormSubmitActionData, FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelAction as FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, NextAction, OfferAcceptedActionData, OfferDeclinedActionData, PaymentFailedActionData, PaymentSuccessActionData, SimpleFunnelContext } from './core/resources/funnel';
|
|
31
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
|
|
31
|
+
export { ApplePayButton, StripeExpressButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers, useSetPaymentMethod, WhopCheckout, useWhopPaymentPolling } from './react';
|
|
32
32
|
export type { DebugScript } from './react';
|
|
33
|
+
export type { PaymentMethodName } from './react';
|
|
33
34
|
export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
|
|
34
35
|
export type { FunnelContextValue } from './react/hooks/useFunnel';
|
|
35
36
|
export type { UseApplePayCheckoutOptions } from './react/hooks/useApplePayCheckout';
|
|
@@ -37,6 +38,8 @@ export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, Use
|
|
|
37
38
|
export type { UseCreditsOptions, UseCreditsResult } from './react/hooks/useCredits';
|
|
38
39
|
export type { UseGooglePayCheckoutOptions } from './react/hooks/useGooglePayCheckout';
|
|
39
40
|
export type { UseLoginOptions, UseLoginResult } from './react/hooks/useLogin';
|
|
41
|
+
export type { WhopCheckoutHandle, WhopCheckoutProps } from './react/components/WhopCheckout';
|
|
42
|
+
export type { WhopPayment, UseWhopPaymentPollingOptions, UseWhopPaymentPollingReturn } from './react/hooks/useWhopPaymentPolling';
|
|
40
43
|
export type { CustomerAddress, CustomerInfos, CustomerOrderSummary, OrderWithRelations, Subscription, SubscriptionsResponse } from './core/resources/customer';
|
|
41
44
|
export type { UseCustomerResult } from './react/hooks/useCustomer';
|
|
42
45
|
export type { UseCustomerInfosOptions, UseCustomerInfosResult } from './react/hooks/useCustomerInfos';
|
package/dist/v2/index.js
CHANGED
|
@@ -15,11 +15,13 @@ export * from './core/utils/previewMode';
|
|
|
15
15
|
export { injectPreviewModeIndicator, isIndicatorInjected, removePreviewModeIndicator } from './core/utils/previewModeIndicator';
|
|
16
16
|
export * from './core/utils/products';
|
|
17
17
|
// Step config utilities (for reading runtime configuration from HTML)
|
|
18
|
-
export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedStepConfig, getLocalFunnelConfig,
|
|
18
|
+
export { getAssignedPaymentFlowId, getAssignedScripts, getAssignedStaticResources, getAssignedResources, getAssignedStepConfig, getAssignedOrderBumpOfferIds, getAssignedUpsellOfferIds, getLocalFunnelConfig,
|
|
19
|
+
// Payment setup config helpers
|
|
20
|
+
getEnabledMethods, getExpressMethods, getExpressMethodsByProcessor, findMethod, isMethodEnabled,
|
|
19
21
|
// Local development helpers
|
|
20
22
|
loadLocalFunnelConfig } from './core/funnelClient';
|
|
21
23
|
// Path remapping helpers (framework-agnostic)
|
|
22
24
|
export * from './core/pathRemapping';
|
|
23
25
|
export { FunnelActionType } from './core/resources/funnel';
|
|
24
26
|
// React exports (hooks and components only, types are exported above)
|
|
25
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
|
|
27
|
+
export { ApplePayButton, StripeExpressButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, PreviewModeIndicator, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useApplePayCheckout, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCredits, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useFunnelLegacy, useGeoLocation, useGoogleAutocomplete, useGooglePayCheckout, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffer, useOrder, useOrderBump, usePayment, usePaymentRetrieve, usePixelTracking, usePluginConfig, usePostPurchases, usePreloadQuery, usePreviewOffer, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStepConfig, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers, useSetPaymentMethod, WhopCheckout, useWhopPaymentPolling } from './react';
|