@tagadapay/plugin-sdk 3.1.5 → 3.1.9
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/README.md +1129 -1129
- package/build-cdn.js +220 -113
- package/dist/external-tracker.js +1225 -558
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/hooks/useApplePay.js +25 -36
- package/dist/react/hooks/usePaymentPolling.d.ts +9 -3
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/utils/money.d.ts +4 -3
- package/dist/react/utils/money.js +39 -6
- package/dist/react/utils/trackingUtils.js +1 -0
- package/dist/tagada-sdk.js +10142 -0
- package/dist/tagada-sdk.min.js +43 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/core/client.js +34 -2
- package/dist/v2/core/config/environment.js +9 -2
- package/dist/v2/core/funnelClient.d.ts +180 -2
- package/dist/v2/core/funnelClient.js +289 -6
- package/dist/v2/core/resources/apiClient.js +1 -1
- package/dist/v2/core/resources/checkout.d.ts +68 -0
- package/dist/v2/core/resources/funnel.d.ts +25 -0
- package/dist/v2/core/resources/payments.d.ts +70 -3
- package/dist/v2/core/resources/payments.js +72 -7
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +68 -5
- package/dist/v2/core/utils/previewMode.d.ts +7 -0
- package/dist/v2/core/utils/previewMode.js +72 -14
- package/dist/v2/core/utils/previewModeIndicator.d.ts +19 -0
- package/dist/v2/core/utils/previewModeIndicator.js +414 -0
- package/dist/v2/core/utils/tokenStorage.d.ts +4 -0
- package/dist/v2/core/utils/tokenStorage.js +15 -1
- package/dist/v2/index.d.ts +9 -3
- package/dist/v2/index.js +8 -3
- package/dist/v2/react/components/ApplePayButton.d.ts +22 -123
- package/dist/v2/react/components/ApplePayButton.js +247 -317
- package/dist/v2/react/components/FunnelScriptInjector.d.ts +3 -1
- package/dist/v2/react/components/FunnelScriptInjector.js +255 -162
- package/dist/v2/react/components/GooglePayButton.d.ts +2 -0
- package/dist/v2/react/components/GooglePayButton.js +80 -64
- package/dist/v2/react/components/PreviewModeIndicator.d.ts +46 -0
- package/dist/v2/react/components/PreviewModeIndicator.js +113 -0
- package/dist/v2/react/hooks/useApplePayCheckout.d.ts +16 -0
- package/dist/v2/react/hooks/useApplePayCheckout.js +193 -0
- package/dist/v2/react/hooks/useFunnel.d.ts +48 -6
- package/dist/v2/react/hooks/useFunnel.js +25 -5
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +10 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +48 -0
- package/dist/v2/react/hooks/useGooglePayCheckout.d.ts +21 -0
- package/dist/v2/react/hooks/useGooglePayCheckout.js +198 -0
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +15 -3
- package/dist/v2/react/hooks/usePaymentPolling.js +31 -9
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +34 -2
- package/dist/v2/react/hooks/usePaymentQuery.js +731 -7
- package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +26 -0
- package/dist/v2/react/hooks/usePaymentRetrieve.js +175 -0
- package/dist/v2/react/hooks/usePixelTracking.d.ts +56 -0
- package/dist/v2/react/hooks/usePixelTracking.js +508 -0
- package/dist/v2/react/hooks/useStepConfig.d.ts +64 -0
- package/dist/v2/react/hooks/useStepConfig.js +53 -0
- package/dist/v2/react/index.d.ts +15 -5
- package/dist/v2/react/index.js +8 -2
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +1 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +41 -13
- package/dist/v2/react/providers/TagadaProvider.js +24 -23
- package/dist/v2/standalone/external-tracker.d.ts +2 -0
- package/dist/v2/standalone/external-tracker.js +6 -3
- package/package.json +112 -112
- package/dist/v2/react/hooks/useApplePay.d.ts +0 -16
- package/dist/v2/react/hooks/useApplePay.js +0 -247
|
@@ -282,9 +282,7 @@ export function useApplePay(options = {}) {
|
|
|
282
282
|
// Tokenize the Apple Pay payment
|
|
283
283
|
const applePayToken = await tokenizeApplePay(event);
|
|
284
284
|
// Complete the Apple Pay session
|
|
285
|
-
session.completePayment(
|
|
286
|
-
status: window.ApplePaySession.STATUS_SUCCESS,
|
|
287
|
-
});
|
|
285
|
+
session.completePayment(window.ApplePaySession.STATUS_SUCCESS);
|
|
288
286
|
// Process the payment using the SDK's payment methods
|
|
289
287
|
await processApplePayPayment(checkoutSessionId, applePayToken, {
|
|
290
288
|
onSuccess: (payment) => {
|
|
@@ -300,9 +298,7 @@ export function useApplePay(options = {}) {
|
|
|
300
298
|
}
|
|
301
299
|
catch (error) {
|
|
302
300
|
console.error('Payment processing failed:', error);
|
|
303
|
-
session.completePayment(
|
|
304
|
-
status: window.ApplePaySession.STATUS_FAILURE,
|
|
305
|
-
});
|
|
301
|
+
session.completePayment(window.ApplePaySession.STATUS_FAILURE);
|
|
306
302
|
setProcessingPayment(false);
|
|
307
303
|
const errorMsg = error instanceof Error ? error.message : 'Payment processing failed';
|
|
308
304
|
setError(errorMsg);
|
|
@@ -321,18 +317,15 @@ export function useApplePay(options = {}) {
|
|
|
321
317
|
return;
|
|
322
318
|
}
|
|
323
319
|
const { lineItems: newLineItems, total: newTotal } = newOrderSummary;
|
|
324
|
-
session.completeShippingMethodSelection({
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
type: 'final',
|
|
334
|
-
})),
|
|
335
|
-
});
|
|
320
|
+
session.completeShippingMethodSelection(window.ApplePaySession.STATUS_SUCCESS, {
|
|
321
|
+
label: newTotal.label,
|
|
322
|
+
amount: newTotal.amount,
|
|
323
|
+
type: 'final',
|
|
324
|
+
}, newLineItems.map(item => ({
|
|
325
|
+
label: item.label,
|
|
326
|
+
amount: item.amount,
|
|
327
|
+
type: 'final',
|
|
328
|
+
})));
|
|
336
329
|
}
|
|
337
330
|
catch (error) {
|
|
338
331
|
console.error('Shipping method selection failed:', error);
|
|
@@ -358,24 +351,20 @@ export function useApplePay(options = {}) {
|
|
|
358
351
|
console.log('======= APPLE PAY ON SHIPPING CONTACT SELECTED ======');
|
|
359
352
|
console.log('newOrderSummary', newOrderSummary);
|
|
360
353
|
console.log(newLineItems, newTotal, newShippingMethods);
|
|
361
|
-
session.completeShippingContactSelection({
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
amount: item.amount,
|
|
376
|
-
type: 'final',
|
|
377
|
-
})),
|
|
378
|
-
});
|
|
354
|
+
session.completeShippingContactSelection(window.ApplePaySession.STATUS_SUCCESS, newShippingMethods.map(method => ({
|
|
355
|
+
label: method.label,
|
|
356
|
+
amount: method.amount,
|
|
357
|
+
detail: method.detail,
|
|
358
|
+
identifier: method.identifier,
|
|
359
|
+
})), {
|
|
360
|
+
label: newTotal.label,
|
|
361
|
+
amount: newTotal.amount,
|
|
362
|
+
type: 'final',
|
|
363
|
+
}, newLineItems.map(item => ({
|
|
364
|
+
label: item.label,
|
|
365
|
+
amount: item.amount,
|
|
366
|
+
type: 'final',
|
|
367
|
+
})));
|
|
379
368
|
}
|
|
380
369
|
catch (error) {
|
|
381
370
|
console.error('Shipping contact selection failed:', error);
|
|
@@ -2,14 +2,14 @@ export interface Payment {
|
|
|
2
2
|
id: string;
|
|
3
3
|
status: string;
|
|
4
4
|
subStatus: string;
|
|
5
|
-
requireAction: 'none' | 'redirect' | 'error';
|
|
5
|
+
requireAction: 'none' | 'redirect' | 'error' | 'radar';
|
|
6
6
|
requireActionData?: {
|
|
7
|
-
type: 'redirect' | 'threeds_auth' | 'processor_auth' | 'error';
|
|
7
|
+
type: 'redirect' | 'threeds_auth' | 'processor_auth' | 'error' | 'stripe_radar' | 'finix_radar';
|
|
8
8
|
url?: string;
|
|
9
9
|
processed: boolean;
|
|
10
10
|
processorId?: string;
|
|
11
11
|
metadata?: {
|
|
12
|
-
type: 'redirect';
|
|
12
|
+
type: 'redirect' | 'stripe_radar' | 'finix_radar';
|
|
13
13
|
redirect?: {
|
|
14
14
|
redirectUrl: string;
|
|
15
15
|
returnUrl: string;
|
|
@@ -20,6 +20,12 @@ export interface Payment {
|
|
|
20
20
|
acsTransID: string;
|
|
21
21
|
messageVersion: string;
|
|
22
22
|
};
|
|
23
|
+
radar?: {
|
|
24
|
+
merchantId: string;
|
|
25
|
+
environment: 'sandbox' | 'live';
|
|
26
|
+
orderId?: string;
|
|
27
|
+
publishableKey?: string;
|
|
28
|
+
};
|
|
23
29
|
};
|
|
24
30
|
redirectUrl?: string;
|
|
25
31
|
resumeToken?: string;
|
|
@@ -38,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
38
38
|
borderTop: '1.5px solid #9ca3af',
|
|
39
39
|
borderRadius: '50%',
|
|
40
40
|
animation: 'tagada-spin 1s linear infinite',
|
|
41
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
-
@keyframes tagada-spin {
|
|
43
|
-
0% { transform: rotate(0deg); }
|
|
44
|
-
100% { transform: rotate(360deg); }
|
|
45
|
-
}
|
|
41
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
+
@keyframes tagada-spin {
|
|
43
|
+
0% { transform: rotate(0deg); }
|
|
44
|
+
100% { transform: rotate(360deg); }
|
|
45
|
+
}
|
|
46
46
|
` })] }));
|
|
47
47
|
const TagadaContext = createContext(null);
|
|
48
48
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
|
|
@@ -2251,12 +2251,11 @@ export declare function getCurrencyInfo(currencyCode: string): {
|
|
|
2251
2251
|
* Convert a money string or number to minor units
|
|
2252
2252
|
*/
|
|
2253
2253
|
export declare function moneyStringOrNumberToMinorUnits(moneyStringOrNumber: string | number, currencyCode: string): number;
|
|
2254
|
-
/**
|
|
2255
|
-
* Convert minor units to major units (decimal value)
|
|
2256
|
-
*/
|
|
2257
2254
|
export declare function minorUnitsToMajorUnits(amountMinorUnits: number, currencyCode: string): number;
|
|
2258
2255
|
/**
|
|
2259
2256
|
* Format money without currency symbol, just the numeric value
|
|
2257
|
+
* Note: The backend stores all amounts with 2 decimal places (multiplied by 100),
|
|
2258
|
+
* even for currencies with 0 decimal places like JPY.
|
|
2260
2259
|
*/
|
|
2261
2260
|
export declare const formatMoneyWithoutSymbol: ({ amount, currencyCode, fromCents, }: {
|
|
2262
2261
|
amount: number;
|
|
@@ -2269,5 +2268,7 @@ export declare const formatMoneyWithoutSymbol: ({ amount, currencyCode, fromCent
|
|
|
2269
2268
|
export declare const convertCurrency: (amount: number, fromCurrency: string, toCurrency: string, rate: number) => number;
|
|
2270
2269
|
/**
|
|
2271
2270
|
* Simple money formatter for quick use (similar to the existing useCurrency format function)
|
|
2271
|
+
* Note: The backend stores all amounts with 2 decimal places (multiplied by 100),
|
|
2272
|
+
* even for currencies with 0 decimal places like JPY.
|
|
2272
2273
|
*/
|
|
2273
2274
|
export declare function formatSimpleMoney(amount: number, currencyCode: string): string;
|
|
@@ -42,7 +42,22 @@ export function formatMoney(amountMinorUnits, currencyCode = 'USD', locale) {
|
|
|
42
42
|
throw new Error(`Currency ${currencyCode} not found in currency data.`);
|
|
43
43
|
}
|
|
44
44
|
// Convert minor units to major units
|
|
45
|
-
|
|
45
|
+
// Note: The backend stores all amounts with 2 decimal places (multiplied by 100),
|
|
46
|
+
// regardless of the currency's ISOdigits. This means:
|
|
47
|
+
// - For ISOdigits: 0 (JPY, KRW, etc.) → divide by 100 (not 10^0 = 1)
|
|
48
|
+
// - For ISOdigits: 2 (USD, EUR, etc.) → divide by 100 (matches 10^2)
|
|
49
|
+
// - For ISOdigits: 3 (KWD, BHD, etc.) → divide by 100 (not 10^3 = 1000)
|
|
50
|
+
// Note: This means currencies with 3 decimal places lose precision (3rd decimal is lost)
|
|
51
|
+
let value;
|
|
52
|
+
if (currencyInfo.ISOdigits === 0 || currencyInfo.ISOdigits === 3) {
|
|
53
|
+
// Backend stores amounts with 2 decimal places for all currencies
|
|
54
|
+
// For currencies with 0 or 3 decimal places, divide by 100 to convert from backend format
|
|
55
|
+
value = amountMinorUnits / 100;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// For currencies with 2 decimal places (most common), use the standard conversion
|
|
59
|
+
value = amountMinorUnits / Math.pow(10, currencyInfo.ISOdigits);
|
|
60
|
+
}
|
|
46
61
|
return formatCurrency(value, safeLocale, currencyCode);
|
|
47
62
|
}
|
|
48
63
|
/**
|
|
@@ -63,23 +78,36 @@ export function moneyStringOrNumberToMinorUnits(moneyStringOrNumber, currencyCod
|
|
|
63
78
|
const value = typeof moneyStringOrNumber === 'string' ? parseFloat(moneyStringOrNumber) : moneyStringOrNumber;
|
|
64
79
|
return Math.round(value * Math.pow(10, currencyInfo.ISOdigits));
|
|
65
80
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Convert minor units to major units (decimal value)
|
|
68
|
-
*/
|
|
69
81
|
export function minorUnitsToMajorUnits(amountMinorUnits, currencyCode) {
|
|
70
82
|
const currencyInfo = currencyData[currencyCode];
|
|
71
83
|
if (!currencyInfo) {
|
|
72
84
|
throw new Error(`Currency ${currencyCode} not found in currency data.`);
|
|
73
85
|
}
|
|
86
|
+
// Backend stores amounts with 2 decimal places for all currencies
|
|
87
|
+
// For currencies with 0 or 3 decimal places, divide by 100 to convert from backend format
|
|
88
|
+
if (currencyInfo.ISOdigits === 0 || currencyInfo.ISOdigits === 3) {
|
|
89
|
+
return amountMinorUnits / 100;
|
|
90
|
+
}
|
|
74
91
|
return amountMinorUnits / Math.pow(10, currencyInfo.ISOdigits);
|
|
75
92
|
}
|
|
76
93
|
/**
|
|
77
94
|
* Format money without currency symbol, just the numeric value
|
|
95
|
+
* Note: The backend stores all amounts with 2 decimal places (multiplied by 100),
|
|
96
|
+
* even for currencies with 0 decimal places like JPY.
|
|
78
97
|
*/
|
|
79
98
|
export const formatMoneyWithoutSymbol = ({ amount, currencyCode, fromCents = true, }) => {
|
|
80
99
|
const currencyInfo = currencyData[currencyCode];
|
|
81
100
|
const digits = currencyInfo?.ISOdigits || 2;
|
|
82
|
-
|
|
101
|
+
let value;
|
|
102
|
+
if (fromCents) {
|
|
103
|
+
// Backend stores amounts with 2 decimal places for all currencies
|
|
104
|
+
// For currencies with 0 or 3 decimal places, divide by 100 to convert from backend format
|
|
105
|
+
const divisor = digits === 0 || digits === 3 ? 100 : Math.pow(10, digits);
|
|
106
|
+
value = amount / divisor;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
value = amount;
|
|
110
|
+
}
|
|
83
111
|
return new Intl.NumberFormat('en-US', {
|
|
84
112
|
minimumFractionDigits: digits,
|
|
85
113
|
maximumFractionDigits: digits,
|
|
@@ -95,10 +123,15 @@ export const convertCurrency = (amount, fromCurrency, toCurrency, rate) => {
|
|
|
95
123
|
};
|
|
96
124
|
/**
|
|
97
125
|
* Simple money formatter for quick use (similar to the existing useCurrency format function)
|
|
126
|
+
* Note: The backend stores all amounts with 2 decimal places (multiplied by 100),
|
|
127
|
+
* even for currencies with 0 decimal places like JPY.
|
|
98
128
|
*/
|
|
99
129
|
export function formatSimpleMoney(amount, currencyCode) {
|
|
100
130
|
const currencyInfo = currencyData[currencyCode];
|
|
101
131
|
const symbol = currencyInfo?.symbol || currencyCode;
|
|
102
132
|
const digits = currencyInfo?.ISOdigits || 2;
|
|
103
|
-
|
|
133
|
+
// Backend stores amounts with 2 decimal places for all currencies
|
|
134
|
+
// For currencies with 0 or 3 decimal places, divide by 100 to convert from backend format
|
|
135
|
+
const divisor = digits === 0 || digits === 3 ? 100 : Math.pow(10, digits);
|
|
136
|
+
return `${symbol}${(amount / divisor).toFixed(digits)}`;
|
|
104
137
|
}
|