@tagadapay/plugin-sdk 2.3.9 → 2.3.10
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 +623 -623
- package/dist/react/hooks/useApplePay.js +172 -84
- package/dist/react/hooks/usePluginConfig.js +2 -0
- package/dist/react/index.d.ts +1 -2
- package/dist/react/index.js +1 -1
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/types/apple-pay.d.ts +9 -11
- package/package.json +83 -83
- package/dist/react/components/ApplePayUniversalButton.d.ts +0 -16
- package/dist/react/components/ApplePayUniversalButton.example.d.ts +0 -3
- package/dist/react/components/ApplePayUniversalButton.example.js +0 -39
- package/dist/react/components/ApplePayUniversalButton.js +0 -62
|
@@ -1,15 +1,49 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { getBasisTheoryApiKey } from '../config/payment';
|
|
3
3
|
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
4
4
|
import { usePayment } from './usePayment';
|
|
5
5
|
export function useApplePay(options = {}) {
|
|
6
6
|
const [processingPayment, setProcessingPayment] = useState(false);
|
|
7
7
|
const [error, setError] = useState(null);
|
|
8
|
-
const [
|
|
8
|
+
const [isApplePayAvailable, setIsApplePayAvailable] = useState(false);
|
|
9
9
|
const { createApplePayPaymentInstrument, processApplePayPayment } = usePayment();
|
|
10
10
|
const { environment, apiService } = useTagadaContext();
|
|
11
11
|
// Get API key from environment
|
|
12
12
|
const apiKey = getBasisTheoryApiKey(environment?.environment || 'local');
|
|
13
|
+
// Check Apple Pay availability on mount
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const checkApplePayAvailability = () => {
|
|
16
|
+
if (typeof window === 'undefined') {
|
|
17
|
+
setIsApplePayAvailable(false);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Check if ApplePaySession is available
|
|
21
|
+
const hasApplePaySession = !!window.ApplePaySession;
|
|
22
|
+
if (!hasApplePaySession) {
|
|
23
|
+
// In development, simulate Apple Pay availability for UI testing
|
|
24
|
+
const isDevelopment = process.env.NODE_ENV === 'development' ||
|
|
25
|
+
window.location.hostname === 'localhost' ||
|
|
26
|
+
window.location.hostname.includes('127.0.0.1');
|
|
27
|
+
if (isDevelopment) {
|
|
28
|
+
setIsApplePayAvailable(true);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setIsApplePayAvailable(false);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
// Check basic Apple Pay support
|
|
36
|
+
const canMakePayments = window.ApplePaySession.canMakePayments();
|
|
37
|
+
setIsApplePayAvailable(canMakePayments);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.warn('Apple Pay availability check failed:', error);
|
|
41
|
+
setIsApplePayAvailable(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
checkApplePayAvailability();
|
|
45
|
+
// Debug logging
|
|
46
|
+
}, []);
|
|
13
47
|
// Utility function to convert Apple Pay contact to address
|
|
14
48
|
const appleContactToAddress = useCallback((contact) => {
|
|
15
49
|
return {
|
|
@@ -25,68 +59,81 @@ export function useApplePay(options = {}) {
|
|
|
25
59
|
email: contact?.emailAddress || '',
|
|
26
60
|
};
|
|
27
61
|
}, []);
|
|
28
|
-
//
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
62
|
+
// Update checkout session with addresses and customer info
|
|
63
|
+
const updateCheckoutSessionValues = useCallback(async (data) => {
|
|
64
|
+
try {
|
|
65
|
+
await apiService.fetch(`/api/v1/checkout-sessions/${options.checkoutSessionId}/address`, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: {
|
|
68
|
+
data: {
|
|
69
|
+
shippingAddress: data.shippingAddress,
|
|
70
|
+
billingAddress: data.billingAddress,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Failed to update checkout session addresses:', error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}, [apiService, options.checkoutSessionId]);
|
|
80
|
+
// Update customer email
|
|
81
|
+
const updateCustomerEmail = useCallback(async (email) => {
|
|
82
|
+
try {
|
|
83
|
+
await apiService.fetch(`/api/v1/customers/${options.customerId}`, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
body: {
|
|
86
|
+
data: {
|
|
87
|
+
email,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error('Failed to update customer email:', error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}, [apiService, options.customerId]);
|
|
97
|
+
// Recompute order summary after address/shipping changes
|
|
98
|
+
const reComputeOrderSummary = useCallback(async () => {
|
|
99
|
+
try {
|
|
100
|
+
const response = await apiService.fetch(`/api/v1/checkout-sessions/${options.checkoutSessionId}/order-summary`, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
});
|
|
103
|
+
return response;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error('Failed to recompute order summary:', error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}, [apiService, options.checkoutSessionId]);
|
|
110
|
+
// Get shipping rates for the checkout session
|
|
111
|
+
const getShippingRates = useCallback(async () => {
|
|
112
|
+
try {
|
|
113
|
+
const response = await apiService.fetch(`/api/v1/checkout-sessions/${options.checkoutSessionId}/shipping-rates`);
|
|
114
|
+
return response;
|
|
58
115
|
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.error('Failed to get shipping rates:', error);
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}, [apiService, options.checkoutSessionId]);
|
|
121
|
+
// Set shipping rate
|
|
122
|
+
const setShippingRate = useCallback(async (shippingRateId) => {
|
|
59
123
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
124
|
+
await apiService.fetch(`/api/v1/checkout-sessions/${options.checkoutSessionId}/shipping-rate`, {
|
|
125
|
+
method: 'POST',
|
|
126
|
+
body: {
|
|
127
|
+
shippingRateId,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
62
130
|
}
|
|
63
131
|
catch (error) {
|
|
64
|
-
console.
|
|
65
|
-
|
|
132
|
+
console.error('Failed to set shipping rate:', error);
|
|
133
|
+
throw error;
|
|
66
134
|
}
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
const shouldShowQRCode = (() => {
|
|
70
|
-
if (typeof window === 'undefined')
|
|
71
|
-
return false;
|
|
72
|
-
// Show QR code if Apple Pay is not available but we're in a supported environment
|
|
73
|
-
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
74
|
-
const isSafari = /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent);
|
|
75
|
-
const isChrome = /Chrome/.test(navigator.userAgent);
|
|
76
|
-
// Show QR code for mobile devices or when Apple Pay is not natively supported
|
|
77
|
-
return !isApplePayAvailable && (isMobile || isSafari || isChrome);
|
|
78
|
-
})();
|
|
79
|
-
// Debug logging
|
|
80
|
-
console.log('Apple Pay availability check:', {
|
|
81
|
-
hasWindow: typeof window !== 'undefined',
|
|
82
|
-
hasApplePaySession: typeof window !== 'undefined' && !!window.ApplePaySession,
|
|
83
|
-
canMakePayments: typeof window !== 'undefined' && window.ApplePaySession && window.ApplePaySession.canMakePayments(),
|
|
84
|
-
isDevelopment: process.env.NODE_ENV === 'development' ||
|
|
85
|
-
(typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname.includes('127.0.0.1'))),
|
|
86
|
-
isAvailable: isApplePayAvailable,
|
|
87
|
-
note: !window.ApplePaySession ? 'Apple Pay not available in this browser. Use Safari on iOS/macOS for real Apple Pay support.' : 'Apple Pay API detected'
|
|
88
|
-
});
|
|
89
|
-
const validateMerchant = useCallback(async () => {
|
|
135
|
+
}, [apiService, options.checkoutSessionId]);
|
|
136
|
+
const validateMerchant = useCallback(async (storeName) => {
|
|
90
137
|
try {
|
|
91
138
|
const response = await fetch('https://api.basistheory.com/apple-pay/session', {
|
|
92
139
|
method: 'POST',
|
|
@@ -95,7 +142,7 @@ export function useApplePay(options = {}) {
|
|
|
95
142
|
'BT-API-KEY': apiKey,
|
|
96
143
|
},
|
|
97
144
|
body: JSON.stringify({
|
|
98
|
-
display_name: 'Tagada Pay Store',
|
|
145
|
+
display_name: storeName || 'Tagada Pay Store',
|
|
99
146
|
domain: typeof window !== 'undefined' ? window.location.host : 'localhost',
|
|
100
147
|
}),
|
|
101
148
|
});
|
|
@@ -133,21 +180,8 @@ export function useApplePay(options = {}) {
|
|
|
133
180
|
throw error;
|
|
134
181
|
}
|
|
135
182
|
}, [apiKey]);
|
|
136
|
-
const handleApplePayClick = useCallback((checkoutSessionId, lineItems, total, config = {}) => {
|
|
183
|
+
const handleApplePayClick = useCallback((checkoutSessionId, lineItems, total, config = {}, storeName, currencyCode, shippingMethods) => {
|
|
137
184
|
if (!isApplePayAvailable) {
|
|
138
|
-
if (shouldShowQRCode) {
|
|
139
|
-
// Generate QR code data for fallback
|
|
140
|
-
const qrData = {
|
|
141
|
-
checkoutSessionId,
|
|
142
|
-
lineItems,
|
|
143
|
-
total,
|
|
144
|
-
config,
|
|
145
|
-
qrCodeUrl: generateQRCode({ checkoutSessionId, lineItems, total, config }),
|
|
146
|
-
};
|
|
147
|
-
setQrCodeData(qrData);
|
|
148
|
-
options.onError?.('Apple Pay not available - QR code generated');
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
185
|
const errorMsg = 'Apple Pay is not available on this device';
|
|
152
186
|
setError(errorMsg);
|
|
153
187
|
options.onError?.(errorMsg);
|
|
@@ -155,11 +189,12 @@ export function useApplePay(options = {}) {
|
|
|
155
189
|
}
|
|
156
190
|
const request = {
|
|
157
191
|
countryCode: config.countryCode || 'US',
|
|
158
|
-
currencyCode: 'USD',
|
|
192
|
+
currencyCode: currencyCode || 'USD',
|
|
159
193
|
supportedNetworks: config.supportedNetworks || ['visa', 'masterCard', 'amex', 'discover'],
|
|
160
194
|
merchantCapabilities: config.merchantCapabilities || ['supports3DS'],
|
|
161
195
|
total,
|
|
162
196
|
lineItems,
|
|
197
|
+
shippingMethods: shippingMethods || [],
|
|
163
198
|
requiredShippingContactFields: ['name', 'phone', 'email', 'postalAddress'],
|
|
164
199
|
requiredBillingContactFields: ['postalAddress'],
|
|
165
200
|
};
|
|
@@ -168,8 +203,7 @@ export function useApplePay(options = {}) {
|
|
|
168
203
|
session.onvalidatemerchant = (event) => {
|
|
169
204
|
void (async () => {
|
|
170
205
|
try {
|
|
171
|
-
|
|
172
|
-
const merchantSession = await validateMerchant();
|
|
206
|
+
const merchantSession = await validateMerchant(storeName);
|
|
173
207
|
session.completeMerchantValidation(merchantSession);
|
|
174
208
|
}
|
|
175
209
|
catch (error) {
|
|
@@ -191,10 +225,17 @@ export function useApplePay(options = {}) {
|
|
|
191
225
|
const billingContact = event.payment.billingContact;
|
|
192
226
|
const shippingAddress = shippingContact ? appleContactToAddress(shippingContact) : null;
|
|
193
227
|
const billingAddress = billingContact ? appleContactToAddress(billingContact) : null;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
228
|
+
// Update checkout session with addresses
|
|
229
|
+
if (shippingAddress || billingAddress) {
|
|
230
|
+
await updateCheckoutSessionValues({
|
|
231
|
+
shippingAddress: shippingAddress || undefined,
|
|
232
|
+
billingAddress: billingAddress || undefined,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// Update customer email if available
|
|
236
|
+
if (shippingContact?.emailAddress) {
|
|
237
|
+
await updateCustomerEmail(shippingContact.emailAddress);
|
|
238
|
+
}
|
|
198
239
|
// Tokenize the Apple Pay payment
|
|
199
240
|
const applePayToken = await tokenizeApplePay(event);
|
|
200
241
|
// Complete the Apple Pay session
|
|
@@ -222,6 +263,48 @@ export function useApplePay(options = {}) {
|
|
|
222
263
|
}
|
|
223
264
|
})();
|
|
224
265
|
};
|
|
266
|
+
// Handle shipping method selection
|
|
267
|
+
session.onshippingmethodselected = (event) => {
|
|
268
|
+
void (async () => {
|
|
269
|
+
try {
|
|
270
|
+
await setShippingRate(event.shippingMethod.identifier);
|
|
271
|
+
const newOrderSummary = await reComputeOrderSummary();
|
|
272
|
+
if (!newOrderSummary) {
|
|
273
|
+
session.abort();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const { lineItems: newLineItems, total: newTotal } = newOrderSummary;
|
|
277
|
+
session.completeShippingMethodSelection(window.ApplePaySession.STATUS_SUCCESS, newTotal, newLineItems);
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.error('Shipping method selection failed:', error);
|
|
281
|
+
session.abort();
|
|
282
|
+
}
|
|
283
|
+
})();
|
|
284
|
+
};
|
|
285
|
+
// Handle shipping contact selection
|
|
286
|
+
session.onshippingcontactselected = (event) => {
|
|
287
|
+
void (async () => {
|
|
288
|
+
try {
|
|
289
|
+
const shippingContact = event.shippingContact;
|
|
290
|
+
await updateCheckoutSessionValues({
|
|
291
|
+
shippingAddress: appleContactToAddress(shippingContact),
|
|
292
|
+
});
|
|
293
|
+
const newOrderSummary = await reComputeOrderSummary();
|
|
294
|
+
if (!newOrderSummary) {
|
|
295
|
+
session.abort();
|
|
296
|
+
setError('Payment Failed');
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const { lineItems: newLineItems, total: newTotal, shippingMethods: newShippingMethods, } = newOrderSummary;
|
|
300
|
+
session.completeShippingContactSelection(window.ApplePaySession.STATUS_SUCCESS, newShippingMethods, newTotal, newLineItems);
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.error('Shipping contact selection failed:', error);
|
|
304
|
+
session.abort();
|
|
305
|
+
}
|
|
306
|
+
})();
|
|
307
|
+
};
|
|
225
308
|
session.onerror = (event) => {
|
|
226
309
|
console.error('Apple Pay Session Error:', event);
|
|
227
310
|
const errorMsg = 'Apple Pay session error';
|
|
@@ -233,6 +316,7 @@ export function useApplePay(options = {}) {
|
|
|
233
316
|
setProcessingPayment(false);
|
|
234
317
|
options.onCancel?.();
|
|
235
318
|
};
|
|
319
|
+
// Begin the Apple Pay session - this opens the modal
|
|
236
320
|
session.begin();
|
|
237
321
|
}
|
|
238
322
|
catch (error) {
|
|
@@ -246,6 +330,10 @@ export function useApplePay(options = {}) {
|
|
|
246
330
|
validateMerchant,
|
|
247
331
|
tokenizeApplePay,
|
|
248
332
|
processApplePayPayment,
|
|
333
|
+
updateCheckoutSessionValues,
|
|
334
|
+
updateCustomerEmail,
|
|
335
|
+
setShippingRate,
|
|
336
|
+
reComputeOrderSummary,
|
|
249
337
|
options,
|
|
250
338
|
]);
|
|
251
339
|
return {
|
|
@@ -253,8 +341,8 @@ export function useApplePay(options = {}) {
|
|
|
253
341
|
processingPayment,
|
|
254
342
|
applePayError: error,
|
|
255
343
|
isApplePayAvailable,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
344
|
+
updateCheckoutSessionValues,
|
|
345
|
+
updateCustomerEmail,
|
|
346
|
+
setShippingRate,
|
|
259
347
|
};
|
|
260
348
|
}
|
|
@@ -19,6 +19,7 @@ const loadLocalDevConfig = async (configVariant = 'default') => {
|
|
|
19
19
|
// Use hostname-based detection for better Vite compatibility
|
|
20
20
|
const isLocalDev = typeof window !== 'undefined' &&
|
|
21
21
|
(window.location.hostname === 'localhost' ||
|
|
22
|
+
window.location.hostname.includes('ngrok-free.app') ||
|
|
22
23
|
window.location.hostname.includes('.localhost') ||
|
|
23
24
|
window.location.hostname.includes('127.0.0.1'));
|
|
24
25
|
if (!isLocalDev) {
|
|
@@ -184,6 +185,7 @@ export const debugPluginConfig = async (configVariant = 'default') => {
|
|
|
184
185
|
// Use hostname-based detection for better Vite compatibility
|
|
185
186
|
const isLocalDev = typeof window !== 'undefined' &&
|
|
186
187
|
(window.location.hostname === 'localhost' ||
|
|
188
|
+
window.location.hostname.includes('ngrok-free.app') ||
|
|
187
189
|
window.location.hostname.includes('.localhost') ||
|
|
188
190
|
window.location.hostname.includes('127.0.0.1'));
|
|
189
191
|
if (!isLocalDev) {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -40,6 +40,5 @@ export type { PostPurchaseOffer, PostPurchaseOfferItem, PostPurchaseOfferLineIte
|
|
|
40
40
|
export type { Payment, PaymentPollingHook, PollingOptions } from './hooks/usePaymentPolling';
|
|
41
41
|
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
|
|
42
42
|
export type { ApplePayToken, CardPaymentMethod, PaymentHook, PaymentInstrumentResponse, PaymentOptions, PaymentResponse } from './hooks/usePayment';
|
|
43
|
-
export type { ApplePayConfig, ApplePayLineItem, ApplePayPaymentAuthorizedEvent, ApplePayPaymentRequest, ApplePayPaymentToken, ApplePayValidateMerchantEvent, BasisTheorySessionRequest, BasisTheoryTokenizeRequest, PayToken, UseApplePayOptions, UseApplePayResult
|
|
44
|
-
export { ApplePayUniversalButton } from './components/ApplePayUniversalButton';
|
|
43
|
+
export type { ApplePayAddress, ApplePayConfig, ApplePayLineItem, ApplePayPaymentAuthorizedEvent, ApplePayPaymentRequest, ApplePayPaymentToken, ApplePayValidateMerchantEvent, BasisTheorySessionRequest, BasisTheoryTokenizeRequest, PayToken, UseApplePayOptions, UseApplePayResult } from './types/apple-pay';
|
|
45
44
|
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './utils/money';
|
package/dist/react/index.js
CHANGED
|
@@ -36,6 +36,6 @@ export { useThreedsModal } from './hooks/useThreedsModal';
|
|
|
36
36
|
// Apple Pay hooks exports
|
|
37
37
|
export { useApplePay } from './hooks/useApplePay';
|
|
38
38
|
// Component exports
|
|
39
|
-
|
|
39
|
+
// Apple Pay components removed - use useApplePay hook directly
|
|
40
40
|
// Utility exports
|
|
41
41
|
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './utils/money';
|
|
@@ -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
|
|
@@ -64,6 +64,8 @@ export interface UseApplePayOptions {
|
|
|
64
64
|
onError?: (error: string) => void;
|
|
65
65
|
onCancel?: () => void;
|
|
66
66
|
config?: ApplePayConfig;
|
|
67
|
+
checkoutSessionId?: string;
|
|
68
|
+
customerId?: string;
|
|
67
69
|
}
|
|
68
70
|
export interface ApplePayAddress {
|
|
69
71
|
address1: string;
|
|
@@ -77,21 +79,17 @@ export interface ApplePayAddress {
|
|
|
77
79
|
phone?: string;
|
|
78
80
|
email?: string;
|
|
79
81
|
}
|
|
80
|
-
export interface ApplePayQRCodeData {
|
|
81
|
-
checkoutSessionId: string;
|
|
82
|
-
lineItems: ApplePayLineItem[];
|
|
83
|
-
total: ApplePayLineItem;
|
|
84
|
-
config?: ApplePayConfig;
|
|
85
|
-
qrCodeUrl?: string;
|
|
86
|
-
}
|
|
87
82
|
export interface UseApplePayResult {
|
|
88
|
-
handleApplePayClick: (checkoutSessionId: string, lineItems: ApplePayLineItem[], total: ApplePayLineItem, config?: ApplePayConfig) => void;
|
|
83
|
+
handleApplePayClick: (checkoutSessionId: string, lineItems: ApplePayLineItem[], total: ApplePayLineItem, config?: ApplePayConfig, storeName?: string, currencyCode?: string, shippingMethods?: any[]) => void;
|
|
89
84
|
processingPayment: boolean;
|
|
90
85
|
applePayError: string | null;
|
|
91
86
|
isApplePayAvailable: boolean;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
updateCheckoutSessionValues: (data: {
|
|
88
|
+
shippingAddress?: ApplePayAddress;
|
|
89
|
+
billingAddress?: ApplePayAddress;
|
|
90
|
+
}) => Promise<void>;
|
|
91
|
+
updateCustomerEmail: (email: string) => Promise<void>;
|
|
92
|
+
setShippingRate: (shippingRateId: string) => Promise<void>;
|
|
95
93
|
}
|
|
96
94
|
declare global {
|
|
97
95
|
interface Window {
|
package/package.json
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "2.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
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc",
|
|
21
|
-
"clean": "rm -rf dist",
|
|
22
|
-
"lint": "echo \"No linting configured\"",
|
|
23
|
-
"test": "echo \"No tests yet\" && exit 0",
|
|
24
|
-
"dev": "tsc --watch",
|
|
25
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
26
|
-
"publish:patch": "npm version patch && npm publish",
|
|
27
|
-
"publish:minor": "npm version minor && npm publish",
|
|
28
|
-
"publish:major": "npm version major && npm publish",
|
|
29
|
-
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
30
|
-
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
31
|
-
"version:patch": "npm version patch",
|
|
32
|
-
"version:minor": "npm version minor",
|
|
33
|
-
"version:major": "npm version major",
|
|
34
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
35
|
-
"version:alpha": "npm version prerelease --preid=alpha",
|
|
36
|
-
"version:check": "node version-sync.js check",
|
|
37
|
-
"version:sync": "node version-sync.js sync",
|
|
38
|
-
"version:list": "node version-sync.js list",
|
|
39
|
-
"version:next": "node version-sync.js next",
|
|
40
|
-
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && git push && git push --tags"
|
|
41
|
-
},
|
|
42
|
-
"keywords": [
|
|
43
|
-
"tagadapay",
|
|
44
|
-
"cms",
|
|
45
|
-
"plugin",
|
|
46
|
-
"sdk",
|
|
47
|
-
"react",
|
|
48
|
-
"typescript"
|
|
49
|
-
],
|
|
50
|
-
"author": "Tagada Pay",
|
|
51
|
-
"license": "MIT",
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
54
|
-
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
55
|
-
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
56
|
-
"@basis-theory/web-threeds": "^1.0.1",
|
|
57
|
-
"axios": "^1.6.0",
|
|
58
|
-
"iso3166-2-db": "^2.3.11",
|
|
59
|
-
"react-intl": "^7.1.11"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/node": "^18.0.0",
|
|
63
|
-
"@types/react": "^19",
|
|
64
|
-
"@types/react-dom": "^19",
|
|
65
|
-
"typescript": "^5.0.0"
|
|
66
|
-
},
|
|
67
|
-
"peerDependencies": {
|
|
68
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
69
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
70
|
-
},
|
|
71
|
-
"files": [
|
|
72
|
-
"dist/**/*",
|
|
73
|
-
"README.md"
|
|
74
|
-
],
|
|
75
|
-
"repository": {
|
|
76
|
-
"type": "git",
|
|
77
|
-
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
78
|
-
},
|
|
79
|
-
"bugs": {
|
|
80
|
-
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
81
|
-
},
|
|
82
|
-
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
83
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "2.3.10",
|
|
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
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"lint": "echo \"No linting configured\"",
|
|
23
|
+
"test": "echo \"No tests yet\" && exit 0",
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
26
|
+
"publish:patch": "npm version patch && npm publish",
|
|
27
|
+
"publish:minor": "npm version minor && npm publish",
|
|
28
|
+
"publish:major": "npm version major && npm publish",
|
|
29
|
+
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
30
|
+
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
31
|
+
"version:patch": "npm version patch",
|
|
32
|
+
"version:minor": "npm version minor",
|
|
33
|
+
"version:major": "npm version major",
|
|
34
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
35
|
+
"version:alpha": "npm version prerelease --preid=alpha",
|
|
36
|
+
"version:check": "node version-sync.js check",
|
|
37
|
+
"version:sync": "node version-sync.js sync",
|
|
38
|
+
"version:list": "node version-sync.js list",
|
|
39
|
+
"version:next": "node version-sync.js next",
|
|
40
|
+
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && git push && git push --tags"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"tagadapay",
|
|
44
|
+
"cms",
|
|
45
|
+
"plugin",
|
|
46
|
+
"sdk",
|
|
47
|
+
"react",
|
|
48
|
+
"typescript"
|
|
49
|
+
],
|
|
50
|
+
"author": "Tagada Pay",
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
54
|
+
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
55
|
+
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
56
|
+
"@basis-theory/web-threeds": "^1.0.1",
|
|
57
|
+
"axios": "^1.6.0",
|
|
58
|
+
"iso3166-2-db": "^2.3.11",
|
|
59
|
+
"react-intl": "^7.1.11"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^18.0.0",
|
|
63
|
+
"@types/react": "^19",
|
|
64
|
+
"@types/react-dom": "^19",
|
|
65
|
+
"typescript": "^5.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
69
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist/**/*",
|
|
73
|
+
"README.md"
|
|
74
|
+
],
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
78
|
+
},
|
|
79
|
+
"bugs": {
|
|
80
|
+
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
83
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ApplePayLineItem, ApplePayConfig } from '../types/apple-pay';
|
|
3
|
-
interface ApplePayUniversalButtonProps {
|
|
4
|
-
checkoutSessionId: string;
|
|
5
|
-
lineItems: ApplePayLineItem[];
|
|
6
|
-
total: ApplePayLineItem;
|
|
7
|
-
config?: ApplePayConfig;
|
|
8
|
-
onSuccess?: (payment: any) => void;
|
|
9
|
-
onError?: (error: string) => void;
|
|
10
|
-
onCancel?: () => void;
|
|
11
|
-
className?: string;
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare const ApplePayUniversalButton: React.FC<ApplePayUniversalButtonProps>;
|
|
16
|
-
export default ApplePayUniversalButton;
|