@tagadapay/plugin-sdk 2.8.8 → 2.8.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.
Files changed (43) hide show
  1. package/dist/react/config/environment.d.ts +1 -22
  2. package/dist/react/config/environment.js +1 -132
  3. package/dist/react/utils/deviceInfo.d.ts +1 -39
  4. package/dist/react/utils/deviceInfo.js +1 -163
  5. package/dist/react/utils/jwtDecoder.d.ts +1 -14
  6. package/dist/react/utils/jwtDecoder.js +1 -86
  7. package/dist/react/utils/tokenStorage.d.ts +1 -16
  8. package/dist/react/utils/tokenStorage.js +1 -53
  9. package/dist/v2/core/client.d.ts +96 -0
  10. package/dist/v2/core/client.js +430 -0
  11. package/dist/v2/core/config/environment.d.ts +36 -0
  12. package/dist/v2/core/config/environment.js +155 -0
  13. package/dist/v2/core/pathRemapping.js +61 -3
  14. package/dist/v2/core/resources/apiClient.d.ts +13 -0
  15. package/dist/v2/core/resources/apiClient.js +77 -9
  16. package/dist/v2/core/resources/funnel.d.ts +21 -0
  17. package/dist/v2/core/resources/payments.d.ts +23 -0
  18. package/dist/v2/core/types.d.ts +271 -0
  19. package/dist/v2/core/types.js +4 -0
  20. package/dist/v2/core/utils/deviceInfo.d.ts +39 -0
  21. package/dist/v2/core/utils/deviceInfo.js +162 -0
  22. package/dist/v2/core/utils/eventDispatcher.d.ts +10 -0
  23. package/dist/v2/core/utils/eventDispatcher.js +24 -0
  24. package/dist/v2/core/utils/jwtDecoder.d.ts +14 -0
  25. package/dist/v2/core/utils/jwtDecoder.js +85 -0
  26. package/dist/v2/core/utils/pluginConfig.d.ts +1 -0
  27. package/dist/v2/core/utils/pluginConfig.js +64 -8
  28. package/dist/v2/core/utils/tokenStorage.d.ts +19 -0
  29. package/dist/v2/core/utils/tokenStorage.js +52 -0
  30. package/dist/v2/react/components/ApplePayButton.js +1 -1
  31. package/dist/v2/react/components/DebugDrawer.js +90 -1
  32. package/dist/v2/react/hooks/__examples__/FunnelContextExample.d.ts +12 -0
  33. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +54 -0
  34. package/dist/v2/react/hooks/useFunnel.d.ts +2 -1
  35. package/dist/v2/react/hooks/useFunnel.js +245 -69
  36. package/dist/v2/react/hooks/useGoogleAutocomplete.js +26 -18
  37. package/dist/v2/react/hooks/useISOData.js +4 -2
  38. package/dist/v2/react/hooks/useOffersQuery.d.ts +42 -29
  39. package/dist/v2/react/hooks/useOffersQuery.js +266 -204
  40. package/dist/v2/react/hooks/usePaymentQuery.js +99 -6
  41. package/dist/v2/react/providers/TagadaProvider.d.ts +13 -21
  42. package/dist/v2/react/providers/TagadaProvider.js +79 -673
  43. package/package.json +1 -1
@@ -25,8 +25,10 @@ export function useISOData(language = 'en', autoImport = true, disputeSetting =
25
25
  }, [language, autoImport]);
