@tagadapay/plugin-sdk 2.6.17 → 2.6.18
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/dist/v2/index.d.ts
CHANGED
|
@@ -20,6 +20,5 @@ export type { ShippingRate, ShippingRatesResponse } from './core/resources/shipp
|
|
|
20
20
|
export type { ApplyDiscountResponse, Discount, DiscountCodeValidation, RemoveDiscountResponse } from './core/resources/discounts';
|
|
21
21
|
export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './core/resources/vipOffers';
|
|
22
22
|
export type { StoreConfig } from './core/resources/storeConfig';
|
|
23
|
-
export type {
|
|
24
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency,
|
|
25
|
-
export type { StoreDiscount, TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react';
|
|
23
|
+
export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelContextUpdateRequest, FunnelContextUpdateResponse } from './core/resources/funnel';
|
|
24
|
+
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency, useDiscounts, useExpressPaymentMethods, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useShippingRates, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useVipOffers, useFunnel, useSimpleFunnel } from './react';
|
package/dist/v2/index.js
CHANGED
|
@@ -12,4 +12,4 @@ export * from './core/utils/currency';
|
|
|
12
12
|
export * from './core/utils/pluginConfig';
|
|
13
13
|
export * from './core/utils/products';
|
|
14
14
|
// React exports (hooks and components only, types are exported above)
|
|
15
|
-
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency,
|
|
15
|
+
export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useCheckout, useCheckoutToken, useCountryOptions, useCurrency, useDiscounts, useExpressPaymentMethods, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useShippingRates, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useVipOffers, useFunnel, useSimpleFunnel } from './react';
|
package/dist/v2/react/index.d.ts
CHANGED
|
@@ -12,11 +12,9 @@ export { useGeoLocation } from './hooks/useGeoLocation';
|
|
|
12
12
|
export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete';
|
|
13
13
|
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
14
14
|
export { usePluginConfig } from './hooks/usePluginConfig';
|
|
15
|
-
export { useTranslation } from './hooks/useTranslation';
|
|
16
15
|
export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQuery } from './hooks/useApiQuery';
|
|
17
16
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
18
17
|
export { useCurrency } from './hooks/useCurrency';
|
|
19
|
-
export { useDiscountQuery as useDiscount } from './hooks/useDiscountQuery';
|
|
20
18
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
21
19
|
export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
|
|
22
20
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
@@ -39,11 +37,8 @@ export type { GeoLocationData, UseGeoLocationOptions, UseGeoLocationReturn } fro
|
|
|
39
37
|
export type { ExtractedAddress, GooglePlaceDetails, GooglePrediction, UseGoogleAutocompleteOptions, UseGoogleAutocompleteResult } from './hooks/useGoogleAutocomplete';
|
|
40
38
|
export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
|
|
41
39
|
export type { UsePluginConfigOptions, UsePluginConfigResult } from './hooks/usePluginConfig';
|
|
42
|
-
export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './hooks/useTranslation';
|
|
43
40
|
export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
|
|
44
|
-
export type { StoreDiscount, UseDiscountQueryOptions as UseDiscountOptions, UseDiscountQueryResult as UseDiscountResult } from './hooks/useDiscountQuery';
|
|
45
41
|
export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
|
|
46
|
-
export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, UseFunnelOptions, UseFunnelResult } from './hooks/useFunnel';
|
|
47
42
|
export type { UseOffersQueryOptions as UseOffersOptions, UseOffersQueryResult as UseOffersResult } from './hooks/useOffersQuery';
|
|
48
43
|
export type { UseOrderBumpQueryOptions as UseOrderBumpOptions, UseOrderBumpQueryResult as UseOrderBumpResult } from './hooks/useOrderBumpQuery';
|
|
49
44
|
export type { UseOrderQueryOptions as UseOrderOptions, UseOrderQueryResult as UseOrderResult } from './hooks/useOrderQuery';
|
|
@@ -55,5 +50,6 @@ export type { UseShippingRatesQueryOptions as UseShippingRatesOptions, UseShippi
|
|
|
55
50
|
export type { UseStoreConfigQueryOptions as UseStoreConfigOptions, UseStoreConfigQueryResult as UseStoreConfigResult } from './hooks/useStoreConfigQuery';
|
|
56
51
|
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
|
|
57
52
|
export type { UseVipOffersQueryOptions as UseVipOffersOptions, UseVipOffersQueryResult as UseVipOffersResult } from './hooks/useVipOffersQuery';
|
|
53
|
+
export type { UseFunnelOptions, UseFunnelResult, FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext } from './hooks/useFunnel';
|
|
58
54
|
export { formatMoney } from '../../react/utils/money';
|
|
59
55
|
export type OrderItem = import('../core/utils/order').OrderLineItem;
|
package/dist/v2/react/index.js
CHANGED
|
@@ -15,12 +15,10 @@ export { useGeoLocation } from './hooks/useGeoLocation';
|
|
|
15
15
|
export { useGoogleAutocomplete } from './hooks/useGoogleAutocomplete';
|
|
16
16
|
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
17
17
|
export { usePluginConfig } from './hooks/usePluginConfig';
|
|
18
|
-
export { useTranslation } from './hooks/useTranslation';
|
|
19
18
|
// TanStack Query hooks (recommended)
|
|
20
19
|
export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQuery } from './hooks/useApiQuery';
|
|
21
20
|
export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
|
|
22
21
|
export { useCurrency } from './hooks/useCurrency';
|
|
23
|
-
export { useDiscountQuery as useDiscount } from './hooks/useDiscountQuery';
|
|
24
22
|
export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
|
|
25
23
|
export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
|
|
26
24
|
export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TagadaProvider - Main provider component for the Tagada Pay React SDK
|
|
3
|
-
*/
|
|
4
1
|
import { ReactNode } from 'react';
|
|
5
2
|
import { PluginConfig, RawPluginConfig } from '../../../react/hooks/usePluginConfig';
|
|
6
3
|
import { ApiService } from '../../../react/services/apiService';
|
|
@@ -3,9 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
/**
|
|
4
4
|
* TagadaProvider - Main provider component for the Tagada Pay React SDK
|
|
5
5
|
*/
|
|
6
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
7
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
8
|
-
import {
|
|
7
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
9
8
|
import { detectEnvironment, getEnvironmentConfig } from '../../../react/config/environment';
|
|
10
9
|
import { ApiService } from '../../../react/services/apiService';
|
|
11
10
|
import { collectDeviceInfo, getBrowserLocale, getUrlParams } from '../../../react/utils/deviceInfo';
|
|
@@ -13,8 +12,9 @@ import { decodeJWTClient, isTokenExpired } from '../../../react/utils/jwtDecoder
|
|
|
13
12
|
import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from '../../../react/utils/money';
|
|
14
13
|
import { clearClientToken, getClientToken, setClientToken } from '../../../react/utils/tokenStorage';
|
|
15
14
|
import { ApiClient } from '../../core/resources/apiClient';
|
|
16
|
-
import { setGlobalApiClient, getGlobalApiClientOrNull } from '../hooks/useApiQuery';
|
|
17
15
|
import { loadPluginConfig } from '../../core/utils/pluginConfig';
|
|
16
|
+
import { default as DebugDrawer } from '../components/DebugDrawer';
|
|
17
|
+
import { setGlobalApiClient } from '../hooks/useApiQuery';
|
|
18
18
|
// Professional, subtle loading component for initialization
|
|
19
19
|
const InitializationLoader = () => (_jsxs("div", { style: {
|
|
20
20
|
position: 'fixed',
|
|
@@ -207,8 +207,9 @@ rawPluginConfig, }) {
|
|
|
207
207
|
}
|
|
208
208
|
return service;
|
|
209
209
|
});
|
|
210
|
-
// Initialize TanStack Query API client
|
|
211
|
-
|
|
210
|
+
// Initialize TanStack Query API client synchronously during provider initialization
|
|
211
|
+
// This ensures the global client is available immediately for hooks that use it in useMemo
|
|
212
|
+
const [apiClient] = useState(() => {
|
|
212
213
|
const client = new ApiClient({
|
|
213
214
|
baseURL: environmentConfig.apiConfig.baseUrl,
|
|
214
215
|
headers: {
|
|
@@ -217,24 +218,40 @@ rawPluginConfig, }) {
|
|
|
217
218
|
});
|
|
218
219
|
// Set the global client for TanStack Query hooks
|
|
219
220
|
setGlobalApiClient(client);
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
// Check for existing token and set it immediately
|
|
222
|
+
const existingToken = getClientToken();
|
|
223
|
+
if (existingToken && !isTokenExpired(existingToken)) {
|
|
224
|
+
client.updateToken(existingToken);
|
|
225
|
+
console.log('[SDK] ApiClient initialized with existing token:', existingToken.substring(0, 8) + '...');
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
console.log('[SDK] ApiClient initialized with baseURL:', environmentConfig.apiConfig.baseUrl);
|
|
229
|
+
}
|
|
230
|
+
return client;
|
|
231
|
+
});
|
|
232
|
+
// Update API client when environment config changes
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
apiClient.updateConfig({
|
|
235
|
+
baseURL: environmentConfig.apiConfig.baseUrl,
|
|
236
|
+
headers: {
|
|
237
|
+
'Content-Type': 'application/json',
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
console.log('[SDK] ApiClient config updated with baseURL:', environmentConfig.apiConfig.baseUrl);
|
|
241
|
+
}, [environmentConfig, apiClient]);
|
|
222
242
|
// Sync token updates between ApiService and ApiClient
|
|
223
243
|
useEffect(() => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
client.updateToken(null);
|
|
234
|
-
console.log('[SDK] Token cleared from ApiClient');
|
|
235
|
-
}
|
|
244
|
+
// Always use the token from ApiService as the source of truth
|
|
245
|
+
const currentToken = apiService.getCurrentToken();
|
|
246
|
+
if (currentToken && typeof currentToken === 'string') {
|
|
247
|
+
apiClient.updateToken(currentToken);
|
|
248
|
+
console.log('[SDK] Token synced to ApiClient:', currentToken.substring(0, 8) + '...');
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
apiClient.updateToken(null);
|
|
252
|
+
console.log('[SDK] Token cleared from ApiClient');
|
|
236
253
|
}
|
|
237
|
-
}, [token, apiService]);
|
|
254
|
+
}, [token, apiService, apiClient]);
|
|
238
255
|
// Update API service when config or token changes
|
|
239
256
|
useEffect(() => {
|
|
240
257
|
apiService.updateConfig(environmentConfig);
|
|
@@ -378,12 +395,6 @@ rawPluginConfig, }) {
|
|
|
378
395
|
console.debug('[SDK][DEBUG] Auth state:', authState);
|
|
379
396
|
}
|
|
380
397
|
console.debug('[SDK] Session initialized successfully');
|
|
381
|
-
// Update token to ApiClient immediately
|
|
382
|
-
const client = getGlobalApiClientOrNull();
|
|
383
|
-
if (client && token) {
|
|
384
|
-
client.updateToken(token);
|
|
385
|
-
console.log('[SDK] Token updated to ApiClient:', token.substring(0, 8) + '...');
|
|
386
|
-
}
|
|
387
398
|
setIsInitialized(true);
|
|
388
399
|
setIsSessionInitialized(true); // Mark CMS session as ready
|
|
389
400
|
setIsLoading(false);
|
|
@@ -425,6 +436,10 @@ rawPluginConfig, }) {
|
|
|
425
436
|
setClientToken(response.token);
|
|
426
437
|
// Update the API service with the new token
|
|
427
438
|
apiService.updateToken(response.token);
|
|
439
|
+
// IMPORTANT: Immediately sync token to API client before marking session as ready
|
|
440
|
+
// This ensures any queries that become enabled after isSessionInitialized=true have the token
|
|
441
|
+
apiClient.updateToken(response.token);
|
|
442
|
+
console.log('[SDK] Token immediately synced to ApiClient:', response.token.substring(0, 8) + '...');
|
|
428
443
|
// Decode the token to get session data
|
|
429
444
|
const decodedSession = decodeJWTClient(response.token);
|
|
430
445
|
if (decodedSession) {
|
|
@@ -441,12 +456,6 @@ rawPluginConfig, }) {
|
|
|
441
456
|
setIsLoading(false);
|
|
442
457
|
}
|
|
443
458
|
console.log('[SDK] ✅ Phase 3 Complete - Session initialization completed successfully');
|
|
444
|
-
// Update token to ApiClient immediately
|
|
445
|
-
const client = getGlobalApiClientOrNull();
|
|
446
|
-
if (client && token) {
|
|
447
|
-
client.updateToken(token);
|
|
448
|
-
console.log('[SDK] Token updated to ApiClient:', token.substring(0, 8) + '...');
|
|
449
|
-
}
|
|
450
459
|
setIsSessionInitialized(true); // Mark CMS session as ready
|
|
451
460
|
}
|
|
452
461
|
catch (error) {
|
|
@@ -508,6 +517,9 @@ rawPluginConfig, }) {
|
|
|
508
517
|
setToken(tokenToUse);
|
|
509
518
|
// Update the API service with the token
|
|
510
519
|
apiService.updateToken(tokenToUse);
|
|
520
|
+
// IMPORTANT: Immediately sync token to API client
|
|
521
|
+
apiClient.updateToken(tokenToUse);
|
|
522
|
+
console.log('[SDK] Token immediately synced to ApiClient:', tokenToUse.substring(0, 8) + '...');
|
|
511
523
|
// Decode token to get session data
|
|
512
524
|
const decodedSession = decodeJWTClient(tokenToUse);
|
|
513
525
|
if (decodedSession) {
|