@tagadapay/plugin-sdk 2.6.2 → 2.6.6
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/README.md +1090 -623
- package/dist/react/components/GooglePayButton.d.ts +12 -0
- package/dist/react/components/GooglePayButton.js +340 -0
- package/dist/react/components/index.d.ts +3 -2
- package/dist/react/components/index.js +3 -2
- package/dist/react/hooks/useApplePay.js +38 -10
- package/dist/react/hooks/{useExpressPayment.d.ts → useExpressPaymentMethods.d.ts} +13 -10
- package/dist/react/hooks/{useExpressPayment.js → useExpressPaymentMethods.js} +17 -8
- package/dist/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/react/hooks/useGoogleAutocomplete.js +18 -2
- package/dist/react/hooks/useGooglePay.d.ts +22 -0
- package/dist/react/hooks/useGooglePay.js +32 -0
- package/dist/react/index.d.ts +9 -7
- package/dist/react/index.js +8 -5
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/types/apple-pay.d.ts +0 -25
- package/dist/v2/core/googleAutocomplete.d.ts +2 -0
- package/dist/v2/core/googleAutocomplete.js +23 -4
- package/dist/v2/core/resources/checkout.d.ts +70 -2
- package/dist/v2/core/resources/discounts.d.ts +53 -0
- package/dist/v2/core/resources/discounts.js +29 -0
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +56 -0
- package/dist/v2/core/resources/expressPaymentMethods.js +27 -0
- package/dist/v2/core/resources/index.d.ts +7 -4
- package/dist/v2/core/resources/index.js +7 -4
- package/dist/v2/core/resources/shippingRates.d.ts +36 -0
- package/dist/v2/core/resources/shippingRates.js +23 -0
- package/dist/v2/core/resources/vipOffers.d.ts +37 -0
- package/dist/v2/core/resources/vipOffers.js +27 -0
- package/dist/v2/core/utils/order.d.ts +1 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +6 -6
- package/dist/v2/index.d.ts +12 -9
- package/dist/v2/index.js +3 -3
- package/dist/v2/react/components/ApplePayButton.d.ts +141 -0
- package/dist/v2/react/components/ApplePayButton.js +320 -0
- package/dist/v2/react/components/GooglePayButton.d.ts +19 -0
- package/dist/v2/react/components/GooglePayButton.js +355 -0
- package/dist/v2/react/hooks/useApiQuery.d.ts +4 -1
- package/dist/v2/react/hooks/useApiQuery.js +4 -1
- package/dist/v2/react/hooks/useDiscountsQuery.d.ts +30 -0
- package/dist/v2/react/hooks/useDiscountsQuery.js +175 -0
- package/dist/v2/react/hooks/useExpressPaymentMethods.d.ts +12 -0
- package/dist/v2/react/hooks/useExpressPaymentMethods.js +17 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +18 -2
- package/dist/v2/react/hooks/useShippingRatesQuery.d.ts +22 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +134 -0
- package/dist/v2/react/hooks/useVipOffersQuery.d.ts +72 -0
- package/dist/v2/react/hooks/useVipOffersQuery.js +140 -0
- package/dist/v2/react/index.d.ts +30 -17
- package/dist/v2/react/index.js +18 -10
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +59 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +165 -0
- package/dist/v2/react/providers/TagadaProvider.js +5 -5
- package/package.json +90 -90
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
export const useGooglePay = ({ onSuccess, onError, onCancel, checkoutSessionId, customerId, storeName = 'Store', currencyCode = 'USD', merchantId = '12345678901234567890', merchantName = 'Store', }) => {
|
|
3
|
+
const [processingPayment, setProcessingPayment] = useState(false);
|
|
4
|
+
const [googlePayError, setGooglePayError] = useState(null);
|
|
5
|
+
const [isGooglePayAvailable, setIsGooglePayAvailable] = useState(false);
|
|
6
|
+
// Check if Google Pay is available on this device
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window !== 'undefined' && window.google?.payments?.api) {
|
|
9
|
+
setIsGooglePayAvailable(true);
|
|
10
|
+
}
|
|
11
|
+
}, []);
|
|
12
|
+
// The actual implementation will be done by the consumer
|
|
13
|
+
// This hook just provides state management
|
|
14
|
+
const handleGooglePayAuthorized = useCallback((paymentData) => {
|
|
15
|
+
// This will be implemented by the consumer
|
|
16
|
+
return Promise.resolve({ transactionState: 'SUCCESS' });
|
|
17
|
+
}, []);
|
|
18
|
+
const handleGooglePayDataChanged = useCallback((intermediatePaymentData) => {
|
|
19
|
+
// This will be implemented by the consumer
|
|
20
|
+
return Promise.resolve({});
|
|
21
|
+
}, []);
|
|
22
|
+
return {
|
|
23
|
+
handleGooglePayAuthorized,
|
|
24
|
+
handleGooglePayDataChanged,
|
|
25
|
+
processingPayment,
|
|
26
|
+
setProcessingPayment,
|
|
27
|
+
googlePayError,
|
|
28
|
+
setGooglePayError,
|
|
29
|
+
isGooglePayAvailable,
|
|
30
|
+
paymentRequest: null, // Will be provided by consumer
|
|
31
|
+
};
|
|
32
|
+
};
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
export { TagadaProvider } from './providers/TagadaProvider';
|
|
5
5
|
export { useAuth } from './hooks/useAuth';
|
|
6
6
|
export { useCheckout } from './hooks/useCheckout';
|
|
7
|
+
export { useCheckoutSession } from './hooks/useCheckoutSession';
|
|
8
|
+
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
7
9
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
8
10
|
export { useCurrency } from './hooks/useCurrency';
|
|
9
11
|
export { useCustomer } from './hooks/useCustomer';
|
|
@@ -20,8 +22,6 @@ export { useOffers } from './hooks/useOffers';
|
|
|
20
22
|
export { useOrderBump } from './hooks/useOrderBump';
|
|
21
23
|
export { useOrderBumpV2 } from './hooks/useOrderBumpV2';
|
|
22
24
|
export { useOrderBumpV3 } from './hooks/useOrderBumpV3';
|
|
23
|
-
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
24
|
-
export { useCheckoutSession } from './hooks/useCheckoutSession';
|
|
25
25
|
export { usePostPurchases } from './hooks/usePostPurchases';
|
|
26
26
|
export { useProducts } from './hooks/useProducts';
|
|
27
27
|
export { useSession } from './hooks/useSession';
|
|
@@ -32,7 +32,7 @@ export { useVipOffers } from './hooks/useVipOffers';
|
|
|
32
32
|
export { useTagadaContext } from './providers/TagadaProvider';
|
|
33
33
|
export { clearPluginConfigCache, debugPluginConfig, getPluginConfig, useBasePath, usePluginConfig } from './hooks/usePluginConfig';
|
|
34
34
|
export type { PluginConfig } from './hooks/usePluginConfig';
|
|
35
|
-
export { getAvailableLanguages, useCountryOptions, useISOData,
|
|
35
|
+
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
36
36
|
export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
|
|
37
37
|
export type { GeoLocationData, UseGeoLocationOptions, UseGeoLocationReturn } from './hooks/useGeoLocation';
|
|
38
38
|
export type { ExtractedAddress, GoogleAddressComponent, GooglePlaceDetails, GooglePrediction, UseGoogleAutocompleteOptions, UseGoogleAutocompleteResult } from './hooks/useGoogleAutocomplete';
|
|
@@ -43,20 +43,22 @@ export { usePaymentPolling } from './hooks/usePaymentPolling';
|
|
|
43
43
|
export { useThreeds } from './hooks/useThreeds';
|
|
44
44
|
export { useThreedsModal } from './hooks/useThreedsModal';
|
|
45
45
|
export { useApplePay } from './hooks/useApplePay';
|
|
46
|
-
export {
|
|
46
|
+
export { useGooglePay } from './hooks/useGooglePay';
|
|
47
|
+
export { ExpressPaymentMethodsProvider, useExpressPaymentMethods } from './hooks/useExpressPaymentMethods';
|
|
48
|
+
export type { ExpressPaymentMethodsContextType } from './hooks/useExpressPaymentMethods';
|
|
47
49
|
export type { AuthState, Currency, Customer, CustomerInfos, Environment, EnvironmentConfig, Locale, Order, OrderAddress, OrderItem, OrderSummary, PickupPoint, Session, Store } from './types';
|
|
48
50
|
export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, CheckoutSessionPreview, Promotion, UseCheckoutOptions, UseCheckoutResult } from './hooks/useCheckout';
|
|
49
51
|
export type { Discount, DiscountCodeValidation, UseDiscountsOptions, UseDiscountsResult } from './hooks/useDiscounts';
|
|
52
|
+
export type { UseCheckoutSessionOptions, UseCheckoutSessionResult } from './hooks/useCheckoutSession';
|
|
53
|
+
export type { UseCheckoutTokenOptions, UseCheckoutTokenResult } from './hooks/useCheckoutToken';
|
|
50
54
|
export type { OrderBumpPreview, UseOrderBumpOptions, UseOrderBumpResult } from './hooks/useOrderBump';
|
|
51
55
|
export type { UseOrderBumpV2Options, UseOrderBumpV2Result } from './hooks/useOrderBumpV2';
|
|
52
56
|
export type { UseOrderBumpV3Options, UseOrderBumpV3Result } from './hooks/useOrderBumpV3';
|
|
53
|
-
export type { UseCheckoutTokenOptions, UseCheckoutTokenResult } from './hooks/useCheckoutToken';
|
|
54
|
-
export type { UseCheckoutSessionOptions, UseCheckoutSessionResult } from './hooks/useCheckoutSession';
|
|
55
57
|
export type { UseVipOffersOptions, UseVipOffersResult, VipOffer, VipPreviewResponse } from './hooks/useVipOffers';
|
|
56
58
|
export type { PostPurchaseOffer, PostPurchaseOfferItem, PostPurchaseOfferLineItem, PostPurchaseOfferSummary, UsePostPurchasesOptions, UsePostPurchasesResult } from './hooks/usePostPurchases';
|
|
57
59
|
export type { Payment, PaymentPollingHook, PollingOptions } from './hooks/usePaymentPolling';
|
|
58
60
|
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession } from './hooks/useThreeds';
|
|
59
61
|
export type { ApplePayToken, CardPaymentMethod, PaymentHook, PaymentInstrumentResponse, PaymentOptions, PaymentResponse } from './hooks/usePayment';
|
|
60
62
|
export type { ApplePayAddress, ApplePayConfig, ApplePayLineItem, ApplePayPaymentAuthorizedEvent, ApplePayPaymentRequest, ApplePayPaymentToken, ApplePayValidateMerchantEvent, BasisTheorySessionRequest, BasisTheoryTokenizeRequest, PayToken, UseApplePayOptions, UseApplePayResult } from './types/apple-pay';
|
|
61
|
-
export { ApplePayButton, Button } from './components';
|
|
63
|
+
export { ApplePayButton, Button, GooglePayButton } from './components';
|
|
62
64
|
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './utils/money';
|
package/dist/react/index.js
CHANGED
|
@@ -7,6 +7,8 @@ export { TagadaProvider } from './providers/TagadaProvider';
|
|
|
7
7
|
// Hook exports
|
|
8
8
|
export { useAuth } from './hooks/useAuth';
|
|
9
9
|
export { useCheckout } from './hooks/useCheckout';
|
|
10
|
+
export { useCheckoutSession } from './hooks/useCheckoutSession';
|
|
11
|
+
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
10
12
|
export { useClubOffers } from './hooks/useClubOffers';
|
|
11
13
|
export { useCurrency } from './hooks/useCurrency';
|
|
12
14
|
export { useCustomer } from './hooks/useCustomer';
|
|
@@ -23,8 +25,6 @@ export { useOffers } from './hooks/useOffers';
|
|
|
23
25
|
export { useOrderBump } from './hooks/useOrderBump';
|
|
24
26
|
export { useOrderBumpV2 } from './hooks/useOrderBumpV2';
|
|
25
27
|
export { useOrderBumpV3 } from './hooks/useOrderBumpV3';
|
|
26
|
-
export { useCheckoutToken } from './hooks/useCheckoutToken';
|
|
27
|
-
export { useCheckoutSession } from './hooks/useCheckoutSession';
|
|
28
28
|
export { usePostPurchases } from './hooks/usePostPurchases';
|
|
29
29
|
export { useProducts } from './hooks/useProducts';
|
|
30
30
|
export { useSession } from './hooks/useSession';
|
|
@@ -35,7 +35,7 @@ export { useTagadaContext } from './providers/TagadaProvider';
|
|
|
35
35
|
// Plugin configuration hooks
|
|
36
36
|
export { clearPluginConfigCache, debugPluginConfig, getPluginConfig, useBasePath, usePluginConfig } from './hooks/usePluginConfig';
|
|
37
37
|
// ISO Data hooks
|
|
38
|
-
export { getAvailableLanguages, useCountryOptions, useISOData,
|
|
38
|
+
export { getAvailableLanguages, useCountryOptions, useISOData, useLanguageImport, useRegionOptions } from './hooks/useISOData';
|
|
39
39
|
// Order hook exports
|
|
40
40
|
export { useOrder } from './hooks/useOrder';
|
|
41
41
|
// Payment hooks exports
|
|
@@ -45,9 +45,12 @@ export { useThreeds } from './hooks/useThreeds';
|
|
|
45
45
|
export { useThreedsModal } from './hooks/useThreedsModal';
|
|
46
46
|
// Apple Pay hooks exports
|
|
47
47
|
export { useApplePay } from './hooks/useApplePay';
|
|
48
|
+
// Google Pay hooks exports
|
|
49
|
+
export { useGooglePay } from './hooks/useGooglePay';
|
|
48
50
|
// Express Payment context exports
|
|
49
|
-
|
|
51
|
+
// Express Payment Methods (extended functionality)
|
|
52
|
+
export { ExpressPaymentMethodsProvider, useExpressPaymentMethods } from './hooks/useExpressPaymentMethods';
|
|
50
53
|
// Component exports
|
|
51
|
-
export { ApplePayButton, Button } from './components';
|
|
54
|
+
export { ApplePayButton, Button, GooglePayButton } from './components';
|
|
52
55
|
// Utility exports
|
|
53
56
|
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from './utils/money';
|
|
@@ -38,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
38
38
|
borderTop: '1.5px solid #9ca3af',
|
|
39
39
|
borderRadius: '50%',
|
|
40
40
|
animation: 'tagada-spin 1s linear infinite',
|
|
41
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
-
@keyframes tagada-spin {
|
|
43
|
-
0% { transform: rotate(0deg); }
|
|
44
|
-
100% { transform: rotate(360deg); }
|
|
45
|
-
}
|
|
41
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
+
@keyframes tagada-spin {
|
|
43
|
+
0% { transform: rotate(0deg); }
|
|
44
|
+
100% { transform: rotate(360deg); }
|
|
45
|
+
}
|
|
46
46
|
` })] }));
|
|
47
47
|
const TagadaContext = createContext(null);
|
|
48
48
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
|
|
@@ -91,28 +91,3 @@ export interface UseApplePayResult {
|
|
|
91
91
|
updateCustomerEmail: (email: string) => Promise<void>;
|
|
92
92
|
setShippingRate: (shippingRateId: string) => Promise<void>;
|
|
93
93
|
}
|
|
94
|
-
declare global {
|
|
95
|
-
interface Window {
|
|
96
|
-
ApplePaySession: typeof ApplePaySession;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
declare class ApplePaySession {
|
|
100
|
-
static STATUS_SUCCESS: number;
|
|
101
|
-
static STATUS_FAILURE: number;
|
|
102
|
-
static canMakePayments(): boolean;
|
|
103
|
-
static canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise<boolean>;
|
|
104
|
-
constructor(version: number, request: ApplePayPaymentRequest);
|
|
105
|
-
begin(): void;
|
|
106
|
-
abort(): void;
|
|
107
|
-
onerror: ((event: any) => void) | null;
|
|
108
|
-
completeMerchantValidation(merchantSession: any): void;
|
|
109
|
-
completeShippingContactSelection(status: number, shippingMethods: any[], total: any, lineItems: any[]): void;
|
|
110
|
-
completeShippingMethodSelection(status: number, total: any, lineItems: any[]): void;
|
|
111
|
-
completePayment(status: number): void;
|
|
112
|
-
onvalidatemerchant: ((event: ApplePayValidateMerchantEvent) => void) | null;
|
|
113
|
-
onpaymentauthorized: ((event: ApplePayPaymentAuthorizedEvent) => void) | null;
|
|
114
|
-
oncancel: (() => void) | null;
|
|
115
|
-
onshippingmethodselected: ((event: any) => void) | null;
|
|
116
|
-
onshippingcontactselected: ((event: any) => void) | null;
|
|
117
|
-
}
|
|
118
|
-
export {};
|
|
@@ -36,6 +36,8 @@ export interface AddressComponents {
|
|
|
36
36
|
locality?: string;
|
|
37
37
|
administrativeAreaLevel1?: string;
|
|
38
38
|
administrativeAreaLevel1Long?: string;
|
|
39
|
+
administrativeAreaLevel2?: string;
|
|
40
|
+
administrativeAreaLevel2Long?: string;
|
|
39
41
|
iso?: string;
|
|
40
42
|
}
|
|
41
43
|
export declare class GoogleAutocompleteCore {
|
|
@@ -8,7 +8,7 @@ export class GoogleAutocompleteCore {
|
|
|
8
8
|
*/
|
|
9
9
|
static initialize(apiKey) {
|
|
10
10
|
this.apiKey = apiKey;
|
|
11
|
-
if (typeof window !== 'undefined' && window.google) {
|
|
11
|
+
if (typeof window !== 'undefined' && window.google?.maps?.places) {
|
|
12
12
|
this.service = new window.google.maps.places.AutocompleteService();
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -25,7 +25,7 @@ export class GoogleAutocompleteCore {
|
|
|
25
25
|
types: options.types || ['address'],
|
|
26
26
|
componentRestrictions: options.componentRestrictions,
|
|
27
27
|
}, (predictions, status) => {
|
|
28
|
-
if (status === window.google
|
|
28
|
+
if (status === window.google?.maps?.places?.PlacesServiceStatus.OK && predictions) {
|
|
29
29
|
resolve(predictions);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
@@ -38,7 +38,7 @@ export class GoogleAutocompleteCore {
|
|
|
38
38
|
* Get place details
|
|
39
39
|
*/
|
|
40
40
|
static async getPlaceDetails(placeId) {
|
|
41
|
-
if (typeof window === 'undefined' || !window.google) {
|
|
41
|
+
if (typeof window === 'undefined' || !window.google?.maps?.places) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
return new Promise((resolve, reject) => {
|
|
@@ -47,7 +47,7 @@ export class GoogleAutocompleteCore {
|
|
|
47
47
|
placeId,
|
|
48
48
|
fields: ['place_id', 'formatted_address', 'address_components', 'geometry'],
|
|
49
49
|
}, (place, status) => {
|
|
50
|
-
if (status === window.google
|
|
50
|
+
if (status === window.google?.maps?.places?.PlacesServiceStatus.OK && place) {
|
|
51
51
|
resolve(place);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -73,6 +73,15 @@ export class GoogleAutocompleteCore {
|
|
|
73
73
|
components.city = component.long_name;
|
|
74
74
|
components.locality = component.long_name;
|
|
75
75
|
}
|
|
76
|
+
else if (types.includes('administrative_area_level_2')) {
|
|
77
|
+
components.administrativeAreaLevel2 = component.short_name;
|
|
78
|
+
components.administrativeAreaLevel2Long = component.long_name;
|
|
79
|
+
// Use level_2 as fallback for city if city is not set
|
|
80
|
+
if (!components.city) {
|
|
81
|
+
components.city = component.long_name;
|
|
82
|
+
components.locality = component.long_name;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
76
85
|
else if (types.includes('administrative_area_level_1')) {
|
|
77
86
|
components.state = component.long_name;
|
|
78
87
|
components.administrativeAreaLevel1 = component.short_name;
|
|
@@ -87,6 +96,16 @@ export class GoogleAutocompleteCore {
|
|
|
87
96
|
components.iso = component.short_name;
|
|
88
97
|
}
|
|
89
98
|
}
|
|
99
|
+
// For countries like France where administrative_area_level_1 (région) may be missing,
|
|
100
|
+
// use administrative_area_level_2 (département) as the primary state/province value
|
|
101
|
+
// We prefer the long_name (e.g., "Bouches-du-Rhône") over short_name (e.g., "13")
|
|
102
|
+
// because it's more likely to match our state database entries
|
|
103
|
+
if (!components.administrativeAreaLevel1 && components.administrativeAreaLevel2) {
|
|
104
|
+
// Use long name as the primary state value (e.g., "Bouches-du-Rhône" instead of "13")
|
|
105
|
+
components.state = components.administrativeAreaLevel2Long || components.administrativeAreaLevel2;
|
|
106
|
+
components.administrativeAreaLevel1 = components.administrativeAreaLevel2;
|
|
107
|
+
components.administrativeAreaLevel1Long = components.administrativeAreaLevel2Long;
|
|
108
|
+
}
|
|
90
109
|
return components;
|
|
91
110
|
}
|
|
92
111
|
}
|
|
@@ -40,12 +40,80 @@ export interface CheckoutSession {
|
|
|
40
40
|
selectedPresentmentCurrency: string;
|
|
41
41
|
[key: string]: any;
|
|
42
42
|
}
|
|
43
|
+
export interface CheckoutSummaryItem {
|
|
44
|
+
id: string;
|
|
45
|
+
productId: string;
|
|
46
|
+
variantId: string;
|
|
47
|
+
priceId: string;
|
|
48
|
+
product: {
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
variant: {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
imageUrl: string;
|
|
56
|
+
grams: number;
|
|
57
|
+
};
|
|
58
|
+
sku: string;
|
|
59
|
+
unitAmount: number;
|
|
60
|
+
quantity: number;
|
|
61
|
+
amount: number;
|
|
62
|
+
adjustedAmount: number;
|
|
63
|
+
currency: string;
|
|
64
|
+
adjustments: any[];
|
|
65
|
+
recurring: boolean;
|
|
66
|
+
interval?: 'day' | 'week' | 'month' | 'year';
|
|
67
|
+
intervalCount?: number;
|
|
68
|
+
totalBillingCycles?: number;
|
|
69
|
+
unitAmountAfterFirstCycle?: number;
|
|
70
|
+
orderLineItemProduct: {
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
orderLineItemVariant: {
|
|
74
|
+
name: string;
|
|
75
|
+
imageUrl: string;
|
|
76
|
+
};
|
|
77
|
+
metadata: {
|
|
78
|
+
originalIds: string[];
|
|
79
|
+
isConsolidated: boolean;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface CheckoutSummary {
|
|
83
|
+
currency: string;
|
|
84
|
+
items: CheckoutSummaryItem[];
|
|
85
|
+
subtotalAmount: number;
|
|
86
|
+
subtotalAdjustedAmount: number;
|
|
87
|
+
shippingCost: number;
|
|
88
|
+
shippingCostIsFree: boolean;
|
|
89
|
+
totalAmount: number;
|
|
90
|
+
totalAdjustedAmount: number;
|
|
91
|
+
totalPromotionAmount: number;
|
|
92
|
+
totalTaxAmount: number;
|
|
93
|
+
lineItemsPromotionAmount: number;
|
|
94
|
+
lineItemsTaxAmount: number;
|
|
95
|
+
totalWeight: number;
|
|
96
|
+
_consolidated: boolean;
|
|
97
|
+
adjustments: {
|
|
98
|
+
type: string;
|
|
99
|
+
description: string;
|
|
100
|
+
amount: number;
|
|
101
|
+
}[];
|
|
102
|
+
}
|
|
103
|
+
export interface Promotion {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
description: string | null;
|
|
107
|
+
type: string;
|
|
108
|
+
rules: any[];
|
|
109
|
+
actions: any[];
|
|
110
|
+
}
|
|
43
111
|
export interface CheckoutData {
|
|
44
112
|
checkoutSession: CheckoutSession;
|
|
45
113
|
customerIsClubMember: boolean;
|
|
46
114
|
clubProductId?: string;
|
|
47
|
-
summary:
|
|
48
|
-
availablePromotions:
|
|
115
|
+
summary: CheckoutSummary;
|
|
116
|
+
availablePromotions: Promotion[];
|
|
49
117
|
}
|
|
50
118
|
export interface Promotion {
|
|
51
119
|
id: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discounts Resource Client
|
|
3
|
+
* Axios-based API client for discount/promotion code endpoints
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
export interface Discount {
|
|
7
|
+
id: string;
|
|
8
|
+
promotionId: string;
|
|
9
|
+
promotionCodeId: string | null;
|
|
10
|
+
appliedAt: string;
|
|
11
|
+
appliedManually: boolean;
|
|
12
|
+
promotion: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface DiscountCodeValidation {
|
|
18
|
+
isValid: boolean;
|
|
19
|
+
code: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
discount?: {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
value: number;
|
|
26
|
+
currency: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface ApplyDiscountResponse {
|
|
30
|
+
success: boolean;
|
|
31
|
+
error?: any;
|
|
32
|
+
promotion?: Discount;
|
|
33
|
+
}
|
|
34
|
+
export interface RemoveDiscountResponse {
|
|
35
|
+
success: boolean;
|
|
36
|
+
error?: any;
|
|
37
|
+
}
|
|
38
|
+
export declare class DiscountsResource {
|
|
39
|
+
private apiClient;
|
|
40
|
+
constructor(apiClient: ApiClient);
|
|
41
|
+
/**
|
|
42
|
+
* Get applied discounts for a checkout session
|
|
43
|
+
*/
|
|
44
|
+
getAppliedDiscounts(sessionId: string): Promise<Discount[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Apply a discount code to a checkout session
|
|
47
|
+
*/
|
|
48
|
+
applyDiscountCode(sessionId: string, code: string): Promise<ApplyDiscountResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Remove a discount from a checkout session
|
|
51
|
+
*/
|
|
52
|
+
removeDiscount(sessionId: string, discountId: string): Promise<RemoveDiscountResponse>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discounts Resource Client
|
|
3
|
+
* Axios-based API client for discount/promotion code endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class DiscountsResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get applied discounts for a checkout session
|
|
11
|
+
*/
|
|
12
|
+
async getAppliedDiscounts(sessionId) {
|
|
13
|
+
return this.apiClient.get(`/api/v1/checkout-sessions/${sessionId}/promotions`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply a discount code to a checkout session
|
|
17
|
+
*/
|
|
18
|
+
async applyDiscountCode(sessionId, code) {
|
|
19
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${sessionId}/promotions/apply`, {
|
|
20
|
+
code: code.trim(),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Remove a discount from a checkout session
|
|
25
|
+
*/
|
|
26
|
+
async removeDiscount(sessionId, discountId) {
|
|
27
|
+
return this.apiClient.delete(`/api/v1/checkout-sessions/${sessionId}/promotions/${discountId}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express Payment Methods Resource Client
|
|
3
|
+
* Axios-based API client for express payment methods
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
export interface PaymentMethod {
|
|
7
|
+
id: string;
|
|
8
|
+
type: string;
|
|
9
|
+
title: string;
|
|
10
|
+
iconUrl: string;
|
|
11
|
+
default: boolean;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface Address {
|
|
15
|
+
address1: string;
|
|
16
|
+
address2?: string;
|
|
17
|
+
lastName?: string;
|
|
18
|
+
firstName?: string;
|
|
19
|
+
city?: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
country?: string;
|
|
22
|
+
postal?: string;
|
|
23
|
+
phone?: string;
|
|
24
|
+
email?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UpdateAddressRequest {
|
|
27
|
+
data: {
|
|
28
|
+
shippingAddress: Address;
|
|
29
|
+
billingAddress?: Address | null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateCustomerEmailRequest {
|
|
33
|
+
data: {
|
|
34
|
+
email: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare class ExpressPaymentMethodsResource {
|
|
38
|
+
private apiClient;
|
|
39
|
+
constructor(apiClient: ApiClient);
|
|
40
|
+
/**
|
|
41
|
+
* Get enabled payment methods for a checkout session
|
|
42
|
+
*/
|
|
43
|
+
getPaymentMethods(sessionId: string): Promise<PaymentMethod[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Update checkout session address (for express checkout flows)
|
|
46
|
+
*/
|
|
47
|
+
updateCheckoutSessionAddress(sessionId: string, data: UpdateAddressRequest): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Update customer email
|
|
52
|
+
*/
|
|
53
|
+
updateCustomerEmail(customerId: string, data: UpdateCustomerEmailRequest): Promise<{
|
|
54
|
+
success: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express Payment Methods Resource Client
|
|
3
|
+
* Axios-based API client for express payment methods
|
|
4
|
+
*/
|
|
5
|
+
export class ExpressPaymentMethodsResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get enabled payment methods for a checkout session
|
|
11
|
+
*/
|
|
12
|
+
async getPaymentMethods(sessionId) {
|
|
13
|
+
return this.apiClient.get(`/api/v1/payment-methods?checkoutSessionId=${encodeURIComponent(sessionId)}`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Update checkout session address (for express checkout flows)
|
|
17
|
+
*/
|
|
18
|
+
async updateCheckoutSessionAddress(sessionId, data) {
|
|
19
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${sessionId}/address`, data);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Update customer email
|
|
23
|
+
*/
|
|
24
|
+
async updateCustomerEmail(customerId, data) {
|
|
25
|
+
return this.apiClient.post(`/api/v1/customers/${customerId}`, data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
* Axios-based API clients for all endpoints
|
|
4
4
|
*/
|
|
5
5
|
export * from './apiClient';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './checkout';
|
|
7
|
+
export * from './discounts';
|
|
8
|
+
export * from './offers';
|
|
7
9
|
export * from './orders';
|
|
8
10
|
export * from './payments';
|
|
9
|
-
export * from './checkout';
|
|
10
|
-
export * from './promotions';
|
|
11
11
|
export * from './postPurchases';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './products';
|
|
13
|
+
export * from './promotions';
|
|
14
|
+
export * from './shippingRates';
|
|
13
15
|
export * from './threeds';
|
|
16
|
+
export * from './vipOffers';
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
* Axios-based API clients for all endpoints
|
|
4
4
|
*/
|
|
5
5
|
export * from './apiClient';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './checkout';
|
|
7
|
+
export * from './discounts';
|
|
8
|
+
export * from './offers';
|
|
7
9
|
export * from './orders';
|
|
8
10
|
export * from './payments';
|
|
9
|
-
export * from './checkout';
|
|
10
|
-
export * from './promotions';
|
|
11
11
|
export * from './postPurchases';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './products';
|
|
13
|
+
export * from './promotions';
|
|
14
|
+
export * from './shippingRates';
|
|
13
15
|
export * from './threeds';
|
|
16
|
+
export * from './vipOffers';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shipping Rates Resource Client
|
|
3
|
+
* Axios-based API client for shipping rates endpoints
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
export interface ShippingRate {
|
|
7
|
+
id: string;
|
|
8
|
+
shippingRateName: string;
|
|
9
|
+
amount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
isFree: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
highlighted?: boolean;
|
|
14
|
+
icon?: string;
|
|
15
|
+
isPickupPoint?: boolean;
|
|
16
|
+
pickupPointCarriers?: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface ShippingRatesResponse {
|
|
19
|
+
rates: ShippingRate[];
|
|
20
|
+
forceCheckoutSessionRefetch?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class ShippingRatesResource {
|
|
23
|
+
private apiClient;
|
|
24
|
+
constructor(apiClient: ApiClient);
|
|
25
|
+
/**
|
|
26
|
+
* Get shipping rates for a checkout session
|
|
27
|
+
*/
|
|
28
|
+
getShippingRates(sessionId: string): Promise<ShippingRatesResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Set selected shipping rate for a checkout session
|
|
31
|
+
*/
|
|
32
|
+
setShippingRate(sessionId: string, shippingRateId: string): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
error?: any;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shipping Rates Resource Client
|
|
3
|
+
* Axios-based API client for shipping rates endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class ShippingRatesResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get shipping rates for a checkout session
|
|
11
|
+
*/
|
|
12
|
+
async getShippingRates(sessionId) {
|
|
13
|
+
return this.apiClient.get(`/api/v1/checkout-sessions/${sessionId}/shipping-rates`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Set selected shipping rate for a checkout session
|
|
17
|
+
*/
|
|
18
|
+
async setShippingRate(sessionId, shippingRateId) {
|
|
19
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${sessionId}/shipping-rate`, {
|
|
20
|
+
shippingRateId,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIP Offers Resource Client
|
|
3
|
+
* Axios-based API client for VIP offer endpoints
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
export interface VipOffer {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
variantId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface VipPreviewResponse {
|
|
12
|
+
savings: number;
|
|
13
|
+
currency: string;
|
|
14
|
+
selectedOffers: {
|
|
15
|
+
productId: string;
|
|
16
|
+
variantId: string;
|
|
17
|
+
isSelected: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
savingsPct: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ToggleOrderBumpResponse {
|
|
22
|
+
success: boolean;
|
|
23
|
+
summary: any;
|
|
24
|
+
availablePromotions: any[];
|
|
25
|
+
}
|
|
26
|
+
export declare class VipOffersResource {
|
|
27
|
+
private apiClient;
|
|
28
|
+
constructor(apiClient: ApiClient);
|
|
29
|
+
/**
|
|
30
|
+
* Get VIP preview showing potential savings
|
|
31
|
+
*/
|
|
32
|
+
getVipPreview(sessionId: string, vipOfferIds: string[]): Promise<VipPreviewResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Toggle an order bump (used for VIP offers)
|
|
35
|
+
*/
|
|
36
|
+
toggleOrderBump(sessionId: string, orderBumpOfferId: string, selected: boolean): Promise<ToggleOrderBumpResponse>;
|
|
37
|
+
}
|