26
26
  const data = useMemo(() => {
27
27
  try {
28
+ console.log('[SDK] Loading ISO data for language:', language, 'autoImport:', autoImport);
28
29
  // Get countries from pre-built data with language support
29
30
  const countriesArray = getCountries(language);
31
+ console.log('[SDK] Loaded countries count:', countriesArray.length);
30
32
  // Transform to our expected format (Record<string, ISOCountry>)
31
33
  const countries = {};
32
34
  countriesArray.forEach((country) => {
@@ -85,8 +87,8 @@ export function useISOData(language = 'en', autoImport = true, disputeSetting =
85
87
  registeredLanguages,
86
88
  };
87
89
  }
88
- catch (_error) {
89
- // Error handling removed
90
+ catch (error) {
91
+ console.error('[SDK] Error loading ISO data:', error);
90
92
  return {
91
93
  countries: {},
92
94
  getRegions: () => [],
@@ -2,8 +2,8 @@
2
2
  * Offers Hook using TanStack Query
3
3
  * Handles offers with automatic caching
4
4
  */
5
- import { Offer } from '../../core/resources/offers';
6
- import { CheckoutSessionState, OrderSummary, CurrencyOptions } from '../../core/resources/postPurchases';
5
+ import { Offer, OfferSummary } from '../../core/resources/offers';
6
+ import { CurrencyOptions, OrderSummary } from '../../core/resources/postPurchases';
7
7
  export interface UseOffersQueryOptions {
8
8
  /**
9
9
  * Array of offer IDs to fetch
@@ -18,32 +18,45 @@ export interface UseOffersQueryOptions {
18
18
  * Return URL for checkout sessions
19
19
  */
20
20
  returnUrl?: string;
21
+ /**
22
+ * Order ID to associate with the offers (required for payments)
23
+ */
24
+ orderId?: string;
25
+ /**
26
+ * The ID of the currently active offer to preview/fetch summary for.
27
+ * If provided, the hook will automatically fetch and manage the summary for this offer.
28
+ */
29
+ activeOfferId?: string;
30
+ /**
31
+ * Whether to skip auto-preview fetching (e.g. during navigation or processing)
32
+ */
33
+ skipPreview?: boolean;
21
34
  }
22
35
  export interface UseOffersQueryResult {
23
36
  offers: Offer[];
24
37
  isLoading: boolean;
25
38
  error: Error | null;
26
- refetch: () => Promise<void>;
27
- createCheckoutSession: (offerId: string, options?: {
28
- returnUrl?: string;
29
- }) => Promise<{
30
- checkoutUrl: string;
31
- }>;
39
+ /**
40
+ * Summary for the active offer (if activeOfferId is provided)
41
+ * Automatically falls back to static summary while loading dynamic data
42
+ */
43
+ activeSummary: OrderSummary | OfferSummary | null;
44
+ /**
45
+ * Whether the active offer summary is currently loading
46
+ */
47
+ isActiveSummaryLoading: boolean;
48
+ /**
49
+ * Pay for an offer
50
+ * Initializes a checkout session and pays it
51
+ */
32
52
  payOffer: (offerId: string, orderId?: string) => Promise<void>;
33
- transformToCheckout: (offerId: string, options?: {
34
- returnUrl?: string;
35
- }) => Promise<{
36
- checkoutUrl: string;
37
- }>;
38
- getOffer: (offerId: string) => Offer | undefined;
39
- getTotalValue: () => number;
40
- getTotalSavings: () => number;
41
- payWithCheckoutSession: (checkoutSessionId: string, orderId?: string) => Promise<void>;
42
- initCheckoutSession: (offerId: string, orderId: string, customerId?: string) => Promise<{
43
- checkoutSessionId: string;
44
- }>;
45
- getCheckoutSessionState: (offerId: string) => CheckoutSessionState | null;
46
- initializeOfferCheckout: (offerId: string) => Promise<void>;
53
+ /**
54
+ * Preview an offer's price/summary
55
+ */
56
+ preview: (offerId: string) => Promise<OrderSummary | OfferSummary | null>;
57
+ /**
58
+ * Get available variants for a product in an offer
59
+ */
47
60
  getAvailableVariants: (offerId: string, productId: string) => {
48
61
  variantId: string;
49
62
  variantName: string;
@@ -53,13 +66,13 @@ export interface UseOffersQueryResult {
53
66
  priceId: string;
54
67
  currencyOptions: CurrencyOptions;
55
68
  }[];
56
- selectVariant: (offerId: string, productId: string, variantId: string) => Promise<void>;
57
- getOrderSummary: (offerId: string) => OrderSummary | null;
69
+ /**
70
+ * Select a variant for a product in an offer
71
+ */
72
+ selectVariant: (offerId: string, productId: string, variantId: string) => Promise<OrderSummary | null>;
73
+ /**
74
+ * Check if variants are loading for a product
75
+ */
58
76
  isLoadingVariants: (offerId: string, productId: string) => boolean;
59
- isUpdatingOrderSummary: (offerId: string) => boolean;
60
- confirmPurchase: (offerId: string, options?: {
61
- draft?: boolean;
62
- returnUrl?: string;
63
- }) => Promise<void>;
64
77
  }
65
78
  export declare function useOffersQuery(options?: UseOffersQueryOptions): UseOffersQueryResult;