@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
package/dist/v2/react/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ 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 {
|
|
10
|
+
export { PreviewModeIndicator } from './components/PreviewModeIndicator';
|
|
11
|
+
export { useApplePayCheckout } from './hooks/useApplePayCheckout';
|
|
11
12
|
export { useAuth } from './hooks/useAuth';
|
|
12
13
|
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
13
14
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
@@ -19,8 +20,11 @@ export { useCustomerSubscriptions } from './hooks/useCustomerSubscriptions';
|
|
|
19
20
|
export { useExpressPaymentMethods } from './hooks/useExpressPaymentMethods';
|
|
20
21
|
export { useGeoLocation } from './hooks/useGeoLocation';
|
|
21
22
|
export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete';
|
|
23
|
+
export { useGooglePayCheckout } from './hooks/useGooglePayCheckout';
|
|
22
24
|
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
23
25
|
export { useLogin } from './hooks/useLogin';
|
|
26
|
+
export { PixelTrackingProvider, usePixelTracking } from './hooks/usePixelTracking';
|
|
27
|
+
export type { PixelTrackingContextValue, StandardPixelEvent } from './hooks/usePixelTracking';
|
|
24
28
|
export { usePluginConfig } from './hooks/usePluginConfig';
|
|
25
29
|
export { useRemappableParams } from './hooks/useRemappableParams';
|
|
26
30
|
export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQuery } from './hooks/useApiQuery';
|
|
@@ -28,11 +32,12 @@ export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
|
28
32
|
export { useCurrency } from './hooks/useCurrency';
|
|
29
33
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
30
34
|
export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
|
|
31
|
-
export { usePreviewOffer } from './hooks/usePreviewOffer';
|
|
32
35
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
33
36
|
export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
|
|
34
37
|
export { usePaymentQuery as usePayment } from './hooks/usePaymentQuery';
|
|
38
|
+
export { usePaymentRetrieve } from './hooks/usePaymentRetrieve';
|
|
35
39
|
export { usePostPurchasesQuery as usePostPurchases } from './hooks/usePostPurchasesQuery';
|
|
40
|
+
export { usePreviewOffer } from './hooks/usePreviewOffer';
|
|
36
41
|
export { useProductsQuery as useProducts } from './hooks/useProductsQuery';
|
|
37
42
|
export { usePromotionsQuery as usePromotions } from './hooks/usePromotionsQuery';
|
|
38
43
|
export { useShippingRatesQuery as useShippingRates } from './hooks/useShippingRatesQuery';
|
|
@@ -42,8 +47,9 @@ export { useThreedsModal } from './hooks/useThreedsModal';
|
|
|
42
47
|
export { useTranslation } from './hooks/useTranslation';
|
|
43
48
|
export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
|
|
44
49
|
export { useFunnel } from './hooks/useFunnel';
|
|
50
|
+
export { useStepConfig } from './hooks/useStepConfig';
|
|
45
51
|
export { useFunnel as useFunnelLegacy, useSimpleFunnel } from './hooks/useFunnelLegacy';
|
|
46
|
-
export type {
|
|
52
|
+
export type { UseApplePayCheckoutOptions } from './hooks/useApplePayCheckout';
|
|
47
53
|
export type { UseCheckoutTokenOptions, UseCheckoutTokenResult } from './hooks/useCheckoutToken';
|
|
48
54
|
export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './hooks/useClubOffers';
|
|
49
55
|
export type { UseCreditsOptions, UseCreditsResult } from './hooks/useCredits';
|
|
@@ -52,9 +58,11 @@ export type { UseCustomerInfosOptions, UseCustomerInfosResult } from './hooks/us
|
|
|
52
58
|
export type { UseCustomerOrdersOptions, UseCustomerOrdersResult } from './hooks/useCustomerOrders';
|
|
53
59
|
export type { UseCustomerSubscriptionsOptions, UseCustomerSubscriptionsResult } from './hooks/useCustomerSubscriptions';
|
|
54
60
|
export type { ExpressPaymentMethodsContextType, ExpressPaymentMethodsProviderProps } from './hooks/useExpressPaymentMethods';
|
|
61
|
+
export type { UseGooglePayCheckoutOptions } from './hooks/useGooglePayCheckout';
|
|
55
62
|
export type { UseLoginOptions, UseLoginResult } from './hooks/useLogin';
|
|
56
63
|
export type { ApplePayButtonProps } from './components/ApplePayButton';
|
|
57
64
|
export type { GooglePayButtonProps } from './components/GooglePayButton';
|
|
65
|
+
export type { PreviewModeIndicatorProps } from './components/PreviewModeIndicator';
|
|
58
66
|
export type { GeoLocationData, UseGeoLocationOptions, UseGeoLocationReturn } from './hooks/useGeoLocation';
|
|
59
67
|
export type { ExtractedAddress, GooglePlaceDetails, GooglePrediction, UseGoogleAutocompleteOptions, UseGoogleAutocompleteResult } from './hooks/useGoogleAutocomplete';
|
|
60
68
|
export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
|
|
@@ -64,14 +72,16 @@ export { FunnelActionType } from '../core/resources/funnel';
|
|
|
64
72
|
export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
|
|
65
73
|
export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
|
|
66
74
|
export type { FunnelAction, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext } from '../core/resources/funnel';
|
|
67
|
-
export type { FunnelContextValue } from './hooks/useFunnel';
|
|
75
|
+
export type { FunnelContextValue, StepConfigValue } from './hooks/useFunnel';
|
|
76
|
+
export type { UseStepConfigResult } from './hooks/useStepConfig';
|
|
68
77
|
export type { UseFunnelOptions as UseFunnelLegacyOptions, UseFunnelResult as UseFunnelLegacyResult } from './hooks/useFunnelLegacy';
|
|
69
78
|
export type { AvailableVariant, LineItemSelection, OfferLineItem, OfferPreviewSummary, UseOfferQueryOptions as UseOfferOptions, UseOfferQueryResult as UseOfferResult } from './hooks/useOfferQuery';
|
|
70
|
-
export type { PreviewOfferSummary, UsePreviewOfferOptions, UsePreviewOfferResult } from './hooks/usePreviewOffer';
|
|
71
79
|
export type { UseOrderBumpQueryOptions as UseOrderBumpOptions, UseOrderBumpQueryResult as UseOrderBumpResult } from './hooks/useOrderBumpQuery';
|
|
72
80
|
export type { UseOrderQueryOptions as UseOrderOptions, UseOrderQueryResult as UseOrderResult } from './hooks/useOrderQuery';
|
|
73
81
|
export type { PaymentHook as UsePaymentResult } from './hooks/usePaymentQuery';
|
|
82
|
+
export type { PaymentRetrieveHook as UsePaymentRetrieveResult } from './hooks/usePaymentRetrieve';
|
|
74
83
|
export type { UsePostPurchasesQueryOptions as UsePostPurchasesOptions, UsePostPurchasesQueryResult as UsePostPurchasesResult } from './hooks/usePostPurchasesQuery';
|
|
84
|
+
export type { PreviewOfferSummary, UsePreviewOfferOptions, UsePreviewOfferResult } from './hooks/usePreviewOffer';
|
|
75
85
|
export type { UseProductsQueryOptions as UseProductsOptions, UseProductsQueryResult as UseProductsResult } from './hooks/useProductsQuery';
|
|
76
86
|
export type { UsePromotionsQueryOptions as UsePromotionsOptions, UsePromotionsQueryResult as UsePromotionsResult } from './hooks/usePromotionsQuery';
|
|
77
87
|
export type { UseShippingRatesQueryOptions as UseShippingRatesOptions, UseShippingRatesQueryResult as UseShippingRatesResult } from './hooks/useShippingRatesQuery';
|
package/dist/v2/react/index.js
CHANGED
|
@@ -8,8 +8,9 @@ export { TagadaProvider, useTagadaContext } from './providers/TagadaProvider';
|
|
|
8
8
|
// Components
|
|
9
9
|
export { ApplePayButton } from './components/ApplePayButton';
|
|
10
10
|
export { GooglePayButton } from './components/GooglePayButton';
|
|
11
|
+
export { PreviewModeIndicator } from './components/PreviewModeIndicator';
|
|
11
12
|
// Hooks
|
|
12
|
-
export {
|
|
13
|
+
export { useApplePayCheckout } from './hooks/useApplePayCheckout';
|
|
13
14
|
export { useAuth } from './hooks/useAuth';
|
|
14
15
|
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
15
16
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
@@ -21,8 +22,10 @@ export { useCustomerSubscriptions } from './hooks/useCustomerSubscriptions';
|
|
|
21
22
|
export { useExpressPaymentMethods } from './hooks/useExpressPaymentMethods';
|
|
22
23
|
export { useGeoLocation } from './hooks/useGeoLocation';
|
|
23
24
|
export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete';
|
|
25
|
+
export { useGooglePayCheckout } from './hooks/useGooglePayCheckout';
|
|
24
26
|
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
25
27
|
export { useLogin } from './hooks/useLogin';
|
|
28
|
+
export { PixelTrackingProvider, usePixelTracking } from './hooks/usePixelTracking';
|
|
26
29
|
export { usePluginConfig } from './hooks/usePluginConfig';
|
|
27
30
|
export { useRemappableParams } from './hooks/useRemappableParams';
|
|
28
31
|
// TanStack Query hooks (recommended)
|
|
@@ -31,11 +34,12 @@ export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
|
31
34
|
export { useCurrency } from './hooks/useCurrency';
|
|
32
35
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
33
36
|
export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
|
|
34
|
-
export { usePreviewOffer } from './hooks/usePreviewOffer';
|
|
35
37
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
36
38
|
export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
|
|
37
39
|
export { usePaymentQuery as usePayment } from './hooks/usePaymentQuery';
|
|
40
|
+
export { usePaymentRetrieve } from './hooks/usePaymentRetrieve';
|
|
38
41
|
export { usePostPurchasesQuery as usePostPurchases } from './hooks/usePostPurchasesQuery';
|
|
42
|
+
export { usePreviewOffer } from './hooks/usePreviewOffer';
|
|
39
43
|
export { useProductsQuery as useProducts } from './hooks/useProductsQuery';
|
|
40
44
|
export { usePromotionsQuery as usePromotions } from './hooks/usePromotionsQuery';
|
|
41
45
|
export { useShippingRatesQuery as useShippingRates } from './hooks/useShippingRatesQuery';
|
|
@@ -46,6 +50,8 @@ export { useTranslation } from './hooks/useTranslation';
|
|
|
46
50
|
export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
|
|
47
51
|
// Funnel hooks
|
|
48
52
|
export { useFunnel } from './hooks/useFunnel';
|
|
53
|
+
// Step config hook (access runtime configuration from HTML injection)
|
|
54
|
+
export { useStepConfig } from './hooks/useStepConfig';
|
|
49
55
|
// Legacy funnel hooks (deprecated - use TagadaProvider + useFunnel instead)
|
|
50
56
|
export { useFunnel as useFunnelLegacy, useSimpleFunnel } from './hooks/useFunnelLegacy';
|
|
51
57
|
// TanStack Query types
|
|
@@ -40,8 +40,11 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
40
40
|
setAvailableExpressPaymentMethodIds((prev) => (prev.includes(id) ? prev : [...prev, id]));
|
|
41
41
|
}, []);
|
|
42
42
|
const minorUnitsToCurrencyString = useCallback((amountMinor, currency) => {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
// Fail safely - don't allow invalid data to become '0.00'
|
|
44
|
+
if (amountMinor === undefined || amountMinor === null || !currency) {
|
|
45
|
+
throw new Error(`Invalid currency data: amountMinor=${amountMinor}, currency=${currency}`);
|
|
46
|
+
}
|
|
47
|
+
// 0 is a valid amount (e.g., free shipping)
|
|
45
48
|
return (amountMinor / 100).toFixed(2);
|
|
46
49
|
}, []);
|
|
47
50
|
// Convert shipping rates to express shipping methods
|
|
@@ -69,9 +72,11 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
69
72
|
// Update checkout session address mutation
|
|
70
73
|
const updateAddressMutation = useMutation({
|
|
71
74
|
mutationFn: (data) => expressPaymentResource.updateCheckoutSessionAddress(checkoutSessionId, { data }),
|
|
72
|
-
onSuccess: () => {
|
|
73
|
-
// Invalidate checkout query to
|
|
74
|
-
|
|
75
|
+
onSuccess: async () => {
|
|
76
|
+
// Invalidate and wait for checkout query to refetch
|
|
77
|
+
await queryClient.invalidateQueries({ queryKey: ['checkout'] });
|
|
78
|
+
// Small delay to ensure parent's query has time to refetch
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
75
80
|
},
|
|
76
81
|
});
|
|
77
82
|
// Update customer email mutation
|
|
@@ -79,18 +84,34 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
79
84
|
mutationFn: (data) => expressPaymentResource.updateCustomerEmail(customerId, { data }),
|
|
80
85
|
});
|
|
81
86
|
// Recompute order summary (refetch after updates)
|
|
87
|
+
// Refetches checkout and shipping rates to get fresh data
|
|
82
88
|
const reComputeOrderSummary = useCallback(async () => {
|
|
83
89
|
try {
|
|
84
|
-
//
|
|
85
|
-
await queryClient.
|
|
90
|
+
// Refetch checkout to get latest data
|
|
91
|
+
await queryClient.refetchQueries({ queryKey: ['checkout'] });
|
|
86
92
|
await refetchRates();
|
|
87
93
|
// Wait a bit for queries to settle
|
|
88
94
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
89
95
|
// Get fresh data from cache
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
const queryCache = queryClient.getQueryCache();
|
|
97
|
+
const checkoutQueries = queryCache.findAll({ queryKey: ['checkout'] });
|
|
98
|
+
// Try to find the checkout that matches our current session ID
|
|
99
|
+
const currentSessionId = checkout?.checkoutSession?.id;
|
|
100
|
+
const matchingCheckout = checkoutQueries.find((query) => query.state.data && query.state.data?.checkoutSession?.id === currentSessionId);
|
|
101
|
+
const freshCheckout = matchingCheckout
|
|
102
|
+
? matchingCheckout.state.data
|
|
103
|
+
: checkoutQueries.length > 0
|
|
104
|
+
? checkoutQueries[0].state.data
|
|
105
|
+
: checkout;
|
|
106
|
+
const freshSummary = freshCheckout?.summary || checkout?.summary;
|
|
107
|
+
if (!freshSummary || !shippingRates) {
|
|
108
|
+
console.error('[ExpressProvider] Missing data:', {
|
|
109
|
+
hasSummary: !!freshSummary,
|
|
110
|
+
hasShippingRates: !!shippingRates,
|
|
111
|
+
checkout: freshCheckout || checkout,
|
|
112
|
+
});
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
94
115
|
const recomputedLineItems = [
|
|
95
116
|
{
|
|
96
117
|
label: 'Subtotal',
|
|
@@ -115,17 +136,20 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
115
136
|
identifier: rate.id,
|
|
116
137
|
detail: rate.description || '',
|
|
117
138
|
}));
|
|
139
|
+
// Get selected shipping rate ID from fresh checkout
|
|
140
|
+
const selectedShippingRateId = freshCheckout?.checkoutSession?.shippingRate?.id;
|
|
118
141
|
return {
|
|
119
142
|
lineItems: recomputedLineItems,
|
|
120
143
|
total,
|
|
121
144
|
shippingMethods: recomputedShippingMethods,
|
|
145
|
+
selectedShippingRateId,
|
|
122
146
|
};
|
|
123
147
|
}
|
|
124
148
|
catch (e) {
|
|
125
149
|
console.error('Error recomputing order summary:', e);
|
|
126
150
|
return undefined;
|
|
127
151
|
}
|
|
128
|
-
}, [
|
|
152
|
+
}, [refetchRates, shippingRates, minorUnitsToCurrencyString, checkout, queryClient]);
|
|
129
153
|
// Update checkout session values
|
|
130
154
|
const updateCheckoutSessionValues = useCallback(async (input) => {
|
|
131
155
|
await updateAddressMutation.mutateAsync(input.data);
|
|
@@ -136,8 +160,12 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
136
160
|
return;
|
|
137
161
|
await updateEmailMutation.mutateAsync(input.data);
|
|
138
162
|
}, [customerId, updateEmailMutation]);
|
|
163
|
+
// Check if Apple Pay is available (window.ApplePaySession only exists on Apple devices)
|
|
164
|
+
const isApplePayAvailable = typeof window !== 'undefined' && typeof window.ApplePaySession !== 'undefined';
|
|
139
165
|
// Identify specific payment method types
|
|
140
|
-
const applePayPaymentMethod = useMemo(() =>
|
|
166
|
+
const applePayPaymentMethod = useMemo(() => {
|
|
167
|
+
return isApplePayAvailable ? paymentMethods?.find((p) => p.type === 'apple_pay') : undefined;
|
|
168
|
+
}, [paymentMethods, isApplePayAvailable]);
|
|
141
169
|
const googlePayPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'google_pay'), [paymentMethods]);
|
|
142
170
|
const paypalPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'paypal'), [paymentMethods]);
|
|
143
171
|
const klarnaPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'klarna'), [paymentMethods]);
|
|
@@ -11,6 +11,7 @@ import { TagadaClient } from '../../core/client';
|
|
|
11
11
|
import { default as DebugDrawer } from '../components/DebugDrawer';
|
|
12
12
|
import { FunnelScriptInjector } from '../components/FunnelScriptInjector';
|
|
13
13
|
import { setGlobalApiClient } from '../hooks/useApiQuery';
|
|
14
|
+
import { PixelTrackingProvider } from '../hooks/usePixelTracking';
|
|
14
15
|
// Professional, subtle loading component for initialization
|
|
15
16
|
const InitializationLoader = () => (_jsxs("div", { style: {
|
|
16
17
|
position: 'fixed',
|
|
@@ -37,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
37
38
|
borderTop: '1.5px solid #9ca3af',
|
|
38
39
|
borderRadius: '50%',
|
|
39
40
|
animation: 'tagada-spin 1s linear infinite',
|
|
40
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
41
|
-
@keyframes tagada-spin {
|
|
42
|
-
0% { transform: rotate(0deg); }
|
|
43
|
-
100% { transform: rotate(360deg); }
|
|
44
|
-
}
|
|
41
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
+
@keyframes tagada-spin {
|
|
43
|
+
0% { transform: rotate(0deg); }
|
|
44
|
+
100% { transform: rotate(360deg); }
|
|
45
|
+
}
|
|
45
46
|
` })] }));
|
|
46
47
|
const TagadaContext = createContext(null);
|
|
47
48
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, features, funnelId, autoInitializeFunnel = true, onNavigate, onFunnelError, debugScripts = [], }) {
|
|
@@ -248,8 +249,8 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
248
249
|
window.location.href = result.url;
|
|
249
250
|
}
|
|
250
251
|
};
|
|
251
|
-
const next = async (event) => {
|
|
252
|
-
const result = await client.funnel.navigate(event);
|
|
252
|
+
const next = async (event, options) => {
|
|
253
|
+
const result = await client.funnel.navigate(event, options);
|
|
253
254
|
handleNavigationResult(result);
|
|
254
255
|
return result;
|
|
255
256
|
};
|
|
@@ -319,22 +320,22 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
319
320
|
// Loading State Logic
|
|
320
321
|
const shouldShowLoading = state.isLoading || state.pluginConfigLoading || (blockUntilSessionReady && !state.isSessionInitialized);
|
|
321
322
|
const canRenderChildren = !state.pluginConfigLoading && (!blockUntilSessionReady || state.isSessionInitialized);
|
|
322
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
323
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(TagadaContext.Provider, { value: contextValue, children: _jsxs(PixelTrackingProvider, { children: [_jsx(FunnelScriptInjector, { ...funnelState }), shouldShowLoading && _jsx(InitializationLoader, {}), state.debugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
324
|
+
position: 'fixed',
|
|
325
|
+
bottom: '16px',
|
|
326
|
+
right: '16px',
|
|
327
|
+
backgroundColor: '#f97316',
|
|
328
|
+
color: 'white',
|
|
329
|
+
border: 'none',
|
|
330
|
+
borderRadius: '50%',
|
|
331
|
+
width: '56px',
|
|
332
|
+
height: '56px',
|
|
333
|
+
fontSize: '20px',
|
|
334
|
+
cursor: 'pointer',
|
|
335
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.3)',
|
|
336
|
+
zIndex: 999997,
|
|
337
|
+
transition: 'all 0.2s ease',
|
|
338
|
+
}, title: "Open TagadaPay SDK Debug Panel", children: "\uD83D\uDC1B" }), _jsx(DebugDrawer, { isOpen: isDebugDrawerOpen, onClose: () => setIsDebugDrawerOpen(false) })] })), canRenderChildren && children] }) }) }));
|
|
338
339
|
}
|
|
339
340
|
export function useTagadaContext() {
|
|
340
341
|
const context = useContext(TagadaContext);
|
|
@@ -71,6 +71,8 @@ export interface NavigateOptions {
|
|
|
71
71
|
eventData?: Record<string, unknown>;
|
|
72
72
|
/** Override return URL */
|
|
73
73
|
returnUrl?: string;
|
|
74
|
+
/** Disable auto-redirect to control navigation manually (default: true) */
|
|
75
|
+
autoRedirect?: boolean;
|
|
74
76
|
}
|
|
75
77
|
declare class TagadaExternalTracker {
|
|
76
78
|
private config;
|
|
@@ -135,15 +135,18 @@ class TagadaExternalTracker {
|
|
|
135
135
|
throw new Error('Tracker not initialized. Call init() first.');
|
|
136
136
|
}
|
|
137
137
|
log(this.config.debug, '🚀 Navigating:', options);
|
|
138
|
+
// Determine if we should auto-redirect (default: true)
|
|
139
|
+
const shouldAutoRedirect = options.autoRedirect !== false;
|
|
138
140
|
try {
|
|
139
141
|
const result = await this.client.funnel.navigate({
|
|
140
142
|
type: options.eventType,
|
|
141
143
|
data: options.eventData || {},
|
|
142
|
-
}
|
|
144
|
+
}, { autoRedirect: false } // Always disable SDK auto-redirect, we handle it here
|
|
145
|
+
);
|
|
143
146
|
if (result?.url) {
|
|
144
147
|
log(this.config.debug, '✅ Navigation result:', result.url);
|
|
145
|
-
//
|
|
146
|
-
if (typeof window !== 'undefined') {
|
|
148
|
+
// Only redirect if autoRedirect is enabled
|
|
149
|
+
if (shouldAutoRedirect && typeof window !== 'undefined') {
|
|
147
150
|
window.location.href = options.returnUrl || result.url;
|
|
148
151
|
}
|
|
149
152
|
return { url: result.url };
|
package/package.json
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "3.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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "3.1.9",
|
|
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,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apple Pay Hook for v2 Architecture
|
|
3
|
-
* Handles Apple Pay payment flow with Basis Theory integration
|
|
4
|
-
*/
|
|
5
|
-
export interface UseApplePayOptions {
|
|
6
|
-
onSuccess?: (result: any) => void;
|
|
7
|
-
onError?: (error: string) => void;
|
|
8
|
-
onCancel?: () => void;
|
|
9
|
-
}
|
|
10
|
-
export interface UseApplePayResult {
|
|
11
|
-
handleApplePayClick: () => void;
|
|
12
|
-
processingPayment: boolean;
|
|
13
|
-
applePayError: string | null;
|
|
14
|
-
isAvailable: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function useApplePay(options?: UseApplePayOptions): UseApplePayResult;
|