@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.
- package/build-cdn.js +397 -11
- package/dist/data/iso3166.d.ts +23 -33
- package/dist/data/iso3166.js +134 -198
- package/dist/data/languages.d.ts +5 -64
- package/dist/data/languages.js +23 -143
- package/dist/external-tracker.js +623 -3426
- package/dist/external-tracker.min.js +2 -25
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/config/payment.d.ts +14 -4
- package/dist/react/config/payment.js +47 -9
- package/dist/react/hooks/useCheckout.d.ts +3 -0
- package/dist/react/hooks/useCheckout.js +4 -1
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/react/hooks/usePluginConfig.js +9 -10
- package/dist/react/providers/TagadaProvider.js +1 -1
- package/dist/tagada-react-sdk-minimal.min.js +36 -0
- package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
- package/dist/tagada-react-sdk.js +37821 -0
- package/dist/tagada-react-sdk.min.js +78 -0
- package/dist/tagada-react-sdk.min.js.map +7 -0
- package/dist/tagada-sdk.js +16044 -0
- package/dist/tagada-sdk.min.js +32 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/cdn-react-minimal.d.ts +23 -0
- package/dist/v2/cdn-react-minimal.js +26 -0
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +5 -4
- package/dist/v2/core/config/environment.js +2 -1
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +100 -10
- package/dist/v2/core/funnelClient.js +121 -27
- package/dist/v2/core/isoData.d.ts +4 -4
- package/dist/v2/core/isoData.js +7 -7
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +363 -0
- package/dist/v2/core/resources/apiClient.d.ts +2 -0
- package/dist/v2/core/resources/apiClient.js +52 -9
- package/dist/v2/core/resources/checkout.d.ts +99 -30
- package/dist/v2/core/resources/checkout.js +14 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +89 -13
- package/dist/v2/core/resources/payments.js +27 -9
- package/dist/v2/core/resources/postPurchases.d.ts +17 -0
- package/dist/v2/core/resources/postPurchases.js +20 -0
- package/dist/v2/core/types.d.ts +50 -12
- package/dist/v2/core/types.js +0 -3
- package/dist/v2/core/utils/checkout.d.ts +2 -2
- package/dist/v2/core/utils/checkout.js +7 -2
- package/dist/v2/core/utils/currency.d.ts +14 -0
- package/dist/v2/core/utils/currency.js +40 -0
- package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
- package/dist/v2/core/utils/deviceInfo.js +152 -76
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/order.d.ts +13 -9
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +36 -12
- package/dist/v2/index.d.ts +6 -3
- package/dist/v2/index.js +4 -2
- package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
- package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
- package/dist/v2/react/components/StripeExpressButton.js +171 -0
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +237 -0
- package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
- package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
- package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
- package/dist/v2/react/hooks/useFunnel.js +8 -4
- package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
- package/dist/v2/react/hooks/useGeoLocation.js +4 -2
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
- package/dist/v2/react/hooks/useISOData.d.ts +2 -5
- package/dist/v2/react/hooks/useISOData.js +26 -27
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
- package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
- package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
- package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
- package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
- package/dist/v2/react/hooks/usePixelTracking.js +283 -504
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
- package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
- package/dist/v2/react/hooks/useRemappableParams.js +23 -23
- package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
- package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
- package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
- package/dist/v2/react/hooks/useStepConfig.js +14 -7
- package/dist/v2/react/hooks/useTranslation.js +23 -8
- package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
- package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
- package/dist/v2/react/index.d.ts +15 -1
- package/dist/v2/react/index.js +7 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
- package/dist/v2/react/providers/TagadaProvider.js +74 -5
- package/dist/v2/standalone/external-tracker.d.ts +52 -46
- package/dist/v2/standalone/external-tracker.js +205 -98
- package/dist/v2/standalone/index.d.ts +40 -0
- package/dist/v2/standalone/index.js +148 -1
- package/dist/v2/standalone/payment-service.d.ts +134 -0
- package/dist/v2/standalone/payment-service.js +928 -0
- package/package.json +6 -4
- package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
- package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
- package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
- package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
* Axios-based API client for payment endpoints
|
|
4
4
|
*/
|
|
5
5
|
import { ApiClient } from './apiClient';
|
|
6
|
+
import type { Order } from '../types';
|
|
6
7
|
export interface Payment {
|
|
7
8
|
id: string;
|
|
8
9
|
status: string;
|
|
9
10
|
subStatus: string;
|
|
10
|
-
requireAction: 'none' | 'redirect' | 'error' | 'radar';
|
|
11
|
+
requireAction: 'none' | 'redirect' | 'redirect_to_payment' | 'error' | 'radar' | 'stripe_express_checkout';
|
|
11
12
|
requireActionData?: {
|
|
12
|
-
type: 'redirect' | 'threeds_auth' | 'processor_auth' | 'error' | 'stripe_radar' | 'finix_radar' | 'radar';
|
|
13
|
+
type: 'redirect' | 'redirect_to_payment' | 'threeds_auth' | 'processor_auth' | 'error' | 'stripe_radar' | 'finix_radar' | 'radar' | 'kesspay_auth' | 'trustflow_auth' | 'mastercard_auth' | 'stripe_express_checkout';
|
|
13
14
|
url?: string;
|
|
14
15
|
processed: boolean;
|
|
15
16
|
processorId?: string;
|
|
16
17
|
metadata?: {
|
|
17
|
-
type: 'redirect' | 'stripe_radar' | 'finix_radar';
|
|
18
|
+
type: 'redirect' | 'redirect_to_payment' | 'stripe_radar' | 'finix_radar';
|
|
18
19
|
redirect?: {
|
|
19
20
|
redirectUrl: string;
|
|
20
21
|
returnUrl: string;
|
|
@@ -31,6 +32,10 @@ export interface Payment {
|
|
|
31
32
|
orderId?: string;
|
|
32
33
|
publishableKey?: string;
|
|
33
34
|
};
|
|
35
|
+
stripeExpressCheckout?: {
|
|
36
|
+
clientSecret: string;
|
|
37
|
+
publishableKey?: string;
|
|
38
|
+
};
|
|
34
39
|
provider?: string;
|
|
35
40
|
isTest?: boolean;
|
|
36
41
|
};
|
|
@@ -42,12 +47,15 @@ export interface Payment {
|
|
|
42
47
|
order?: {
|
|
43
48
|
id: string;
|
|
44
49
|
checkoutSessionId: string;
|
|
50
|
+
amount?: number;
|
|
51
|
+
currency?: string;
|
|
52
|
+
[key: string]: unknown;
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
55
|
export interface PaymentResponse {
|
|
48
56
|
paymentId: string;
|
|
49
57
|
payment: Payment;
|
|
50
|
-
order?:
|
|
58
|
+
order?: Order | null;
|
|
51
59
|
}
|
|
52
60
|
export interface PaymentInstrumentResponse {
|
|
53
61
|
id: string;
|
|
@@ -94,6 +102,16 @@ export interface PaymentOptions {
|
|
|
94
102
|
* If neither is set, the store's selectedPaymentFlowId will be used
|
|
95
103
|
*/
|
|
96
104
|
paymentFlowId?: string;
|
|
105
|
+
/**
|
|
106
|
+
* For alternative payment methods (APM)
|
|
107
|
+
* Processor ID to use for the payment
|
|
108
|
+
*/
|
|
109
|
+
processorId?: string;
|
|
110
|
+
/**
|
|
111
|
+
* For alternative payment methods (APM)
|
|
112
|
+
* Payment method type (e.g., 'klarna', 'afterpay', 'paypal')
|
|
113
|
+
*/
|
|
114
|
+
paymentMethod?: string;
|
|
97
115
|
/** @deprecated Use onPaymentSuccess instead - this will be removed in v3 */
|
|
98
116
|
onSuccess?: (response: PaymentResponse) => void;
|
|
99
117
|
/** @deprecated Use onPaymentFailed instead - this will be removed in v3 */
|
|
@@ -138,28 +156,83 @@ export interface ApplePayToken {
|
|
|
138
156
|
brand: string;
|
|
139
157
|
};
|
|
140
158
|
}
|
|
159
|
+
/** Token response from BasisTheory SDK */
|
|
160
|
+
export interface BasisTheoryTokenResponse {
|
|
161
|
+
id: string;
|
|
162
|
+
type: string;
|
|
163
|
+
enrichments?: {
|
|
164
|
+
cardDetails?: {
|
|
165
|
+
bin?: string;
|
|
166
|
+
last4?: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** External BasisTheory SDK instance shape (from @basis-theory/basis-theory-react) */
|
|
171
|
+
export interface BasisTheoryInstance {
|
|
172
|
+
tokens: {
|
|
173
|
+
create(data: Record<string, unknown>): Promise<BasisTheoryTokenResponse>;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export interface GooglePayToken {
|
|
177
|
+
id: string;
|
|
178
|
+
type: string;
|
|
179
|
+
card: {
|
|
180
|
+
bin: string;
|
|
181
|
+
last4: string;
|
|
182
|
+
expiration_month: number;
|
|
183
|
+
expiration_year: number;
|
|
184
|
+
brand: string;
|
|
185
|
+
};
|
|
186
|
+
details?: {
|
|
187
|
+
auth_method?: string;
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export interface PaymentInstrumentInput {
|
|
192
|
+
type: string;
|
|
193
|
+
token?: string;
|
|
194
|
+
card?: {
|
|
195
|
+
maskedCardNumber?: string;
|
|
196
|
+
expirationMonth?: number;
|
|
197
|
+
expirationYear?: number;
|
|
198
|
+
bin?: string;
|
|
199
|
+
last4?: string;
|
|
200
|
+
brand?: string;
|
|
201
|
+
};
|
|
202
|
+
dpanType?: string;
|
|
203
|
+
authMethod?: string;
|
|
204
|
+
provider?: string;
|
|
205
|
+
paymentMethod?: string;
|
|
206
|
+
processorId?: string;
|
|
207
|
+
[key: string]: unknown;
|
|
208
|
+
}
|
|
141
209
|
export declare class PaymentsResource {
|
|
142
210
|
private apiClient;
|
|
143
211
|
constructor(apiClient: ApiClient);
|
|
144
212
|
/**
|
|
145
213
|
* Create payment instrument
|
|
146
214
|
*/
|
|
147
|
-
createPaymentInstrument(paymentInstrumentData:
|
|
215
|
+
createPaymentInstrument(paymentInstrumentData: PaymentInstrumentInput): Promise<PaymentInstrumentResponse>;
|
|
148
216
|
/**
|
|
149
217
|
* Create card payment instrument
|
|
150
218
|
*/
|
|
151
|
-
createCardPaymentInstrument(basisTheory:
|
|
152
|
-
cardData: CardPaymentMethod): Promise<PaymentInstrumentResponse>;
|
|
219
|
+
createCardPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, cardData: CardPaymentMethod): Promise<PaymentInstrumentResponse>;
|
|
153
220
|
/**
|
|
154
221
|
* Create Apple Pay payment instrument
|
|
155
222
|
*/
|
|
156
|
-
createApplePayPaymentInstrument(basisTheory:
|
|
157
|
-
applePayToken: ApplePayToken): Promise<PaymentInstrumentResponse>;
|
|
223
|
+
createApplePayPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, applePayToken: ApplePayToken): Promise<PaymentInstrumentResponse>;
|
|
158
224
|
/**
|
|
159
225
|
* Create Google Pay payment instrument
|
|
160
226
|
*/
|
|
161
|
-
createGooglePayPaymentInstrument(basisTheory:
|
|
162
|
-
|
|
227
|
+
createGooglePayPaymentInstrument(basisTheory: BasisTheoryInstance | undefined, googlePayToken: GooglePayToken): Promise<PaymentInstrumentResponse>;
|
|
228
|
+
/**
|
|
229
|
+
* Create APM payment instrument (Klarna, Afterpay, PayPal, etc.)
|
|
230
|
+
*/
|
|
231
|
+
createApmPaymentInstrument(apmData: {
|
|
232
|
+
provider: string;
|
|
233
|
+
paymentMethod: string;
|
|
234
|
+
processorId: string;
|
|
235
|
+
}): Promise<PaymentInstrumentResponse>;
|
|
163
236
|
/**
|
|
164
237
|
* Helper function to format expiry date
|
|
165
238
|
*/
|
|
@@ -171,6 +244,9 @@ export declare class PaymentsResource {
|
|
|
171
244
|
initiatedBy?: 'customer' | 'merchant';
|
|
172
245
|
source?: 'upsell' | 'checkout' | 'offer' | 'missing_club' | 'forced';
|
|
173
246
|
paymentFlowId?: string;
|
|
247
|
+
processorId?: string;
|
|
248
|
+
paymentMethod?: string;
|
|
249
|
+
isExpress?: boolean;
|
|
174
250
|
}): Promise<PaymentResponse>;
|
|
175
251
|
/**
|
|
176
252
|
* Get card payment instruments for customer
|
|
@@ -200,7 +276,7 @@ export declare class PaymentsResource {
|
|
|
200
276
|
transactionId?: string;
|
|
201
277
|
message?: string;
|
|
202
278
|
success?: boolean;
|
|
203
|
-
error?:
|
|
279
|
+
error?: string;
|
|
204
280
|
}>;
|
|
205
281
|
saveRadarSession(data: {
|
|
206
282
|
orderId?: string;
|
|
@@ -226,5 +302,5 @@ export declare class PaymentsResource {
|
|
|
226
302
|
paymentId: string;
|
|
227
303
|
status: 'succeeded' | 'failed' | 'pending';
|
|
228
304
|
paymentIntentId: string;
|
|
229
|
-
}): Promise<
|
|
305
|
+
}): Promise<Payment>;
|
|
230
306
|
}
|
|
@@ -17,8 +17,7 @@ export class PaymentsResource {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create card payment instrument
|
|
19
19
|
*/
|
|
20
|
-
async createCardPaymentInstrument(basisTheory,
|
|
21
|
-
cardData) {
|
|
20
|
+
async createCardPaymentInstrument(basisTheory, cardData) {
|
|
22
21
|
if (!basisTheory) {
|
|
23
22
|
throw new Error('Payment processor not initialized');
|
|
24
23
|
}
|
|
@@ -55,8 +54,7 @@ export class PaymentsResource {
|
|
|
55
54
|
/**
|
|
56
55
|
* Create Apple Pay payment instrument
|
|
57
56
|
*/
|
|
58
|
-
async createApplePayPaymentInstrument(basisTheory,
|
|
59
|
-
applePayToken) {
|
|
57
|
+
async createApplePayPaymentInstrument(basisTheory, applePayToken) {
|
|
60
58
|
if (!basisTheory) {
|
|
61
59
|
throw new Error('Payment processor not initialized');
|
|
62
60
|
}
|
|
@@ -81,9 +79,7 @@ export class PaymentsResource {
|
|
|
81
79
|
/**
|
|
82
80
|
* Create Google Pay payment instrument
|
|
83
81
|
*/
|
|
84
|
-
async createGooglePayPaymentInstrument(basisTheory,
|
|
85
|
-
googlePayToken // Token from Basis Theory Google Pay tokenization
|
|
86
|
-
) {
|
|
82
|
+
async createGooglePayPaymentInstrument(basisTheory, googlePayToken) {
|
|
87
83
|
if (!basisTheory) {
|
|
88
84
|
throw new Error('Payment processor not initialized');
|
|
89
85
|
}
|
|
@@ -106,6 +102,21 @@ export class PaymentsResource {
|
|
|
106
102
|
const response = await this.apiClient.post('/api/v1/payment/create-payment-instrument', { paymentInstrumentData });
|
|
107
103
|
return response;
|
|
108
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Create APM payment instrument (Klarna, Afterpay, PayPal, etc.)
|
|
107
|
+
*/
|
|
108
|
+
async createApmPaymentInstrument(apmData) {
|
|
109
|
+
console.log('Creating APM payment instrument:', apmData);
|
|
110
|
+
const paymentInstrumentData = {
|
|
111
|
+
type: 'apm',
|
|
112
|
+
provider: apmData.provider,
|
|
113
|
+
paymentMethod: apmData.paymentMethod,
|
|
114
|
+
processorId: apmData.processorId,
|
|
115
|
+
};
|
|
116
|
+
const response = await this.apiClient.post('/api/v1/payment/create-payment-instrument', { paymentInstrumentData });
|
|
117
|
+
console.log('APM payment instrument created:', response);
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
109
120
|
/**
|
|
110
121
|
* Helper function to format expiry date
|
|
111
122
|
*/
|
|
@@ -124,15 +135,22 @@ export class PaymentsResource {
|
|
|
124
135
|
*/
|
|
125
136
|
async processPaymentDirect(checkoutSessionId, paymentInstrumentId, threedsSessionId, options = {}) {
|
|
126
137
|
console.log('[PaymentsResource] processPaymentDirect START', options.paymentFlowId ? `(flow: ${options.paymentFlowId})` : '');
|
|
138
|
+
console.log('[PaymentsResource] Full options object:', JSON.stringify(options, null, 2));
|
|
139
|
+
console.log('[PaymentsResource] processorId:', options.processorId, 'paymentMethod:', options.paymentMethod);
|
|
127
140
|
try {
|
|
128
|
-
const
|
|
141
|
+
const requestBody = {
|
|
129
142
|
checkoutSessionId,
|
|
130
143
|
paymentInstrumentId,
|
|
131
144
|
...(threedsSessionId && { threedsSessionId }),
|
|
132
145
|
...(options.initiatedBy && { initiatedBy: options.initiatedBy }),
|
|
133
146
|
...(options.source && { source: options.source }),
|
|
134
147
|
...(options.paymentFlowId && { paymentFlowId: options.paymentFlowId }),
|
|
135
|
-
|
|
148
|
+
...(options.processorId && { processorId: options.processorId }),
|
|
149
|
+
...(options.paymentMethod && { paymentMethod: options.paymentMethod }),
|
|
150
|
+
...(options.isExpress && { isExpress: options.isExpress }),
|
|
151
|
+
};
|
|
152
|
+
console.log('[PaymentsResource] Request body being sent:', JSON.stringify(requestBody, null, 2));
|
|
153
|
+
const response = await this.apiClient.post('/api/public/v1/checkout/pay-v2', requestBody);
|
|
136
154
|
console.log('[PaymentsResource] processPaymentDirect SUCCESS:', response);
|
|
137
155
|
return response;
|
|
138
156
|
}
|
|
@@ -110,6 +110,7 @@ export interface CheckoutSessionState {
|
|
|
110
110
|
selectedVariants: Record<string, string>;
|
|
111
111
|
loadingVariants: Record<string, boolean>;
|
|
112
112
|
isUpdatingSummary: boolean;
|
|
113
|
+
isWhop?: boolean;
|
|
113
114
|
}
|
|
114
115
|
export declare class PostPurchasesResource {
|
|
115
116
|
private apiClient;
|
|
@@ -172,6 +173,22 @@ export declare class PostPurchasesResource {
|
|
|
172
173
|
* Get order summary for a checkout session
|
|
173
174
|
*/
|
|
174
175
|
getOrderSummary(sessionId: string, includeVariantOptions?: boolean): Promise<any>;
|
|
176
|
+
/**
|
|
177
|
+
* Get payment methods for a checkout session
|
|
178
|
+
*/
|
|
179
|
+
getPaymentMethods(checkoutSessionId: string): Promise<{
|
|
180
|
+
type: string;
|
|
181
|
+
}[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Charge a Whop post-purchase using the stored payment method from the original order
|
|
184
|
+
*/
|
|
185
|
+
chargeWhopPostPurchase(params: {
|
|
186
|
+
checkoutSessionId: string;
|
|
187
|
+
orderId: string;
|
|
188
|
+
storeId: string;
|
|
189
|
+
}): Promise<{
|
|
190
|
+
checkoutRequestId: string;
|
|
191
|
+
}>;
|
|
175
192
|
/**
|
|
176
193
|
* Update line items for a checkout session
|
|
177
194
|
*/
|
|
@@ -108,6 +108,26 @@ export class PostPurchasesResource {
|
|
|
108
108
|
includeVariantOptions,
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Get payment methods for a checkout session
|
|
113
|
+
*/
|
|
114
|
+
async getPaymentMethods(checkoutSessionId) {
|
|
115
|
+
return this.apiClient.get(`/api/v1/payment-methods?checkoutSessionId=${encodeURIComponent(checkoutSessionId)}`);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Charge a Whop post-purchase using the stored payment method from the original order
|
|
119
|
+
*/
|
|
120
|
+
async chargeWhopPostPurchase(params) {
|
|
121
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${params.checkoutSessionId}/whop-charge-payment`, {
|
|
122
|
+
checkoutSessionId: params.checkoutSessionId,
|
|
123
|
+
orderId: params.orderId,
|
|
124
|
+
storeId: params.storeId,
|
|
125
|
+
metadata: {
|
|
126
|
+
comingFromPostPurchase: true,
|
|
127
|
+
originalOrderId: params.orderId,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
111
131
|
/**
|
|
112
132
|
* Update line items for a checkout session
|
|
113
133
|
*/
|
package/dist/v2/core/types.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types for the Tagada Pay SDK Core
|
|
3
3
|
*/
|
|
4
|
+
export type DeepPartial<T> = {
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
6
|
+
};
|
|
4
7
|
export type Environment = 'production' | 'development' | 'local';
|
|
5
8
|
export interface ApiConfig {
|
|
6
9
|
baseUrl: string;
|
|
@@ -86,6 +89,40 @@ export interface PickupPoint {
|
|
|
86
89
|
opening_hours?: string;
|
|
87
90
|
extra_info?: string;
|
|
88
91
|
}
|
|
92
|
+
export interface Subscription {
|
|
93
|
+
id: string;
|
|
94
|
+
status: string;
|
|
95
|
+
planName?: string;
|
|
96
|
+
interval?: string;
|
|
97
|
+
intervalCount?: number;
|
|
98
|
+
currentPeriodEnd?: string;
|
|
99
|
+
currentPeriodStart?: string;
|
|
100
|
+
cancelAtPeriodEnd?: boolean;
|
|
101
|
+
trialEnd?: string | null;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|
|
104
|
+
export interface DeviceGeoData {
|
|
105
|
+
city?: string;
|
|
106
|
+
regionName?: string;
|
|
107
|
+
country?: string;
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
export interface DeviceInfo {
|
|
111
|
+
userAgent?: string;
|
|
112
|
+
ip?: string;
|
|
113
|
+
country?: string;
|
|
114
|
+
browser?: string;
|
|
115
|
+
browserVersion?: string;
|
|
116
|
+
os?: string;
|
|
117
|
+
osVersion?: string;
|
|
118
|
+
geoData?: DeviceGeoData;
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}
|
|
121
|
+
export interface PromotionCode {
|
|
122
|
+
id: string;
|
|
123
|
+
code: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
89
126
|
export interface OrderItem {
|
|
90
127
|
id: string;
|
|
91
128
|
productId: string;
|
|
@@ -141,15 +178,16 @@ export interface Order {
|
|
|
141
178
|
paidAmount: number;
|
|
142
179
|
status: string;
|
|
143
180
|
createdAt: string;
|
|
144
|
-
metadata?: Record<string,
|
|
181
|
+
metadata?: Record<string, unknown>;
|
|
145
182
|
items: OrderItem[];
|
|
146
183
|
summaries?: OrderSummary[];
|
|
147
184
|
shippingAddress?: OrderAddress;
|
|
148
185
|
billingAddress?: OrderAddress;
|
|
149
|
-
pickupAddress?: PickupPoint;
|
|
186
|
+
pickupAddress?: PickupPoint | null;
|
|
187
|
+
customer?: Customer;
|
|
150
188
|
checkoutSession?: {
|
|
151
189
|
returnUrl?: string;
|
|
152
|
-
[key: string]:
|
|
190
|
+
[key: string]: unknown;
|
|
153
191
|
};
|
|
154
192
|
relatedOrders?: Order[];
|
|
155
193
|
}
|
|
@@ -161,7 +199,7 @@ export interface PaymentSummary {
|
|
|
161
199
|
createdAt: string;
|
|
162
200
|
updatedAt?: string;
|
|
163
201
|
provider?: string;
|
|
164
|
-
metadata?: Record<string,
|
|
202
|
+
metadata?: Record<string, unknown>;
|
|
165
203
|
}
|
|
166
204
|
export interface PromotionSummary {
|
|
167
205
|
id: string;
|
|
@@ -188,10 +226,10 @@ export interface OrderWithRelations extends Order {
|
|
|
188
226
|
checkoutSession?: {
|
|
189
227
|
id?: string;
|
|
190
228
|
returnUrl?: string;
|
|
191
|
-
[key: string]:
|
|
229
|
+
[key: string]: unknown;
|
|
192
230
|
};
|
|
193
231
|
promotions?: PromotionSummary[];
|
|
194
|
-
subscriptions?:
|
|
232
|
+
subscriptions?: Subscription[];
|
|
195
233
|
adjustments: OrderAdjustmentSummary[];
|
|
196
234
|
}
|
|
197
235
|
export interface CustomerAddress {
|
|
@@ -225,7 +263,7 @@ export interface CustomerOrderSummary {
|
|
|
225
263
|
externalOrderId: string | null;
|
|
226
264
|
billingAddress: CustomerAddress;
|
|
227
265
|
shippingAddress: Omit<CustomerAddress, 'email'>;
|
|
228
|
-
pickupAddress:
|
|
266
|
+
pickupAddress: PickupPoint | null;
|
|
229
267
|
taxesIncluded: boolean;
|
|
230
268
|
draft: boolean;
|
|
231
269
|
checkoutSessionId: string | null;
|
|
@@ -235,7 +273,7 @@ export interface CustomerOrderSummary {
|
|
|
235
273
|
paymentInstrumentId: string | null;
|
|
236
274
|
refundedAt: string | null;
|
|
237
275
|
refundedAmount: number | null;
|
|
238
|
-
metadata?: Record<string,
|
|
276
|
+
metadata?: Record<string, unknown>;
|
|
239
277
|
}
|
|
240
278
|
export interface CustomerInfos {
|
|
241
279
|
customer: {
|
|
@@ -255,12 +293,12 @@ export interface CustomerInfos {
|
|
|
255
293
|
acceptsMarketing: boolean;
|
|
256
294
|
createdAt: string;
|
|
257
295
|
updatedAt: string;
|
|
258
|
-
metadata: Record<string,
|
|
259
|
-
device:
|
|
296
|
+
metadata: Record<string, unknown>;
|
|
297
|
+
device: DeviceInfo | null;
|
|
260
298
|
orders: CustomerOrderSummary[];
|
|
261
|
-
subscriptions:
|
|
299
|
+
subscriptions: Subscription[];
|
|
262
300
|
};
|
|
263
|
-
promotionCodes:
|
|
301
|
+
promotionCodes: PromotionCode[];
|
|
264
302
|
}
|
|
265
303
|
export interface SessionInitResponse {
|
|
266
304
|
store: Store;
|
package/dist/v2/core/types.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Checkout Utility Functions
|
|
3
3
|
* Pure functions for checkout data manipulation
|
|
4
4
|
*/
|
|
5
|
-
import type { CheckoutData,
|
|
6
|
-
export type { CheckoutData,
|
|
5
|
+
import type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, Promotion } from '../resources/checkout';
|
|
6
|
+
export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, Promotion };
|
|
7
7
|
export declare class CheckoutUtils {
|
|
8
8
|
/**
|
|
9
9
|
* Get checkout session ID
|
|
@@ -13,13 +13,18 @@ export class CheckoutUtils {
|
|
|
13
13
|
* Get checkout line items
|
|
14
14
|
*/
|
|
15
15
|
static getLineItems(checkoutData) {
|
|
16
|
-
|
|
16
|
+
const lineItems = checkoutData.checkoutSession?.lineItems;
|
|
17
|
+
if (!Array.isArray(lineItems)) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return lineItems;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Get checkout total
|
|
20
24
|
*/
|
|
21
25
|
static getTotal(checkoutData) {
|
|
22
|
-
|
|
26
|
+
const totalPrice = checkoutData.checkoutSession?.totalPrice;
|
|
27
|
+
return typeof totalPrice === 'number' ? totalPrice : 0;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* Check if customer is club member
|
|
@@ -8,6 +8,20 @@ export interface Currency {
|
|
|
8
8
|
name: string;
|
|
9
9
|
decimalPlaces: number;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Format money amount from minor units (cents) to a formatted string
|
|
13
|
+
*
|
|
14
|
+
* @param amountMinorUnits - Amount in minor units (e.g., 12345 for $123.45)
|
|
15
|
+
* @param currencyCode - ISO 4217 currency code (e.g., "USD", "EUR")
|
|
16
|
+
* @param locale - Locale for formatting (default: "en-US")
|
|
17
|
+
* @returns Formatted money string (e.g., "$123.45")
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* formatMoney(12345, 'USD') // "$123.45"
|
|
21
|
+
* formatMoney(10000, 'EUR', 'de-DE') // "100,00 €"
|
|
22
|
+
* formatMoney(1000, 'JPY') // "¥1,000"
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatMoney(amountMinorUnits: number, currencyCode?: string, locale?: string): string;
|
|
11
25
|
export declare class CurrencyUtils {
|
|
12
26
|
/**
|
|
13
27
|
* Get currency from context or fallback to default
|
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
* Currency Utility Functions
|
|
3
3
|
* Pure functions for currency management
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Format money amount from minor units (cents) to a formatted string
|
|
7
|
+
*
|
|
8
|
+
* @param amountMinorUnits - Amount in minor units (e.g., 12345 for $123.45)
|
|
9
|
+
* @param currencyCode - ISO 4217 currency code (e.g., "USD", "EUR")
|
|
10
|
+
* @param locale - Locale for formatting (default: "en-US")
|
|
11
|
+
* @returns Formatted money string (e.g., "$123.45")
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* formatMoney(12345, 'USD') // "$123.45"
|
|
15
|
+
* formatMoney(10000, 'EUR', 'de-DE') // "100,00 €"
|
|
16
|
+
* formatMoney(1000, 'JPY') // "¥1,000"
|
|
17
|
+
*/
|
|
18
|
+
export function formatMoney(amountMinorUnits, currencyCode = 'USD', locale = 'en-US') {
|
|
19
|
+
const decimalPlaces = CurrencyUtils.getDecimalPlaces(currencyCode);
|
|
20
|
+
// Convert minor units to major units
|
|
21
|
+
// Backend stores amounts with 2 decimal places for all currencies
|
|
22
|
+
// For currencies with 0 decimal places (JPY, KRW, etc.), divide by 100
|
|
23
|
+
let value;
|
|
24
|
+
if (decimalPlaces === 0) {
|
|
25
|
+
// For zero-decimal currencies, backend still stores with 2 decimals
|
|
26
|
+
value = amountMinorUnits / 100;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
value = amountMinorUnits / Math.pow(10, decimalPlaces);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return new Intl.NumberFormat(locale, {
|
|
33
|
+
style: 'currency',
|
|
34
|
+
currency: currencyCode,
|
|
35
|
+
minimumFractionDigits: decimalPlaces,
|
|
36
|
+
maximumFractionDigits: decimalPlaces,
|
|
37
|
+
}).format(value);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Fallback if Intl.NumberFormat fails
|
|
41
|
+
const symbol = CurrencyUtils.getCurrencySymbol(currencyCode);
|
|
42
|
+
return `${symbol}${value.toFixed(decimalPlaces)}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
5
45
|
export class CurrencyUtils {
|
|
6
46
|
/**
|
|
7
47
|
* Get currency from context or fallback to default
|
|
@@ -5,7 +5,6 @@ export interface DeviceInfo {
|
|
|
5
5
|
major: string;
|
|
6
6
|
name: string;
|
|
7
7
|
version: string;
|
|
8
|
-
type?: string;
|
|
9
8
|
};
|
|
10
9
|
os: {
|
|
11
10
|
name: string;
|
|
@@ -36,17 +35,8 @@ export interface DeviceInfo {
|
|
|
36
35
|
isAppleSilicon: boolean;
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Get browser locale
|
|
41
|
-
*/
|
|
42
38
|
export declare function getBrowserLocale(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Collect all device information using UAParser
|
|
45
|
-
*/
|
|
46
39
|
export declare function collectDeviceInfo(): DeviceInfo;
|
|
47
|
-
/**
|
|
48
|
-
* Get URL parameters for session initialization
|
|
49
|
-
*/
|
|
50
40
|
export declare function getUrlParams(): {
|
|
51
41
|
locale?: string;
|
|
52
42
|
currency?: string;
|