@tagadapay/plugin-sdk 3.1.12 → 3.1.24

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 (144) hide show
  1. package/build-cdn.js +397 -11
  2. package/dist/data/iso3166.d.ts +23 -33
  3. package/dist/data/iso3166.js +134 -198
  4. package/dist/data/languages.d.ts +5 -64
  5. package/dist/data/languages.js +23 -143
  6. package/dist/external-tracker.js +623 -3426
  7. package/dist/external-tracker.min.js +2 -25
  8. package/dist/external-tracker.min.js.map +4 -4
  9. package/dist/react/config/payment.d.ts +14 -4
  10. package/dist/react/config/payment.js +47 -9
  11. package/dist/react/hooks/useCheckout.d.ts +3 -0
  12. package/dist/react/hooks/useCheckout.js +4 -1
  13. package/dist/react/hooks/useISOData.js +1 -1
  14. package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
  15. package/dist/react/hooks/usePluginConfig.js +9 -10
  16. package/dist/react/providers/TagadaProvider.js +1 -1
  17. package/dist/tagada-react-sdk-minimal.min.js +36 -0
  18. package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
  19. package/dist/tagada-react-sdk.js +37821 -0
  20. package/dist/tagada-react-sdk.min.js +78 -0
  21. package/dist/tagada-react-sdk.min.js.map +7 -0
  22. package/dist/tagada-sdk.js +16044 -0
  23. package/dist/tagada-sdk.min.js +32 -0
  24. package/dist/tagada-sdk.min.js.map +7 -0
  25. package/dist/v2/cdn-react-minimal.d.ts +23 -0
  26. package/dist/v2/cdn-react-minimal.js +26 -0
  27. package/dist/v2/core/client.d.ts +4 -2
  28. package/dist/v2/core/client.js +5 -4
  29. package/dist/v2/core/config/environment.js +2 -1
  30. package/dist/v2/core/errors.d.ts +75 -0
  31. package/dist/v2/core/errors.js +104 -0
  32. package/dist/v2/core/funnelClient.d.ts +100 -10
  33. package/dist/v2/core/funnelClient.js +121 -27
  34. package/dist/v2/core/isoData.d.ts +4 -4
  35. package/dist/v2/core/isoData.js +7 -7
  36. package/dist/v2/core/pixelMapping.d.ts +49 -0
  37. package/dist/v2/core/pixelMapping.js +363 -0
  38. package/dist/v2/core/resources/apiClient.d.ts +2 -0
  39. package/dist/v2/core/resources/apiClient.js +52 -9
  40. package/dist/v2/core/resources/checkout.d.ts +99 -30
  41. package/dist/v2/core/resources/checkout.js +14 -0
  42. package/dist/v2/core/resources/customer.d.ts +20 -19
  43. package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
  44. package/dist/v2/core/resources/funnel.d.ts +17 -17
  45. package/dist/v2/core/resources/payments.d.ts +89 -13
  46. package/dist/v2/core/resources/payments.js +27 -9
  47. package/dist/v2/core/resources/postPurchases.d.ts +17 -0
  48. package/dist/v2/core/resources/postPurchases.js +20 -0
  49. package/dist/v2/core/types.d.ts +50 -12
  50. package/dist/v2/core/types.js +0 -3
  51. package/dist/v2/core/utils/checkout.d.ts +2 -2
  52. package/dist/v2/core/utils/checkout.js +7 -2
  53. package/dist/v2/core/utils/currency.d.ts +14 -0
  54. package/dist/v2/core/utils/currency.js +40 -0
  55. package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
  56. package/dist/v2/core/utils/deviceInfo.js +152 -76
  57. package/dist/v2/core/utils/index.d.ts +1 -0
  58. package/dist/v2/core/utils/index.js +2 -0
  59. package/dist/v2/core/utils/order.d.ts +13 -9
  60. package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
  61. package/dist/v2/core/utils/pluginConfig.js +36 -12
  62. package/dist/v2/index.d.ts +6 -3
  63. package/dist/v2/index.js +4 -2
  64. package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
  65. package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
  66. package/dist/v2/react/components/StripeExpressButton.js +171 -0
  67. package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
  68. package/dist/v2/react/components/WhopCheckout.js +237 -0
  69. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
  70. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
  71. package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
  72. package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
  73. package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
  74. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
  75. package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
  76. package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
  77. package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
  78. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
  79. package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
  80. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
  81. package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
  82. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
  83. package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
  84. package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
  85. package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
  86. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
  87. package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
  88. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
  89. package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
  90. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
  91. package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
  92. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
  93. package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
  94. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
  95. package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
  96. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
  97. package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
  98. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
  99. package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
  100. package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
  101. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
  102. package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
  103. package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
  104. package/dist/v2/react/hooks/useFunnel.js +8 -4
  105. package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
  106. package/dist/v2/react/hooks/useGeoLocation.js +4 -2
  107. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
  108. package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
  109. package/dist/v2/react/hooks/useISOData.d.ts +2 -5
  110. package/dist/v2/react/hooks/useISOData.js +26 -27
  111. package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
  112. package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
  113. package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
  114. package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
  115. package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
  116. package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
  117. package/dist/v2/react/hooks/usePixelTracking.js +283 -504
  118. package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
  119. package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
  120. package/dist/v2/react/hooks/useRemappableParams.js +23 -23
  121. package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
  122. package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
  123. package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
  124. package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
  125. package/dist/v2/react/hooks/useStepConfig.js +14 -7
  126. package/dist/v2/react/hooks/useTranslation.js +23 -8
  127. package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
  128. package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
  129. package/dist/v2/react/index.d.ts +15 -1
  130. package/dist/v2/react/index.js +7 -0
  131. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
  132. package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
  133. package/dist/v2/react/providers/TagadaProvider.js +74 -5
  134. package/dist/v2/standalone/external-tracker.d.ts +52 -46
  135. package/dist/v2/standalone/external-tracker.js +205 -98
  136. package/dist/v2/standalone/index.d.ts +40 -0
  137. package/dist/v2/standalone/index.js +148 -1
  138. package/dist/v2/standalone/payment-service.d.ts +134 -0
  139. package/dist/v2/standalone/payment-service.js +928 -0
  140. package/package.json +6 -4
  141. package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
  142. package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
  143. package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
  144. package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
