@tagadapay/plugin-sdk 3.0.15 → 3.1.1
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 +113 -113
- package/dist/external-tracker.js +1 -1
- package/dist/external-tracker.min.js +1 -1
- package/dist/external-tracker.min.js.map +1 -1
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/v2/react/components/ApplePayButton.js +125 -37
- package/dist/v2/react/components/FunnelScriptInjector.d.ts +14 -0
- package/dist/v2/react/components/FunnelScriptInjector.js +242 -0
- package/dist/v2/react/hooks/useApplePay.d.ts +16 -0
- package/dist/v2/react/hooks/useApplePay.js +247 -0
- package/dist/v2/react/index.d.ts +2 -0
- package/dist/v2/react/index.js +1 -0
- package/dist/v2/react/providers/TagadaProvider.js +8 -67
- package/package.json +112 -112
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apple Pay Hook for v2 Architecture
|
|
3
|
+
* Handles Apple Pay payment flow with Basis Theory integration
|
|
4
|
+
*/
|
|
5
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
6
|
+
import { getBasisTheoryApiKey } from '../../../react/config/payment';
|
|
7
|
+
import { minorUnitsToMajorUnits, getCurrencyInfo } from '../../../react/utils/money';
|
|
8
|
+
import { useCheckoutQuery } from './useCheckoutQuery';
|
|
9
|
+
import { usePaymentQuery } from './usePaymentQuery';
|
|
10
|
+
import { PaymentsResource } from '../../core/resources/payments';
|
|
11
|
+
import { OrdersResource } from '../../core/resources/orders';
|
|
12
|
+
import { getGlobalApiClient } from './useApiQuery';
|
|
13
|
+
export function useApplePay(options = {}) {
|
|
14
|
+
const [processingPayment, setProcessingPayment] = useState(false);
|
|
15
|
+
const [error, setError] = useState(null);
|
|
16
|
+
const [isAvailable, setIsAvailable] = useState(false);
|
|
17
|
+
const { checkout } = useCheckoutQuery();
|
|
18
|
+
const { createApplePayPaymentInstrument } = usePaymentQuery();
|
|
19
|
+
const checkoutSessionId = checkout?.checkoutSession?.id;
|
|
20
|
+
const store = checkout?.checkoutSession?.store;
|
|
21
|
+
const summary = checkout?.summary;
|
|
22
|
+
const basistheoryPublicKey = getBasisTheoryApiKey();
|
|
23
|
+
// Create SDK resource clients
|
|
24
|
+
const paymentsResource = new PaymentsResource(getGlobalApiClient());
|
|
25
|
+
const ordersResource = new OrdersResource(getGlobalApiClient());
|
|
26
|
+
// Helper to convert minor units to currency string for Apple Pay
|
|
27
|
+
const minorUnitsToCurrencyString = useCallback((amountMinor, currency) => {
|
|
28
|
+
if (!amountMinor || !currency)
|
|
29
|
+
return '0.00';
|
|
30
|
+
const currencyInfo = getCurrencyInfo(currency);
|
|
31
|
+
if (!currencyInfo) {
|
|
32
|
+
console.warn(`Currency info not found for ${currency}, using fallback`);
|
|
33
|
+
return (amountMinor / 100).toFixed(2);
|
|
34
|
+
}
|
|
35
|
+
const majorUnits = minorUnitsToMajorUnits(amountMinor, currency);
|
|
36
|
+
return majorUnits.toFixed(currencyInfo.ISOdigits);
|
|
37
|
+
}, []);
|
|
38
|
+
// Check Apple Pay availability on mount
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const checkApplePayAvailability = () => {
|
|
41
|
+
if (typeof window === 'undefined' || !window.ApplePaySession) {
|
|
42
|
+
setIsAvailable(false);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const canMakePayments = window.ApplePaySession.canMakePayments();
|
|
47
|
+
setIsAvailable(canMakePayments);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error checking Apple Pay availability:', error);
|
|
51
|
+
setIsAvailable(false);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
checkApplePayAvailability();
|
|
55
|
+
}, []);
|
|
56
|
+
// Validate merchant with Basis Theory
|
|
57
|
+
const validateMerchant = useCallback(async () => {
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch('https://api.basistheory.com/apple-pay/session', {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'BT-API-KEY': basistheoryPublicKey,
|
|
64
|
+
},
|
|
65
|
+
body: JSON.stringify({
|
|
66
|
+
display_name: store?.name || 'Store',
|
|
67
|
+
domain: window.location.host,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
72
|
+
}
|
|
73
|
+
return response.json();
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
console.error('Merchant validation failed:', err);
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
}, [basistheoryPublicKey, store?.name]);
|
|
80
|
+
// Tokenize Apple Pay payment with Basis Theory
|
|
81
|
+
const tokenizeApplePay = useCallback(async (event) => {
|
|
82
|
+
try {
|
|
83
|
+
const response = await fetch('https://api.basistheory.com/apple-pay', {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
'BT-API-KEY': basistheoryPublicKey,
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify({
|
|
90
|
+
apple_payment_data: event.payment.token,
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
setError('Payment Failed');
|
|
95
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
96
|
+
}
|
|
97
|
+
const result = await response.json();
|
|
98
|
+
return result.apple_pay; // Basis Theory returns the Apple Pay token in the apple_pay field
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error('Tokenization failed:', error);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}, [basistheoryPublicKey]);
|
|
105
|
+
// Charge payment using SDK methods
|
|
106
|
+
const chargePayment = useCallback(async (applePayToken) => {
|
|
107
|
+
if (!checkoutSessionId) {
|
|
108
|
+
throw new Error('Checkout session ID not available');
|
|
109
|
+
}
|
|
110
|
+
setProcessingPayment(true);
|
|
111
|
+
try {
|
|
112
|
+
// 1. Tokenize with Basis Theory (already done - we have applePayToken)
|
|
113
|
+
// 2. Create payment instrument from the tokenized Apple Pay payment
|
|
114
|
+
const paymentInstrumentData = {
|
|
115
|
+
type: 'apple_pay',
|
|
116
|
+
token: applePayToken.id,
|
|
117
|
+
dpanType: applePayToken.type,
|
|
118
|
+
card: {
|
|
119
|
+
bin: applePayToken.card.bin,
|
|
120
|
+
last4: applePayToken.card.last4,
|
|
121
|
+
expirationMonth: applePayToken.card.expiration_month,
|
|
122
|
+
expirationYear: applePayToken.card.expiration_year,
|
|
123
|
+
brand: applePayToken.card.brand,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
const paymentInstrument = await paymentsResource.createPaymentInstrument(paymentInstrumentData);
|
|
127
|
+
if (!paymentInstrument?.id) {
|
|
128
|
+
throw new Error('Failed to create payment instrument');
|
|
129
|
+
}
|
|
130
|
+
// 3. Create order from checkout session
|
|
131
|
+
const orderResponse = await ordersResource.createOrder(checkoutSessionId);
|
|
132
|
+
if (!orderResponse?.success || !orderResponse?.order?.id) {
|
|
133
|
+
throw new Error('Failed to create order');
|
|
134
|
+
}
|
|
135
|
+
// 4. Process payment
|
|
136
|
+
const paymentResult = await paymentsResource.processPaymentDirect(checkoutSessionId, paymentInstrument.id, undefined, {
|
|
137
|
+
initiatedBy: 'customer',
|
|
138
|
+
source: 'checkout',
|
|
139
|
+
});
|
|
140
|
+
if (options.onSuccess) {
|
|
141
|
+
options.onSuccess(paymentResult);
|
|
142
|
+
}
|
|
143
|
+
return paymentResult;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error('Payment failed:', error);
|
|
147
|
+
const errorMessage = error instanceof Error ? error.message : 'Payment Failed';
|
|
148
|
+
setError(errorMessage);
|
|
149
|
+
if (options.onError) {
|
|
150
|
+
options.onError(errorMessage);
|
|
151
|
+
}
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
setProcessingPayment(false);
|
|
156
|
+
}
|
|
157
|
+
}, [checkoutSessionId, paymentsResource, ordersResource, options]);
|
|
158
|
+
// Handle Apple Pay button click - opens Apple Pay sheet
|
|
159
|
+
const handleApplePayClick = useCallback(() => {
|
|
160
|
+
if (!summary || !store) {
|
|
161
|
+
console.error('Order summary or store not available');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const total = {
|
|
165
|
+
label: store.name || 'Store',
|
|
166
|
+
amount: minorUnitsToCurrencyString(summary.totalAdjustedAmount, summary.currency),
|
|
167
|
+
type: 'final',
|
|
168
|
+
};
|
|
169
|
+
const lineItems = [
|
|
170
|
+
{
|
|
171
|
+
label: 'Subtotal',
|
|
172
|
+
amount: minorUnitsToCurrencyString(summary.subtotalAdjustedAmount, summary.currency),
|
|
173
|
+
type: 'final',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
label: 'Shipping',
|
|
177
|
+
amount: minorUnitsToCurrencyString(summary.shippingCost ?? 0, summary.currency),
|
|
178
|
+
type: 'final',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Tax',
|
|
182
|
+
amount: minorUnitsToCurrencyString(summary.totalTaxAmount, summary.currency),
|
|
183
|
+
type: 'final',
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
const request = {
|
|
187
|
+
countryCode: 'US', // TODO: Get from checkout session metadata
|
|
188
|
+
currencyCode: summary.currency,
|
|
189
|
+
supportedNetworks: ['visa', 'masterCard', 'amex', 'discover'],
|
|
190
|
+
merchantCapabilities: ['supports3DS'],
|
|
191
|
+
total,
|
|
192
|
+
lineItems,
|
|
193
|
+
};
|
|
194
|
+
try {
|
|
195
|
+
const session = new ApplePaySession(3, request);
|
|
196
|
+
session.onvalidatemerchant = (event) => {
|
|
197
|
+
void (async () => {
|
|
198
|
+
try {
|
|
199
|
+
console.log('Merchant validation requested for:', event.validationURL);
|
|
200
|
+
const merchantSession = await validateMerchant();
|
|
201
|
+
session.completeMerchantValidation(merchantSession);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
console.error('Merchant validation failed:', error);
|
|
205
|
+
session.abort();
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
};
|
|
209
|
+
session.onpaymentauthorized = (event) => {
|
|
210
|
+
void (async () => {
|
|
211
|
+
try {
|
|
212
|
+
const applePayToken = await tokenizeApplePay(event);
|
|
213
|
+
session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
|
214
|
+
await chargePayment(applePayToken);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
console.error('Payment processing failed:', error);
|
|
218
|
+
session.completePayment(ApplePaySession.STATUS_FAILURE);
|
|
219
|
+
}
|
|
220
|
+
})();
|
|
221
|
+
};
|
|
222
|
+
session.onerror = (event) => {
|
|
223
|
+
console.error('Apple Pay Session Error:', event);
|
|
224
|
+
};
|
|
225
|
+
session.oncancel = () => {
|
|
226
|
+
console.log('Payment cancelled by user');
|
|
227
|
+
if (options.onCancel) {
|
|
228
|
+
options.onCancel();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
session.begin();
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error('Failed to start Apple Pay session:', error);
|
|
235
|
+
setError('Failed to start Apple Pay session');
|
|
236
|
+
if (options.onError) {
|
|
237
|
+
options.onError('Failed to start Apple Pay session');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, [summary, store, minorUnitsToCurrencyString, validateMerchant, tokenizeApplePay, chargePayment, options]);
|
|
241
|
+
return {
|
|
242
|
+
handleApplePayClick,
|
|
243
|
+
processingPayment,
|
|
244
|
+
applePayError: error,
|
|
245
|
+
isAvailable,
|
|
246
|
+
};
|
|
247
|
+
}
|
package/dist/v2/react/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { TagadaProvider, useTagadaContext } from './providers/TagadaProvider';
|
|
|
7
7
|
export type { DebugScript } from './providers/TagadaProvider';
|
|
8
8
|
export { ApplePayButton } from './components/ApplePayButton';
|
|
9
9
|
export { GooglePayButton } from './components/GooglePayButton';
|
|
10
|
+
export { useApplePay } from './hooks/useApplePay';
|
|
10
11
|
export { useAuth } from './hooks/useAuth';
|
|
11
12
|
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
12
13
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
@@ -42,6 +43,7 @@ export { useTranslation } from './hooks/useTranslation';
|
|
|
42
43
|
export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
|
|
43
44
|
export { useFunnel } from './hooks/useFunnel';
|
|
44
45
|
export { useFunnel as useFunnelLegacy, useSimpleFunnel } from './hooks/useFunnelLegacy';
|
|
46
|
+
export type { UseApplePayOptions, UseApplePayResult } from './hooks/useApplePay';
|
|
45
47
|
export type { UseCheckoutTokenOptions, UseCheckoutTokenResult } from './hooks/useCheckoutToken';
|
|
46
48
|
export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './hooks/useClubOffers';
|
|
47
49
|
export type { UseCreditsOptions, UseCreditsResult } from './hooks/useCredits';
|
package/dist/v2/react/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { TagadaProvider, useTagadaContext } from './providers/TagadaProvider';
|
|
|
9
9
|
export { ApplePayButton } from './components/ApplePayButton';
|
|
10
10
|
export { GooglePayButton } from './components/GooglePayButton';
|
|
11
11
|
// Hooks
|
|
12
|
+
export { useApplePay } from './hooks/useApplePay';
|
|
12
13
|
export { useAuth } from './hooks/useAuth';
|
|
13
14
|
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
14
15
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
@@ -4,11 +4,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* TagadaProvider - Main provider component for the Tagada Pay React SDK
|
|
5
5
|
*/
|
|
6
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
7
|
-
import { createContext, useCallback, useContext, useEffect, useMemo,
|
|
7
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { ApiService } from '../../../react/services/apiService';
|
|
9
9
|
import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from '../../../react/utils/money';
|
|
10
10
|
import { TagadaClient } from '../../core/client';
|
|
11
11
|
import { default as DebugDrawer } from '../components/DebugDrawer';
|
|
12
|
+
import { FunnelScriptInjector } from '../components/FunnelScriptInjector';
|
|
12
13
|
import { setGlobalApiClient } from '../hooks/useApiQuery';
|
|
13
14
|
// Professional, subtle loading component for initialization
|
|
14
15
|
const InitializationLoader = () => (_jsxs("div", { style: {
|
|
@@ -36,11 +37,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
36
37
|
borderTop: '1.5px solid #9ca3af',
|
|
37
38
|
borderRadius: '50%',
|
|
38
39
|
animation: 'tagada-spin 1s linear infinite',
|
|
39
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
40
|
-
@keyframes tagada-spin {
|
|
41
|
-
0% { transform: rotate(0deg); }
|
|
42
|
-
100% { transform: rotate(360deg); }
|
|
43
|
-
}
|
|
40
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
41
|
+
@keyframes tagada-spin {
|
|
42
|
+
0% { transform: rotate(0deg); }
|
|
43
|
+
100% { transform: rotate(360deg); }
|
|
44
|
+
}
|
|
44
45
|
` })] }));
|
|
45
46
|
const TagadaContext = createContext(null);
|
|
46
47
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, features, funnelId, autoInitializeFunnel = true, onNavigate, onFunnelError, debugScripts = [], }) {
|
|
@@ -211,8 +212,6 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
211
212
|
formatSimpleMoney,
|
|
212
213
|
}), []);
|
|
213
214
|
const [isDebugDrawerOpen, setIsDebugDrawerOpen] = useState(false);
|
|
214
|
-
// Track last injected script to prevent duplicate execution
|
|
215
|
-
const lastInjectedScriptRef = useRef(null);
|
|
216
215
|
// Funnel Methods
|
|
217
216
|
const funnelMethods = useMemo(() => {
|
|
218
217
|
if (!client.funnel) {
|
|
@@ -285,63 +284,6 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
285
284
|
},
|
|
286
285
|
};
|
|
287
286
|
}, [client, state.auth.session, state.store, funnelId, onNavigate]);
|
|
288
|
-
// Inject funnel script into the page
|
|
289
|
-
useEffect(() => {
|
|
290
|
-
// Only run in browser environment
|
|
291
|
-
if (typeof document === 'undefined') {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const scriptContent = funnelState.context?.script;
|
|
295
|
-
const scriptId = 'tagada-funnel-script';
|
|
296
|
-
if (!scriptContent || !scriptContent.trim()) {
|
|
297
|
-
// Clear ref if script is removed
|
|
298
|
-
lastInjectedScriptRef.current = null;
|
|
299
|
-
// Remove existing script if it exists
|
|
300
|
-
const existingScript = document.getElementById(scriptId);
|
|
301
|
-
if (existingScript) {
|
|
302
|
-
existingScript.remove();
|
|
303
|
-
}
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
// Extract script content (remove <script> tags if present)
|
|
307
|
-
let scriptBody = scriptContent.trim();
|
|
308
|
-
// Check if script is wrapped in <script> tags
|
|
309
|
-
const scriptTagMatch = scriptBody.match(/^<script[^>]*>([\s\S]*)<\/script>$/i);
|
|
310
|
-
if (scriptTagMatch) {
|
|
311
|
-
scriptBody = scriptTagMatch[1].trim();
|
|
312
|
-
}
|
|
313
|
-
// Skip if script body is empty after extraction
|
|
314
|
-
if (!scriptBody) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
// Prevent duplicate injection of the same script content
|
|
318
|
-
// This handles React StrictMode double-execution in development
|
|
319
|
-
if (lastInjectedScriptRef.current === scriptBody) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
// Remove existing script if it exists (for script updates)
|
|
323
|
-
const existingScript = document.getElementById(scriptId);
|
|
324
|
-
if (existingScript) {
|
|
325
|
-
existingScript.remove();
|
|
326
|
-
}
|
|
327
|
-
// Create and inject new script element
|
|
328
|
-
const scriptElement = document.createElement('script');
|
|
329
|
-
scriptElement.id = scriptId;
|
|
330
|
-
scriptElement.textContent = scriptBody;
|
|
331
|
-
document.body.appendChild(scriptElement);
|
|
332
|
-
// Track this script content to prevent re-injection (handles React StrictMode double-execution)
|
|
333
|
-
lastInjectedScriptRef.current = scriptBody;
|
|
334
|
-
// Cleanup: remove script element but keep ref to prevent re-injection on StrictMode second run
|
|
335
|
-
return () => {
|
|
336
|
-
const scriptToRemove = document.getElementById(scriptId);
|
|
337
|
-
if (scriptToRemove) {
|
|
338
|
-
scriptToRemove.remove();
|
|
339
|
-
}
|
|
340
|
-
// Note: We intentionally DON'T clear lastInjectedScriptRef here
|
|
341
|
-
// This prevents React StrictMode from re-injecting the same script on the second run
|
|
342
|
-
// The ref will be cleared when script content actually changes (next effect run)
|
|
343
|
-
};
|
|
344
|
-
}, [funnelState.context?.script]);
|
|
345
287
|
const contextValue = {
|
|
346
288
|
client,
|
|
347
289
|
...state,
|
|
@@ -360,7 +302,6 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
360
302
|
refreshCoordinator,
|
|
361
303
|
money: moneyUtils,
|
|
362
304
|
};
|
|
363
|
-
console.log('contextValue', contextValue, contextValue.funnel.currentStep);
|
|
364
305
|
// Query Client
|
|
365
306
|
const [queryClient] = useState(() => new QueryClient({
|
|
366
307
|
defaultOptions: {
|
|
@@ -378,7 +319,7 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
378
319
|
// Loading State Logic
|
|
379
320
|
const shouldShowLoading = state.isLoading || state.pluginConfigLoading || (blockUntilSessionReady && !state.isSessionInitialized);
|
|
380
321
|
const canRenderChildren = !state.pluginConfigLoading && (!blockUntilSessionReady || state.isSessionInitialized);
|
|
381
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(TagadaContext.Provider, { value: contextValue, children: [shouldShowLoading && _jsx(InitializationLoader, {}), state.debugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
322
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(TagadaContext.Provider, { value: contextValue, children: [_jsx(FunnelScriptInjector, { ...funnelState }), shouldShowLoading && _jsx(InitializationLoader, {}), state.debugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
382
323
|
position: 'fixed',
|
|
383
324
|
bottom: '16px',
|
|
384
325
|
right: '16px',
|
package/package.json
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./react": {
|
|
14
|
-
"types": "./dist/react/index.d.ts",
|
|
15
|
-
"import": "./dist/react/index.js",
|
|
16
|
-
"require": "./dist/react/index.js"
|
|
17
|
-
},
|
|
18
|
-
"./v2": {
|
|
19
|
-
"types": "./dist/v2/index.d.ts",
|
|
20
|
-
"import": "./dist/v2/index.js",
|
|
21
|
-
"require": "./dist/v2/index.js"
|
|
22
|
-
},
|
|
23
|
-
"./v2/standalone": {
|
|
24
|
-
"types": "./dist/v2/standalone/index.d.ts",
|
|
25
|
-
"import": "./dist/v2/standalone/index.js",
|
|
26
|
-
"require": "./dist/v2/standalone/index.js"
|
|
27
|
-
},
|
|
28
|
-
"./external-tracker": {
|
|
29
|
-
"browser": "./dist/external-tracker.min.js",
|
|
30
|
-
"default": "./dist/external-tracker.min.js"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"build": "tsc && npm run build:cdn",
|
|
35
|
-
"build:cdn": "node build-cdn.js",
|
|
36
|
-
"build:ts": "tsc",
|
|
37
|
-
"clean": "rm -rf dist",
|
|
38
|
-
"lint": "echo \"No linting configured\"",
|
|
39
|
-
"test": "jest --no-watchman",
|
|
40
|
-
"test:watch": "jest --watch --no-watchman",
|
|
41
|
-
"test:coverage": "jest --coverage --no-watchman",
|
|
42
|
-
"dev": "tsc --watch",
|
|
43
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
44
|
-
"publish:patch": "npm version patch && npm publish",
|
|
45
|
-
"publish:minor": "npm version minor && npm publish",
|
|
46
|
-
"publish:major": "npm version major && npm publish",
|
|
47
|
-
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
48
|
-
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
49
|
-
"version:patch": "npm version patch",
|
|
50
|
-
"version:minor": "npm version minor",
|
|
51
|
-
"version:major": "npm version major",
|
|
52
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
53
|
-
"version:alpha": "npm version prerelease --preid=alpha",
|
|
54
|
-
"version:check": "node version-sync.js check",
|
|
55
|
-
"version:sync": "node version-sync.js sync",
|
|
56
|
-
"version:list": "node version-sync.js list",
|
|
57
|
-
"version:next": "node version-sync.js next",
|
|
58
|
-
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
59
|
-
},
|
|
60
|
-
"keywords": [
|
|
61
|
-
"tagadapay",
|
|
62
|
-
"cms",
|
|
63
|
-
"plugin",
|
|
64
|
-
"sdk",
|
|
65
|
-
"react",
|
|
66
|
-
"typescript"
|
|
67
|
-
],
|
|
68
|
-
"author": "Tagada Pay",
|
|
69
|
-
"license": "MIT",
|
|
70
|
-
"dependencies": {
|
|
71
|
-
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
72
|
-
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
73
|
-
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
74
|
-
"@basis-theory/web-threeds": "^1.0.1",
|
|
75
|
-
"@google-pay/button-react": "^3.0.10",
|
|
76
|
-
"@tagadapay/plugin-sdk": "link:",
|
|
77
|
-
"@tanstack/react-query": "^5.90.2",
|
|
78
|
-
"@ua-parser-js/pro-enterprise": "^2.0.6",
|
|
79
|
-
"axios": "^1.10.0",
|
|
80
|
-
"iso3166-2-db": "^2.3.11",
|
|
81
|
-
"path-to-regexp": "^8.2.0",
|
|
82
|
-
"react-intl": "^7.1.11",
|
|
83
|
-
"swr": "^2.3.6"
|
|
84
|
-
},
|
|
85
|
-
"devDependencies": {
|
|
86
|
-
"@types/jest": "^29.5.0",
|
|
87
|
-
"@types/node": "^18.0.0",
|
|
88
|
-
"@types/react": "^19",
|
|
89
|
-
"@types/react-dom": "^19",
|
|
90
|
-
"esbuild": "^0.24.2",
|
|
91
|
-
"jest": "^29.5.0",
|
|
92
|
-
"ts-jest": "^29.1.0",
|
|
93
|
-
"typescript": "^5.0.0"
|
|
94
|
-
},
|
|
95
|
-
"peerDependencies": {
|
|
96
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
97
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
98
|
-
},
|
|
99
|
-
"files": [
|
|
100
|
-
"dist/**/*",
|
|
101
|
-
"README.md",
|
|
102
|
-
"build-cdn.js"
|
|
103
|
-
],
|
|
104
|
-
"repository": {
|
|
105
|
-
"type": "git",
|
|
106
|
-
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
107
|
-
},
|
|
108
|
-
"bugs": {
|
|
109
|
-
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
110
|
-
},
|
|
111
|
-
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
112
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "3.1.1",
|
|
4
|
+
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react/index.d.ts",
|
|
15
|
+
"import": "./dist/react/index.js",
|
|
16
|
+
"require": "./dist/react/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./v2": {
|
|
19
|
+
"types": "./dist/v2/index.d.ts",
|
|
20
|
+
"import": "./dist/v2/index.js",
|
|
21
|
+
"require": "./dist/v2/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./v2/standalone": {
|
|
24
|
+
"types": "./dist/v2/standalone/index.d.ts",
|
|
25
|
+
"import": "./dist/v2/standalone/index.js",
|
|
26
|
+
"require": "./dist/v2/standalone/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./external-tracker": {
|
|
29
|
+
"browser": "./dist/external-tracker.min.js",
|
|
30
|
+
"default": "./dist/external-tracker.min.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc && npm run build:cdn",
|
|
35
|
+
"build:cdn": "node build-cdn.js",
|
|
36
|
+
"build:ts": "tsc",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"lint": "echo \"No linting configured\"",
|
|
39
|
+
"test": "jest --no-watchman",
|
|
40
|
+
"test:watch": "jest --watch --no-watchman",
|
|
41
|
+
"test:coverage": "jest --coverage --no-watchman",
|
|
42
|
+
"dev": "tsc --watch",
|
|
43
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
44
|
+
"publish:patch": "npm version patch && npm publish",
|
|
45
|
+
"publish:minor": "npm version minor && npm publish",
|
|
46
|
+
"publish:major": "npm version major && npm publish",
|
|
47
|
+
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
48
|
+
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
49
|
+
"version:patch": "npm version patch",
|
|
50
|
+
"version:minor": "npm version minor",
|
|
51
|
+
"version:major": "npm version major",
|
|
52
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
53
|
+
"version:alpha": "npm version prerelease --preid=alpha",
|
|
54
|
+
"version:check": "node version-sync.js check",
|
|
55
|
+
"version:sync": "node version-sync.js sync",
|
|
56
|
+
"version:list": "node version-sync.js list",
|
|
57
|
+
"version:next": "node version-sync.js next",
|
|
58
|
+
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"tagadapay",
|
|
62
|
+
"cms",
|
|
63
|
+
"plugin",
|
|
64
|
+
"sdk",
|
|
65
|
+
"react",
|
|
66
|
+
"typescript"
|
|
67
|
+
],
|
|
68
|
+
"author": "Tagada Pay",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
72
|
+
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
73
|
+
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
74
|
+
"@basis-theory/web-threeds": "^1.0.1",
|
|
75
|
+
"@google-pay/button-react": "^3.0.10",
|
|
76
|
+
"@tagadapay/plugin-sdk": "link:",
|
|
77
|
+
"@tanstack/react-query": "^5.90.2",
|
|
78
|
+
"@ua-parser-js/pro-enterprise": "^2.0.6",
|
|
79
|
+
"axios": "^1.10.0",
|
|
80
|
+
"iso3166-2-db": "^2.3.11",
|
|
81
|
+
"path-to-regexp": "^8.2.0",
|
|
82
|
+
"react-intl": "^7.1.11",
|
|
83
|
+
"swr": "^2.3.6"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@types/jest": "^29.5.0",
|
|
87
|
+
"@types/node": "^18.0.0",
|
|
88
|
+
"@types/react": "^19",
|
|
89
|
+
"@types/react-dom": "^19",
|
|
90
|
+
"esbuild": "^0.24.2",
|
|
91
|
+
"jest": "^29.5.0",
|
|
92
|
+
"ts-jest": "^29.1.0",
|
|
93
|
+
"typescript": "^5.0.0"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
97
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
98
|
+
},
|
|
99
|
+
"files": [
|
|
100
|
+
"dist/**/*",
|
|
101
|
+
"README.md",
|
|
102
|
+
"build-cdn.js"
|
|
103
|
+
],
|
|
104
|
+
"repository": {
|
|
105
|
+
"type": "git",
|
|
106
|
+
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
107
|
+
},
|
|
108
|
+
"bugs": {
|
|
109
|
+
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
110
|
+
},
|
|
111
|
+
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
112
|
+
}
|