@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.
- package/dist/react/config/environment.d.ts +1 -22
- package/dist/react/config/environment.js +1 -132
- package/dist/react/utils/deviceInfo.d.ts +1 -39
- package/dist/react/utils/deviceInfo.js +1 -163
- package/dist/react/utils/jwtDecoder.d.ts +1 -14
- package/dist/react/utils/jwtDecoder.js +1 -86
- package/dist/react/utils/tokenStorage.d.ts +1 -16
- package/dist/react/utils/tokenStorage.js +1 -53
- package/dist/v2/core/client.d.ts +96 -0
- package/dist/v2/core/client.js +430 -0
- package/dist/v2/core/config/environment.d.ts +36 -0
- package/dist/v2/core/config/environment.js +155 -0
- package/dist/v2/core/pathRemapping.js +61 -3
- package/dist/v2/core/resources/apiClient.d.ts +13 -0
- package/dist/v2/core/resources/apiClient.js +77 -9
- package/dist/v2/core/resources/funnel.d.ts +21 -0
- package/dist/v2/core/resources/payments.d.ts +23 -0
- package/dist/v2/core/types.d.ts +271 -0
- package/dist/v2/core/types.js +4 -0
- package/dist/v2/core/utils/deviceInfo.d.ts +39 -0
- package/dist/v2/core/utils/deviceInfo.js +162 -0
- package/dist/v2/core/utils/eventDispatcher.d.ts +10 -0
- package/dist/v2/core/utils/eventDispatcher.js +24 -0
- package/dist/v2/core/utils/jwtDecoder.d.ts +14 -0
- package/dist/v2/core/utils/jwtDecoder.js +85 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +1 -0
- package/dist/v2/core/utils/pluginConfig.js +64 -8
- package/dist/v2/core/utils/tokenStorage.d.ts +19 -0
- package/dist/v2/core/utils/tokenStorage.js +52 -0
- package/dist/v2/react/components/ApplePayButton.js +1 -1
- package/dist/v2/react/components/DebugDrawer.js +90 -1
- package/dist/v2/react/hooks/__examples__/FunnelContextExample.d.ts +12 -0
- package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +54 -0
- package/dist/v2/react/hooks/useFunnel.d.ts +2 -1
- package/dist/v2/react/hooks/useFunnel.js +245 -69
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +26 -18
- package/dist/v2/react/hooks/useISOData.js +4 -2
- package/dist/v2/react/hooks/useOffersQuery.d.ts +42 -29
- package/dist/v2/react/hooks/useOffersQuery.js +266 -204
- package/dist/v2/react/hooks/usePaymentQuery.js +99 -6
- package/dist/v2/react/providers/TagadaProvider.d.ts +13 -21
- package/dist/v2/react/providers/TagadaProvider.js +79 -673
- package/package.json +1 -1
|
@@ -87,15 +87,28 @@ export function usePaymentQuery() {
|
|
|
87
87
|
},
|
|
88
88
|
onSuccess: (successPayment) => {
|
|
89
89
|
setIsLoading(false);
|
|
90
|
-
|
|
90
|
+
const response = {
|
|
91
91
|
paymentId: successPayment.id,
|
|
92
92
|
payment: successPayment,
|
|
93
|
-
|
|
93
|
+
// Extract order from payment if available (for funnel path resolution)
|
|
94
|
+
order: successPayment.order,
|
|
95
|
+
};
|
|
96
|
+
// Legacy callback (backwards compatibility)
|
|
97
|
+
options.onSuccess?.(response);
|
|
98
|
+
// Funnel-aligned callback (recommended)
|
|
99
|
+
options.onPaymentSuccess?.(response);
|
|
94
100
|
},
|
|
95
101
|
onFailure: (errorMsg) => {
|
|
96
102
|
setError(errorMsg);
|
|
97
103
|
setIsLoading(false);
|
|
104
|
+
// Legacy callback (backwards compatibility)
|
|
98
105
|
options.onFailure?.(errorMsg);
|
|
106
|
+
// Funnel-aligned callback (recommended)
|
|
107
|
+
options.onPaymentFailed?.({
|
|
108
|
+
code: 'PAYMENT_FAILED',
|
|
109
|
+
message: errorMsg,
|
|
110
|
+
payment,
|
|
111
|
+
});
|
|
99
112
|
},
|
|
100
113
|
});
|
|
101
114
|
}
|
|
@@ -105,22 +118,57 @@ export function usePaymentQuery() {
|
|
|
105
118
|
const errorMsg = _error instanceof Error ? _error.message : 'Failed to start 3DS challenge';
|
|
106
119
|
setError(errorMsg);
|
|
107
120
|
setIsLoading(false);
|
|
121
|
+
// Legacy callback (backwards compatibility)
|
|
108
122
|
options.onFailure?.(errorMsg);
|
|
123
|
+
// Funnel-aligned callback (recommended)
|
|
124
|
+
options.onPaymentFailed?.({
|
|
125
|
+
code: '3DS_CHALLENGE_FAILED',
|
|
126
|
+
message: errorMsg,
|
|
127
|
+
payment,
|
|
128
|
+
});
|
|
109
129
|
}
|
|
110
130
|
}
|
|
111
131
|
break;
|
|
112
132
|
case 'processor_auth':
|
|
113
133
|
case 'redirect': {
|
|
114
|
-
if (
|
|
134
|
+
// Only auto-redirect if explicitly enabled (disableAutoRedirect: false)
|
|
135
|
+
// Default behavior: disable redirects and let funnel orchestrator handle navigation
|
|
136
|
+
const shouldRedirect = options.disableAutoRedirect === false;
|
|
137
|
+
if (shouldRedirect && actionData.metadata?.redirect?.redirectUrl) {
|
|
115
138
|
window.location.href = actionData.metadata.redirect.redirectUrl;
|
|
116
139
|
}
|
|
140
|
+
else {
|
|
141
|
+
// If auto-redirect is disabled AND payment succeeded, call success callbacks
|
|
142
|
+
// This allows funnel orchestrator to handle navigation
|
|
143
|
+
if (payment.status === 'succeeded') {
|
|
144
|
+
setIsLoading(false);
|
|
145
|
+
const response = {
|
|
146
|
+
paymentId: payment.id,
|
|
147
|
+
payment,
|
|
148
|
+
// Extract order from payment if available (for funnel path resolution)
|
|
149
|
+
order: payment.order,
|
|
150
|
+
};
|
|
151
|
+
// Legacy callback (backwards compatibility)
|
|
152
|
+
options.onSuccess?.(response);
|
|
153
|
+
// Funnel-aligned callback (recommended)
|
|
154
|
+
options.onPaymentSuccess?.(response);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
117
157
|
break;
|
|
118
158
|
}
|
|
119
159
|
case 'error': {
|
|
120
160
|
const errorMsg = actionData.message || 'Payment processing failed';
|
|
161
|
+
const errorCode = actionData.errorCode || 'PAYMENT_FAILED';
|
|
121
162
|
setError(errorMsg);
|
|
122
163
|
setIsLoading(false);
|
|
164
|
+
// Legacy callback (backwards compatibility)
|
|
123
165
|
options.onFailure?.(errorMsg);
|
|
166
|
+
// Funnel-aligned callback (recommended)
|
|
167
|
+
options.onPaymentFailed?.({
|
|
168
|
+
code: errorCode,
|
|
169
|
+
message: errorMsg,
|
|
170
|
+
payment,
|
|
171
|
+
});
|
|
124
172
|
break;
|
|
125
173
|
}
|
|
126
174
|
}
|
|
@@ -147,7 +195,15 @@ export function usePaymentQuery() {
|
|
|
147
195
|
}
|
|
148
196
|
else if (response.payment.status === 'succeeded') {
|
|
149
197
|
setIsLoading(false);
|
|
150
|
-
|
|
198
|
+
// Ensure order is at response root (extract from payment if needed)
|
|
199
|
+
const successResponse = {
|
|
200
|
+
...response,
|
|
201
|
+
order: response.order || response.payment.order,
|
|
202
|
+
};
|
|
203
|
+
// Legacy callback (backwards compatibility)
|
|
204
|
+
options.onSuccess?.(successResponse);
|
|
205
|
+
// Funnel-aligned callback (recommended)
|
|
206
|
+
options.onPaymentSuccess?.(successResponse);
|
|
151
207
|
}
|
|
152
208
|
else {
|
|
153
209
|
// Start polling for payment status
|
|
@@ -157,15 +213,28 @@ export function usePaymentQuery() {
|
|
|
157
213
|
},
|
|
158
214
|
onSuccess: (payment) => {
|
|
159
215
|
setIsLoading(false);
|
|
160
|
-
|
|
216
|
+
const successResponse = {
|
|
161
217
|
paymentId: payment.id,
|
|
162
218
|
payment,
|
|
163
|
-
|
|
219
|
+
// Extract order from payment if available (for funnel path resolution)
|
|
220
|
+
order: payment.order,
|
|
221
|
+
};
|
|
222
|
+
// Legacy callback (backwards compatibility)
|
|
223
|
+
options.onSuccess?.(successResponse);
|
|
224
|
+
// Funnel-aligned callback (recommended)
|
|
225
|
+
options.onPaymentSuccess?.(successResponse);
|
|
164
226
|
},
|
|
165
227
|
onFailure: (errorMsg) => {
|
|
166
228
|
setError(errorMsg);
|
|
167
229
|
setIsLoading(false);
|
|
230
|
+
// Legacy callback (backwards compatibility)
|
|
168
231
|
options.onFailure?.(errorMsg);
|
|
232
|
+
// Funnel-aligned callback (recommended)
|
|
233
|
+
options.onPaymentFailed?.({
|
|
234
|
+
code: 'PAYMENT_FAILED',
|
|
235
|
+
message: errorMsg,
|
|
236
|
+
payment: response.payment,
|
|
237
|
+
});
|
|
169
238
|
},
|
|
170
239
|
});
|
|
171
240
|
}
|
|
@@ -175,7 +244,13 @@ export function usePaymentQuery() {
|
|
|
175
244
|
const errorMsg = _error instanceof Error ? _error.message : 'Payment failed';
|
|
176
245
|
setError(errorMsg);
|
|
177
246
|
setIsLoading(false);
|
|
247
|
+
// Legacy callback (backwards compatibility)
|
|
178
248
|
options.onFailure?.(errorMsg);
|
|
249
|
+
// Funnel-aligned callback (recommended)
|
|
250
|
+
options.onPaymentFailed?.({
|
|
251
|
+
code: 'PAYMENT_PROCESSING_ERROR',
|
|
252
|
+
message: errorMsg,
|
|
253
|
+
});
|
|
179
254
|
throw _error;
|
|
180
255
|
}
|
|
181
256
|
}, [paymentsResource, handlePaymentAction, startPolling]);
|
|
@@ -205,7 +280,13 @@ export function usePaymentQuery() {
|
|
|
205
280
|
setIsLoading(false);
|
|
206
281
|
const errorMsg = _error instanceof Error ? _error.message : 'Payment failed';
|
|
207
282
|
setError(errorMsg);
|
|
283
|
+
// Legacy callback (backwards compatibility)
|
|
208
284
|
options.onFailure?.(errorMsg);
|
|
285
|
+
// Funnel-aligned callback (recommended)
|
|
286
|
+
options.onPaymentFailed?.({
|
|
287
|
+
code: 'CARD_PAYMENT_ERROR',
|
|
288
|
+
message: errorMsg,
|
|
289
|
+
});
|
|
209
290
|
throw _error;
|
|
210
291
|
}
|
|
211
292
|
}, [createCardPaymentInstrument, createSession, processPaymentDirect]);
|
|
@@ -223,7 +304,13 @@ export function usePaymentQuery() {
|
|
|
223
304
|
setIsLoading(false);
|
|
224
305
|
const errorMsg = _error instanceof Error ? _error.message : 'Apple Pay payment failed';
|
|
225
306
|
setError(errorMsg);
|
|
307
|
+
// Legacy callback (backwards compatibility)
|
|
226
308
|
options.onFailure?.(errorMsg);
|
|
309
|
+
// Funnel-aligned callback (recommended)
|
|
310
|
+
options.onPaymentFailed?.({
|
|
311
|
+
code: 'APPLE_PAY_ERROR',
|
|
312
|
+
message: errorMsg,
|
|
313
|
+
});
|
|
227
314
|
throw _error;
|
|
228
315
|
}
|
|
229
316
|
}, [createApplePayPaymentInstrument, processPaymentDirect]);
|
|
@@ -238,7 +325,13 @@ export function usePaymentQuery() {
|
|
|
238
325
|
setIsLoading(false);
|
|
239
326
|
const errorMsg = _error instanceof Error ? _error.message : 'Payment failed';
|
|
240
327
|
setError(errorMsg);
|
|
328
|
+
// Legacy callback (backwards compatibility)
|
|
241
329
|
options.onFailure?.(errorMsg);
|
|
330
|
+
// Funnel-aligned callback (recommended)
|
|
331
|
+
options.onPaymentFailed?.({
|
|
332
|
+
code: 'PAYMENT_INSTRUMENT_ERROR',
|
|
333
|
+
message: errorMsg,
|
|
334
|
+
});
|
|
242
335
|
throw _error;
|
|
243
336
|
}
|
|
244
337
|
}, [processPaymentDirect]);
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TagadaState } from '../../core/client';
|
|
3
|
+
import { RawPluginConfig } from '../../core/utils/pluginConfig';
|
|
4
|
+
import { Environment, EnvironmentConfig } from '../../core/types';
|
|
3
5
|
import { ApiService } from '../../../react/services/apiService';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
interface TagadaContextValue {
|
|
7
|
-
auth: AuthState;
|
|
8
|
-
session: Session | null;
|
|
9
|
-
customer: Customer | null;
|
|
10
|
-
locale: Locale;
|
|
11
|
-
currency: Currency;
|
|
12
|
-
store: Store | null;
|
|
13
|
-
environment: EnvironmentConfig;
|
|
6
|
+
import { formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, convertCurrency } from '../../../react/utils/money';
|
|
7
|
+
interface TagadaContextValue extends TagadaState {
|
|
14
8
|
apiService: ApiService;
|
|
15
|
-
isLoading: boolean;
|
|
16
|
-
isInitialized: boolean;
|
|
17
|
-
isSessionInitialized: boolean;
|
|
18
|
-
debugMode: boolean;
|
|
19
|
-
pluginConfig: PluginConfig;
|
|
20
|
-
pluginConfigLoading: boolean;
|
|
21
9
|
debugCheckout: {
|
|
22
10
|
isActive: boolean;
|
|
23
11
|
data: any;
|
|
@@ -40,7 +28,7 @@ interface TagadaContextValue {
|
|
|
40
28
|
notifyCheckoutChanged: () => Promise<void>;
|
|
41
29
|
notifyOrderBumpChanged: () => Promise<void>;
|
|
42
30
|
unregisterCheckoutRefresh: (refreshFn?: () => Promise<void>) => void;
|
|
43
|
-
unregisterOrderBumpRefresh: () => void;
|
|
31
|
+
unregisterOrderBumpRefresh: (refreshFn?: () => Promise<void>) => void;
|
|
44
32
|
};
|
|
45
33
|
money: {
|
|
46
34
|
formatMoney: typeof formatMoney;
|
|
@@ -54,6 +42,11 @@ interface TagadaContextValue {
|
|
|
54
42
|
}
|
|
55
43
|
interface TagadaProviderProps {
|
|
56
44
|
children: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Optional environment override.
|
|
47
|
+
* ⚠️ Leave undefined for automatic runtime detection (recommended).
|
|
48
|
+
* Only set this if you need to force a specific environment for testing.
|
|
49
|
+
*/
|
|
57
50
|
environment?: Environment;
|
|
58
51
|
customApiConfig?: Partial<EnvironmentConfig>;
|
|
59
52
|
debugMode?: boolean;
|
|
@@ -61,8 +54,7 @@ interface TagadaProviderProps {
|
|
|
61
54
|
blockUntilSessionReady?: boolean;
|
|
62
55
|
rawPluginConfig?: RawPluginConfig;
|
|
63
56
|
}
|
|
64
|
-
export declare function TagadaProvider({ children, environment, customApiConfig,
|
|
65
|
-
localConfig, blockUntilSessionReady,
|
|
66
|
-
rawPluginConfig, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export declare function TagadaProvider({ children, environment, customApiConfig, // Ignored for now in TagadaClient, or need to add support
|
|
58
|
+
debugMode, localConfig, blockUntilSessionReady, rawPluginConfig, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
67
59
|
export declare function useTagadaContext(): TagadaContextValue;
|
|
68
60
|
export {};
|