@@ -0,0 +1,134 @@
1
+ /**
2
+ * PaymentService (Standalone / Vanilla JS)
3
+ *
4
+ * Complete standalone equivalent of the React SDK's payment system:
5
+ * - usePaymentQuery (orchestration)
6
+ * - usePaymentPolling (status polling)
7
+ * - usePaymentActionHandler (action routing)
8
+ * - usePaymentProcessors (card, APM, Apple Pay, Google Pay, saved instruments)
9
+ * - usePaymentInstruments (instrument creation)
10
+ * - useThreeds (3DS session + challenge)
11
+ * - useGenericPaymentReturn (generic redirect return)
12
+ * - useAirwallex3dsReturn (Airwallex-specific redirect return)
13
+ * - All action handlers: redirect, threeds_auth, processor_auth, error,
14
+ * kesspay_auth, trustflow_auth, finix_radar, stripe_radar, airwallex radar,
15
+ * mastercard_auth
16
+ *
17
+ * No React. No hooks. No DOM framework dependency.
18
+ */
19
+ import { PaymentsResource, type Payment, type CardPaymentMethod, type ApplePayToken, type GooglePayToken, type PaymentInstrumentResponse, type PaymentInstrumentCustomerResponse } from '../core/resources/payments';
20
+ import type { ApiClient } from '../core/resources/apiClient';
21
+ export interface PaymentServiceConfig {
22
+ apiClient: ApiClient;
23
+ storeId?: string;
24
+ }
25
+ export interface CardData {
26
+ cardNumber: string;
27
+ expiryDate: string;
28
+ cvc: string;
29
+ }
30
+ export interface ApmData {
31
+ processorId: string;
32
+ paymentMethod: string;
33
+ initiatedBy?: 'customer' | 'merchant';
34
+ source?: 'upsell' | 'checkout' | 'offer' | 'missing_club' | 'forced';
35
+ }
36
+ export interface PaymentResult {
37
+ success: boolean;
38
+ payment?: Payment;
39
+ order?: {
40
+ id: string;
41
+ checkoutSessionId?: string;
42
+ } | null;
43
+ error?: string;
44
+ /** True if the browser is being redirected (page will unload) */
45
+ redirecting?: boolean;
46
+ }
47
+ export interface PaymentCallbacks {
48
+ onProcessing?: (processing: boolean) => void;
49
+ onError?: (error: string | null) => void;
50
+ onCurrentPaymentId?: (paymentId: string | null) => void;
51
+ onSuccess?: (payment: Payment) => void;
52
+ onFailure?: (error: string) => void;
53
+ onRedirectReturn?: (paymentId: string) => void;
54
+ }
55
+ export interface PollingCallbacks {
56
+ onSuccess: (payment: Payment) => void;
57
+ onFailure: (error: string) => void;
58
+ onRequireAction?: (payment: Payment) => void;
59
+ }
60
+ export declare class PaymentService {
61
+ private paymentsResource;
62
+ private threedsResource;
63
+ private storeConfigResource;
64
+ private storeId?;
65
+ private callbacks;
66
+ private basisTheory;
67
+ private btInitPromise;
68
+ private bt3dsClass;
69
+ private bt3dsInitPromise;
70
+ private storeConfig;
71
+ private storeConfigPromise;
72
+ private pollTimer;
73
+ private pollAttempts;
74
+ private isPollingActive;
75
+ private redirectReturnProcessed;
76
+ constructor(config: PaymentServiceConfig);
77
+ /** Expose paymentsResource for advanced consumers */
78
+ get payments(): PaymentsResource;
79
+ setCallbacks(callbacks: PaymentCallbacks): void;
80
+ /** Pre-warm BasisTheory + store config (non-blocking). */
81
+ warmup(): void;
82
+ destroy(): void;
83
+ private initBasisTheory;
84
+ private getBtApiKey;
85
+ /** Lazy-load @basis-theory/web-threeds (BasisTheory3ds class) */
86
+ private initBt3ds;
87
+ private fetchStoreConfig;
88
+ stopPolling(): void;
89
+ startPolling(paymentId: string, callbacks: PollingCallbacks, maxAttempts?: number, interval?: number): void;
90
+ /**
91
+ * Internal: call processPaymentDirect and handle requireAction / polling.
92
+ * Shared by processCardPayment, processApplePayPayment, etc.
93
+ */
94
+ private processAndHandle;
95
+ /**
96
+ * After radar / completePaymentAfterAction, handle the resumed payment.
97
+ */
98
+ private handleResumedPayment;
99
+ handlePaymentAction(payment: Payment): Promise<void>;
100
+ private handleKessPayAuth;
101
+ private handleTrustFlowAuth;
102
+ private handleFinixRadar;
103
+ private handleStripeRadar;
104
+ private handleAirwallexRadar;
105
+ private handleMasterCardAuth;
106
+ private loadScript;
107
+ private waitFor;
108
+ /**
109
+ * Detect ALL redirect return types and resume.
110
+ * Handles both generic returns and Airwallex-specific 3DS returns.
111
+ * Call once during initialization. Returns true if a return was detected.
112
+ */
113
+ detectRedirectReturn(): boolean;
114
+ private detectGenericRedirectReturn;
115
+ private detectAirwallex3dsReturn;
116
+ private handleAirwallex3dsRedirectReturn;
117
+ cleanPaymentUrlParams(): void;
118
+ createCardPaymentInstrument(cardData: CardPaymentMethod): Promise<PaymentInstrumentResponse>;
119
+ createApplePayPaymentInstrument(token: ApplePayToken): Promise<PaymentInstrumentResponse>;
120
+ createGooglePayPaymentInstrument(token: GooglePayToken): Promise<PaymentInstrumentResponse>;
121
+ getCardPaymentInstruments(): Promise<PaymentInstrumentCustomerResponse>;
122
+ createThreedsSession(paymentInstrument: {
123
+ id: string;
124
+ token: string | null;
125
+ }): Promise<{
126
+ id: string;
127
+ sessionId: string;
128
+ }>;
129
+ processCardPayment(checkoutSessionId: string, cardData: CardData): Promise<PaymentResult>;
130
+ processApplePayPayment(checkoutSessionId: string, applePayToken: ApplePayToken): Promise<PaymentResult>;
131
+ processGooglePayPayment(checkoutSessionId: string, googlePayToken: GooglePayToken): Promise<PaymentResult>;
132
+ processPaymentWithInstrument(checkoutSessionId: string, paymentInstrumentId: string): Promise<PaymentResult>;
133
+ processApmPayment(checkoutSessionId: string, apmData: ApmData): Promise<PaymentResult>;
134
+ }