@tagadapay/plugin-sdk 1.0.2
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 +475 -0
- package/dist/data/currencies.json +2410 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +37 -0
- package/dist/react/components/DebugDrawer.d.ts +7 -0
- package/dist/react/components/DebugDrawer.js +368 -0
- package/dist/react/components/OffersDemo.d.ts +1 -0
- package/dist/react/components/OffersDemo.js +50 -0
- package/dist/react/components/index.d.ts +1 -0
- package/dist/react/components/index.js +1 -0
- package/dist/react/config/environment.d.ts +22 -0
- package/dist/react/config/environment.js +132 -0
- package/dist/react/config/payment.d.ts +23 -0
- package/dist/react/config/payment.js +52 -0
- package/dist/react/hooks/useAuth.d.ts +4 -0
- package/dist/react/hooks/useAuth.js +12 -0
- package/dist/react/hooks/useCheckout.d.ts +262 -0
- package/dist/react/hooks/useCheckout.js +325 -0
- package/dist/react/hooks/useCurrency.d.ts +4 -0
- package/dist/react/hooks/useCurrency.js +640 -0
- package/dist/react/hooks/useCustomer.d.ts +7 -0
- package/dist/react/hooks/useCustomer.js +14 -0
- package/dist/react/hooks/useEnvironment.d.ts +7 -0
- package/dist/react/hooks/useEnvironment.js +18 -0
- package/dist/react/hooks/useLocale.d.ts +2 -0
- package/dist/react/hooks/useLocale.js +43 -0
- package/dist/react/hooks/useOffers.d.ts +99 -0
- package/dist/react/hooks/useOffers.js +115 -0
- package/dist/react/hooks/useOrder.d.ts +44 -0
- package/dist/react/hooks/useOrder.js +77 -0
- package/dist/react/hooks/usePayment.d.ts +60 -0
- package/dist/react/hooks/usePayment.js +343 -0
- package/dist/react/hooks/usePaymentPolling.d.ts +45 -0
- package/dist/react/hooks/usePaymentPolling.js +146 -0
- package/dist/react/hooks/useProducts.d.ts +95 -0
- package/dist/react/hooks/useProducts.js +120 -0
- package/dist/react/hooks/useSession.d.ts +10 -0
- package/dist/react/hooks/useSession.js +17 -0
- package/dist/react/hooks/useThreeds.d.ts +38 -0
- package/dist/react/hooks/useThreeds.js +162 -0
- package/dist/react/hooks/useThreedsModal.d.ts +16 -0
- package/dist/react/hooks/useThreedsModal.js +328 -0
- package/dist/react/index.d.ts +26 -0
- package/dist/react/index.js +27 -0
- package/dist/react/providers/TagadaProvider.d.ts +55 -0
- package/dist/react/providers/TagadaProvider.js +471 -0
- package/dist/react/services/apiService.d.ts +149 -0
- package/dist/react/services/apiService.js +168 -0
- package/dist/react/types.d.ts +151 -0
- package/dist/react/types.js +4 -0
- package/dist/react/utils/__tests__/urlUtils.test.d.ts +1 -0
- package/dist/react/utils/__tests__/urlUtils.test.js +189 -0
- package/dist/react/utils/deviceInfo.d.ts +39 -0
- package/dist/react/utils/deviceInfo.js +163 -0
- package/dist/react/utils/jwtDecoder.d.ts +14 -0
- package/dist/react/utils/jwtDecoder.js +86 -0
- package/dist/react/utils/money.d.ts +2273 -0
- package/dist/react/utils/money.js +104 -0
- package/dist/react/utils/tokenStorage.d.ts +16 -0
- package/dist/react/utils/tokenStorage.js +52 -0
- package/dist/react/utils/urlUtils.d.ts +239 -0
- package/dist/react/utils/urlUtils.js +449 -0
- package/package.json +64 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* Environment configurations for different deployment environments
|
|
4
|
+
*/
|
|
5
|
+
export const ENVIRONMENT_CONFIGS = {
|
|
6
|
+
production: {
|
|
7
|
+
baseUrl: 'https://app.tagadapay.com',
|
|
8
|
+
endpoints: {
|
|
9
|
+
checkout: {
|
|
10
|
+
sessionInit: '/api/v1/checkout/session/init',
|
|
11
|
+
sessionStatus: '/api/v1/checkout/session/status',
|
|
12
|
+
},
|
|
13
|
+
customer: {
|
|
14
|
+
profile: '/api/v1/customer/profile',
|
|
15
|
+
session: '/api/v1/customer/session',
|
|
16
|
+
},
|
|
17
|
+
store: {
|
|
18
|
+
config: '/api/v1/store/config',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
development: {
|
|
23
|
+
baseUrl: 'https://app.tagadapay.dev',
|
|
24
|
+
endpoints: {
|
|
25
|
+
checkout: {
|
|
26
|
+
sessionInit: '/api/v1/checkout/session/init',
|
|
27
|
+
sessionStatus: '/api/v1/checkout/session/status',
|
|
28
|
+
},
|
|
29
|
+
customer: {
|
|
30
|
+
profile: '/api/v1/customer/profile',
|
|
31
|
+
session: '/api/v1/customer/session',
|
|
32
|
+
},
|
|
33
|
+
store: {
|
|
34
|
+
config: '/api/v1/store/config',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
local: {
|
|
39
|
+
baseUrl: 'http://app.localhost:3000',
|
|
40
|
+
endpoints: {
|
|
41
|
+
checkout: {
|
|
42
|
+
sessionInit: '/api/v1/checkout/session/init',
|
|
43
|
+
sessionStatus: '/api/v1/checkout/session/status',
|
|
44
|
+
},
|
|
45
|
+
customer: {
|
|
46
|
+
profile: '/api/v1/customer/profile',
|
|
47
|
+
session: '/api/v1/customer/session',
|
|
48
|
+
},
|
|
49
|
+
store: {
|
|
50
|
+
config: '/api/v1/store/config',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Get the environment configuration based on the current environment
|
|
57
|
+
*/
|
|
58
|
+
export function getEnvironmentConfig(environment = 'local') {
|
|
59
|
+
const apiConfig = ENVIRONMENT_CONFIGS[environment];
|
|
60
|
+
if (!apiConfig) {
|
|
61
|
+
console.warn(`Unknown environment: ${environment}. Falling back to local.`);
|
|
62
|
+
return {
|
|
63
|
+
environment: 'local',
|
|
64
|
+
apiConfig: ENVIRONMENT_CONFIGS.local,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
environment,
|
|
69
|
+
apiConfig,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build a complete API URL from environment config and endpoint path
|
|
74
|
+
*/
|
|
75
|
+
export function buildApiUrl(config, endpointPath) {
|
|
76
|
+
return `${config.apiConfig.baseUrl}${endpointPath}`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a specific endpoint URL
|
|
80
|
+
*/
|
|
81
|
+
export function getEndpointUrl(config, category, endpoint) {
|
|
82
|
+
const categoryEndpoints = config.apiConfig.endpoints[category];
|
|
83
|
+
const endpointPath = categoryEndpoints[endpoint];
|
|
84
|
+
if (!endpointPath) {
|
|
85
|
+
throw new Error(`Endpoint not found: ${category}.${endpoint}`);
|
|
86
|
+
}
|
|
87
|
+
return buildApiUrl(config, endpointPath);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Auto-detect environment based on hostname, URL patterns, and deployment context
|
|
91
|
+
* Works with any build tool or deployment system
|
|
92
|
+
*/
|
|
93
|
+
export function detectEnvironment() {
|
|
94
|
+
// Check if we're in browser
|
|
95
|
+
if (typeof window === 'undefined') {
|
|
96
|
+
return 'local'; // SSR fallback
|
|
97
|
+
}
|
|
98
|
+
const hostname = window.location.hostname;
|
|
99
|
+
const href = window.location.href;
|
|
100
|
+
// Production: deployed to production domains
|
|
101
|
+
if (hostname === 'app.tagadapay.com' ||
|
|
102
|
+
hostname.includes('tagadapay.com') ||
|
|
103
|
+
hostname.includes('yourproductiondomain.com')) {
|
|
104
|
+
return 'production';
|
|
105
|
+
}
|
|
106
|
+
// Development: deployed to staging/dev domains or has dev indicators
|
|
107
|
+
if (hostname === 'app.tagadapay.dev' ||
|
|
108
|
+
hostname.includes('tagadapay.dev') || // ✅ app.tagadapay.dev and subdomains
|
|
109
|
+
hostname.includes('vercel.app') ||
|
|
110
|
+
hostname.includes('netlify.app') ||
|
|
111
|
+
hostname.includes('surge.sh') ||
|
|
112
|
+
hostname.includes('github.io') ||
|
|
113
|
+
hostname.includes('herokuapp.com') ||
|
|
114
|
+
hostname.includes('railway.app') ||
|
|
115
|
+
href.includes('?env=dev') ||
|
|
116
|
+
href.includes('?dev=true') ||
|
|
117
|
+
href.includes('#dev')) {
|
|
118
|
+
return 'development';
|
|
119
|
+
}
|
|
120
|
+
// Local: localhost, local IPs, or local domains
|
|
121
|
+
if (hostname === 'localhost' ||
|
|
122
|
+
hostname.startsWith('127.') ||
|
|
123
|
+
hostname.startsWith('192.168.') ||
|
|
124
|
+
hostname.startsWith('10.') ||
|
|
125
|
+
hostname.includes('.local') ||
|
|
126
|
+
hostname === '' ||
|
|
127
|
+
hostname === '0.0.0.0') {
|
|
128
|
+
return 'local';
|
|
129
|
+
}
|
|
130
|
+
// Default fallback for unknown domains (safer to use development)
|
|
131
|
+
return 'development';
|
|
132
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment processor configuration for TagadaPay SDK
|
|
3
|
+
* These are public API keys - safe to embed in client-side code
|
|
4
|
+
*/
|
|
5
|
+
export interface PaymentConfig {
|
|
6
|
+
basisTheory: {
|
|
7
|
+
publicApiKey: string;
|
|
8
|
+
environment: 'sandbox' | 'production';
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Payment configurations for different environments
|
|
13
|
+
*/
|
|
14
|
+
export declare const PAYMENT_CONFIGS: Record<string, PaymentConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Get payment configuration based on environment
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPaymentConfig(environment?: string): PaymentConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Get BasisTheory API key for current environment
|
|
21
|
+
* Falls back to environment variable if available
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBasisTheoryApiKey(environment?: string): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment processor configuration for TagadaPay SDK
|
|
3
|
+
* These are public API keys - safe to embed in client-side code
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Payment configurations for different environments
|
|
7
|
+
*/
|
|
8
|
+
export const PAYMENT_CONFIGS = {
|
|
9
|
+
production: {
|
|
10
|
+
basisTheory: {
|
|
11
|
+
// TODO: Replace with actual production BasisTheory public API key
|
|
12
|
+
publicApiKey: 'key_prod_us_pub_PNMB2AiaECJ463K6QAPNU6',
|
|
13
|
+
environment: 'production',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
development: {
|
|
17
|
+
basisTheory: {
|
|
18
|
+
// TODO: Replace with actual development BasisTheory public API key
|
|
19
|
+
publicApiKey: 'key_test_us_pub_VExdfbFQARn821iqP8zNaq',
|
|
20
|
+
environment: 'sandbox',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
local: {
|
|
24
|
+
basisTheory: {
|
|
25
|
+
// Development/testing API key (sandbox)
|
|
26
|
+
publicApiKey: 'key_test_us_pub_VExdfbFQARn821iqP8zNaq',
|
|
27
|
+
environment: 'sandbox',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Get payment configuration based on environment
|
|
33
|
+
*/
|
|
34
|
+
export function getPaymentConfig(environment = 'local') {
|
|
35
|
+
return PAYMENT_CONFIGS[environment] || PAYMENT_CONFIGS.local;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get BasisTheory API key for current environment
|
|
39
|
+
* Falls back to environment variable if available
|
|
40
|
+
*/
|
|
41
|
+
export function getBasisTheoryApiKey(environment = 'local') {
|
|
42
|
+
// Check environment variable first (allows override)
|
|
43
|
+
if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_BASIS_THEORY_PUBLIC_API_KEY) {
|
|
44
|
+
return process.env.NEXT_PUBLIC_BASIS_THEORY_PUBLIC_API_KEY;
|
|
45
|
+
}
|
|
46
|
+
if (typeof process !== 'undefined' && process.env?.VITE_BASIS_THEORY_PUBLIC_API_KEY) {
|
|
47
|
+
return process.env.VITE_BASIS_THEORY_PUBLIC_API_KEY;
|
|
48
|
+
}
|
|
49
|
+
// Fall back to embedded configuration
|
|
50
|
+
const config = getPaymentConfig(environment);
|
|
51
|
+
return config.basisTheory.publicApiKey;
|
|
52
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* useAuth - Hook to access authentication state
|
|
4
|
+
*/
|
|
5
|
+
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
6
|
+
export function useAuth() {
|
|
7
|
+
const { auth, isInitialized } = useTagadaContext();
|
|
8
|
+
return {
|
|
9
|
+
...auth,
|
|
10
|
+
isInitialized,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
export interface CheckoutLineItem {
|
|
2
|
+
externalProductId?: string | null;
|
|
3
|
+
externalVariantId?: string | null;
|
|
4
|
+
variantId?: string | null;
|
|
5
|
+
quantity: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckoutInitParams {
|
|
8
|
+
lineItems: CheckoutLineItem[];
|
|
9
|
+
cartToken?: string;
|
|
10
|
+
promotionIds?: string[];
|
|
11
|
+
returnUrl?: string;
|
|
12
|
+
draft?: boolean;
|
|
13
|
+
useCustomDomain?: boolean;
|
|
14
|
+
customerMetadata?: Record<string, unknown>;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
storeId?: string;
|
|
17
|
+
customer?: {
|
|
18
|
+
currency?: string;
|
|
19
|
+
locale?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface CheckoutSession {
|
|
23
|
+
id: string;
|
|
24
|
+
checkoutToken: string;
|
|
25
|
+
status: string;
|
|
26
|
+
storeId: string;
|
|
27
|
+
accountId: string;
|
|
28
|
+
customerId: string;
|
|
29
|
+
draft: boolean;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
lastActiveDate: string;
|
|
33
|
+
selectedPresentmentCurrency: string;
|
|
34
|
+
shippingAddress?: any;
|
|
35
|
+
billingAddress?: any;
|
|
36
|
+
customer?: {
|
|
37
|
+
id: string;
|
|
38
|
+
email?: string;
|
|
39
|
+
firstName?: string;
|
|
40
|
+
lastName?: string;
|
|
41
|
+
phone?: string;
|
|
42
|
+
locale?: string;
|
|
43
|
+
};
|
|
44
|
+
sessionLineItems: {
|
|
45
|
+
id: string;
|
|
46
|
+
quantity: number;
|
|
47
|
+
priceId: string;
|
|
48
|
+
variantId: string;
|
|
49
|
+
productId: string;
|
|
50
|
+
isOrderBump: boolean;
|
|
51
|
+
orderBumpType?: string;
|
|
52
|
+
price: {
|
|
53
|
+
id: string;
|
|
54
|
+
amount: number;
|
|
55
|
+
currency: string;
|
|
56
|
+
currencyOptions: any;
|
|
57
|
+
variant: {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
description: string | null;
|
|
61
|
+
sku: string | null;
|
|
62
|
+
imageUrl: string | null;
|
|
63
|
+
product: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
description: string | null;
|
|
67
|
+
imageUrl: string | null;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}[];
|
|
72
|
+
store: {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
domain: string;
|
|
76
|
+
currency: string;
|
|
77
|
+
locale: string;
|
|
78
|
+
presentmentCurrencies: string[];
|
|
79
|
+
chargeCurrencies: string[];
|
|
80
|
+
upsells: {
|
|
81
|
+
id: string;
|
|
82
|
+
type: string;
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
orderBumpOffers: {
|
|
85
|
+
id: string;
|
|
86
|
+
type: string;
|
|
87
|
+
precheck: boolean;
|
|
88
|
+
variantId: string;
|
|
89
|
+
productId: string;
|
|
90
|
+
priceId: string;
|
|
91
|
+
variant: {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
description: string | null;
|
|
95
|
+
imageUrl: string | null;
|
|
96
|
+
};
|
|
97
|
+
product: {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
description: string | null;
|
|
101
|
+
imageUrl: string | null;
|
|
102
|
+
};
|
|
103
|
+
price: {
|
|
104
|
+
id: string;
|
|
105
|
+
amount: number;
|
|
106
|
+
currency: string;
|
|
107
|
+
};
|
|
108
|
+
}[];
|
|
109
|
+
}[];
|
|
110
|
+
integrations: {
|
|
111
|
+
id: string;
|
|
112
|
+
type: string;
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
config: any;
|
|
115
|
+
}[];
|
|
116
|
+
};
|
|
117
|
+
shippingRate?: {
|
|
118
|
+
id: string;
|
|
119
|
+
shippingRateName: string;
|
|
120
|
+
amount: number;
|
|
121
|
+
isFree: boolean;
|
|
122
|
+
};
|
|
123
|
+
orders: {
|
|
124
|
+
id: string;
|
|
125
|
+
status: string;
|
|
126
|
+
}[];
|
|
127
|
+
orderSummaries: {
|
|
128
|
+
id: string;
|
|
129
|
+
currency: string;
|
|
130
|
+
totalAmount: number;
|
|
131
|
+
totalAdjustedAmount: number;
|
|
132
|
+
totalPromotionAmount: number;
|
|
133
|
+
items: any;
|
|
134
|
+
adjustments: any;
|
|
135
|
+
}[];
|
|
136
|
+
}
|
|
137
|
+
export interface CheckoutSummary {
|
|
138
|
+
currency: string;
|
|
139
|
+
totalAmount: number;
|
|
140
|
+
totalAdjustedAmount: number;
|
|
141
|
+
totalPromotionAmount: number;
|
|
142
|
+
items: {
|
|
143
|
+
id: string;
|
|
144
|
+
name: string;
|
|
145
|
+
description: string | null;
|
|
146
|
+
imageUrl: string | null;
|
|
147
|
+
quantity: number;
|
|
148
|
+
unitAmount: number;
|
|
149
|
+
amount: number;
|
|
150
|
+
adjustedAmount: number;
|
|
151
|
+
currency: string;
|
|
152
|
+
isOrderBump: boolean;
|
|
153
|
+
orderBumpType?: string;
|
|
154
|
+
}[];
|
|
155
|
+
adjustments: {
|
|
156
|
+
type: string;
|
|
157
|
+
description: string;
|
|
158
|
+
amount: number;
|
|
159
|
+
}[];
|
|
160
|
+
}
|
|
161
|
+
export interface Promotion {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
description: string | null;
|
|
165
|
+
type: string;
|
|
166
|
+
rules: any[];
|
|
167
|
+
actions: any[];
|
|
168
|
+
}
|
|
169
|
+
export interface CheckoutData {
|
|
170
|
+
checkoutSession: CheckoutSession;
|
|
171
|
+
customerIsClubMember: boolean;
|
|
172
|
+
clubProductId?: string;
|
|
173
|
+
summary: CheckoutSummary;
|
|
174
|
+
availablePromotions: Promotion[];
|
|
175
|
+
}
|
|
176
|
+
export interface UseCheckoutOptions {
|
|
177
|
+
autoRefresh?: boolean;
|
|
178
|
+
refreshInterval?: number;
|
|
179
|
+
realTimeUpdates?: boolean;
|
|
180
|
+
autoInitFromUrl?: boolean;
|
|
181
|
+
checkoutToken?: string;
|
|
182
|
+
fallbackToken?: string;
|
|
183
|
+
autoLoadFromToken?: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface UseCheckoutResult {
|
|
186
|
+
checkout: CheckoutData | null;
|
|
187
|
+
isLoading: boolean;
|
|
188
|
+
error: Error | null;
|
|
189
|
+
isInitialized: boolean;
|
|
190
|
+
initialized: boolean;
|
|
191
|
+
init: (params: CheckoutInitParams) => Promise<{
|
|
192
|
+
checkoutUrl: string;
|
|
193
|
+
checkoutSession: CheckoutSession;
|
|
194
|
+
checkoutToken: string;
|
|
195
|
+
}>;
|
|
196
|
+
getCheckout: (checkoutToken: string) => Promise<CheckoutData>;
|
|
197
|
+
refresh: () => Promise<void>;
|
|
198
|
+
updateAddress: (data: {
|
|
199
|
+
shippingAddress: any;
|
|
200
|
+
billingAddress?: any;
|
|
201
|
+
}) => Promise<{
|
|
202
|
+
success: boolean;
|
|
203
|
+
shippingCountryChanged: boolean;
|
|
204
|
+
billingCountryChanged: boolean;
|
|
205
|
+
}>;
|
|
206
|
+
setCheckoutInfo: (data: {
|
|
207
|
+
shippingAddress: any;
|
|
208
|
+
billingAddress?: any;
|
|
209
|
+
differentBillingAddress?: boolean;
|
|
210
|
+
}) => Promise<{
|
|
211
|
+
success: boolean;
|
|
212
|
+
errors?: Record<string, {
|
|
213
|
+
message: string;
|
|
214
|
+
type: string;
|
|
215
|
+
}>;
|
|
216
|
+
shippingCountryChanged?: boolean;
|
|
217
|
+
billingCountryChanged?: boolean;
|
|
218
|
+
}>;
|
|
219
|
+
applyPromotionCode: (code: string) => Promise<{
|
|
220
|
+
success: boolean;
|
|
221
|
+
error?: any;
|
|
222
|
+
}>;
|
|
223
|
+
removePromotion: (promotionId: string) => Promise<{
|
|
224
|
+
success: boolean;
|
|
225
|
+
error?: any;
|
|
226
|
+
}>;
|
|
227
|
+
getAppliedPromotions: () => Promise<Promotion[]>;
|
|
228
|
+
updateLineItems: (lineItems: CheckoutLineItem[]) => Promise<{
|
|
229
|
+
success: boolean;
|
|
230
|
+
error?: any;
|
|
231
|
+
}>;
|
|
232
|
+
toggleOrderBump: (orderBumpOfferId: string, selected: boolean) => Promise<{
|
|
233
|
+
success: boolean;
|
|
234
|
+
error?: any;
|
|
235
|
+
}>;
|
|
236
|
+
updateCustomer: (data: {
|
|
237
|
+
email: string;
|
|
238
|
+
acceptsMarketing?: boolean;
|
|
239
|
+
}) => Promise<{
|
|
240
|
+
success: boolean;
|
|
241
|
+
error?: any;
|
|
242
|
+
}>;
|
|
243
|
+
updateCustomerAndSessionInfo: (data: {
|
|
244
|
+
customerData: {
|
|
245
|
+
email: string;
|
|
246
|
+
acceptsMarketing?: boolean;
|
|
247
|
+
};
|
|
248
|
+
shippingAddress: any;
|
|
249
|
+
billingAddress?: any;
|
|
250
|
+
differentBillingAddress?: boolean;
|
|
251
|
+
}) => Promise<{
|
|
252
|
+
success: boolean;
|
|
253
|
+
errors?: Record<string, {
|
|
254
|
+
message: string;
|
|
255
|
+
type: string;
|
|
256
|
+
}>;
|
|
257
|
+
shippingCountryChanged?: boolean;
|
|
258
|
+
billingCountryChanged?: boolean;
|
|
259
|
+
}>;
|
|
260
|
+
clear: () => void;
|
|
261
|
+
}
|
|
262
|
+
export declare function useCheckout(options?: UseCheckoutOptions): UseCheckoutResult;
|