@tagadapay/plugin-sdk 2.4.38 → 2.5.0
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/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/react/hooks/useCheckout.js +21 -33
- package/dist/react/hooks/useCheckoutSession.d.ts +19 -0
- package/dist/react/hooks/useCheckoutSession.js +108 -0
- package/dist/react/hooks/useCheckoutToken.d.ts +17 -0
- package/dist/react/hooks/useCheckoutToken.js +80 -0
- package/dist/react/hooks/useOrderBump.js +94 -29
- package/dist/react/hooks/useOrderBumpV2.d.ts +17 -0
- package/dist/react/hooks/useOrderBumpV2.js +95 -0
- package/dist/react/hooks/useOrderBumpV3.d.ts +23 -0
- package/dist/react/hooks/useOrderBumpV3.js +109 -0
- package/dist/react/hooks/usePayment.d.ts +1 -1
- package/dist/react/hooks/usePayment.js +2 -18
- package/dist/react/hooks/usePluginConfig.js +2 -13
- package/dist/react/hooks/usePostPurchases.js +11 -5
- package/dist/react/hooks/useProducts.js +2 -16
- package/dist/react/index.d.ts +9 -1
- package/dist/react/index.js +5 -1
- package/dist/react/providers/TagadaProvider.d.ts +0 -1
- package/dist/react/providers/TagadaProvider.js +16 -12
- package/dist/react/services/apiService.d.ts +1 -0
- package/dist/react/services/apiService.js +3 -0
- package/dist/v2/core/googleAutocomplete.d.ts +65 -0
- package/dist/v2/core/googleAutocomplete.js +94 -0
- package/dist/v2/core/index.d.ts +8 -0
- package/dist/v2/core/index.js +11 -0
- package/dist/v2/core/isoData.d.ts +50 -0
- package/dist/v2/core/isoData.js +103 -0
- package/dist/v2/core/resources/apiClient.d.ts +25 -0
- package/dist/v2/core/resources/apiClient.js +95 -0
- package/dist/v2/core/resources/checkout.d.ts +189 -0
- package/dist/v2/core/resources/checkout.js +119 -0
- package/dist/v2/core/resources/index.d.ts +13 -0
- package/dist/v2/core/resources/index.js +13 -0
- package/dist/v2/core/resources/offers.d.ts +98 -0
- package/dist/v2/core/resources/offers.js +115 -0
- package/dist/v2/core/resources/orders.d.ts +40 -0
- package/dist/v2/core/resources/orders.js +59 -0
- package/dist/v2/core/resources/payments.d.ts +140 -0
- package/dist/v2/core/resources/payments.js +126 -0
- package/dist/v2/core/resources/postPurchases.d.ts +182 -0
- package/dist/v2/core/resources/postPurchases.js +116 -0
- package/dist/v2/core/resources/products.d.ts +29 -0
- package/dist/v2/core/resources/products.js +49 -0
- package/dist/v2/core/resources/promotions.d.ts +45 -0
- package/dist/v2/core/resources/promotions.js +87 -0
- package/dist/v2/core/resources/threeds.d.ts +23 -0
- package/dist/v2/core/resources/threeds.js +15 -0
- package/dist/v2/core/utils/checkout.d.ts +24 -0
- package/dist/v2/core/utils/checkout.js +30 -0
- package/dist/v2/core/utils/currency.d.ts +28 -0
- package/dist/v2/core/utils/currency.js +272 -0
- package/dist/v2/core/utils/index.d.ts +12 -0
- package/dist/v2/core/utils/index.js +12 -0
- package/dist/v2/core/utils/order.d.ts +159 -0
- package/dist/v2/core/utils/order.js +42 -0
- package/dist/v2/core/utils/orderBump.d.ts +40 -0
- package/dist/v2/core/utils/orderBump.js +47 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +43 -0
- package/dist/v2/core/utils/pluginConfig.js +155 -0
- package/dist/v2/core/utils/postPurchases.d.ts +32 -0
- package/dist/v2/core/utils/postPurchases.js +42 -0
- package/dist/v2/core/utils/products.d.ts +58 -0
- package/dist/v2/core/utils/products.js +64 -0
- package/dist/v2/core/utils/promotions.d.ts +24 -0
- package/dist/v2/core/utils/promotions.js +30 -0
- package/dist/v2/index.d.ts +19 -0
- package/dist/v2/index.js +15 -0
- package/dist/v2/react/components/DebugDrawer.d.ts +7 -0
- package/dist/v2/react/components/DebugDrawer.js +383 -0
- package/dist/v2/react/hooks/useApiQuery.d.ts +28 -0
- package/dist/v2/react/hooks/useApiQuery.js +84 -0
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +39 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +208 -0
- package/dist/v2/react/hooks/useCheckoutToken.d.ts +17 -0
- package/dist/v2/react/hooks/useCheckoutToken.js +80 -0
- package/dist/v2/react/hooks/useCurrency.d.ts +9 -0
- package/dist/v2/react/hooks/useCurrency.js +21 -0
- package/dist/v2/react/hooks/useGeoLocation.d.ts +138 -0
- package/dist/v2/react/hooks/useGeoLocation.js +126 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +74 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +207 -0
- package/dist/v2/react/hooks/useISOData.d.ts +61 -0
- package/dist/v2/react/hooks/useISOData.js +176 -0
- package/dist/v2/react/hooks/useOffersQuery.d.ts +65 -0
- package/dist/v2/react/hooks/useOffersQuery.js +353 -0
- package/dist/v2/react/hooks/useOrderBumpQuery.d.ts +20 -0
- package/dist/v2/react/hooks/useOrderBumpQuery.js +88 -0
- package/dist/v2/react/hooks/useOrderQuery.d.ts +29 -0
- package/dist/v2/react/hooks/useOrderQuery.js +98 -0
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +45 -0
- package/dist/v2/react/hooks/usePaymentPolling.js +153 -0
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +19 -0
- package/dist/v2/react/hooks/usePaymentQuery.js +283 -0
- package/dist/v2/react/hooks/usePluginConfig.d.ts +16 -0
- package/dist/v2/react/hooks/usePluginConfig.js +36 -0
- package/dist/v2/react/hooks/usePostPurchasesQuery.d.ts +63 -0
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +365 -0
- package/dist/v2/react/hooks/useProductsQuery.d.ts +31 -0
- package/dist/v2/react/hooks/useProductsQuery.js +102 -0
- package/dist/v2/react/hooks/usePromotionsQuery.d.ts +28 -0
- package/dist/v2/react/hooks/usePromotionsQuery.js +97 -0
- package/dist/v2/react/hooks/useThreeds.d.ts +36 -0
- package/dist/v2/react/hooks/useThreeds.js +166 -0
- package/dist/v2/react/hooks/useThreedsModal.d.ts +13 -0
- package/dist/v2/react/hooks/useThreedsModal.js +343 -0
- package/dist/v2/react/index.d.ts +38 -0
- package/dist/v2/react/index.js +27 -0
- package/dist/v2/react/providers/TagadaProvider.d.ts +63 -0
- package/dist/v2/react/providers/TagadaProvider.js +680 -0
- package/package.json +10 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post Purchases Resource Client
|
|
3
|
+
* Axios-based API client for post-purchase endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class PostPurchasesResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get post-purchase offers for an order
|
|
11
|
+
*/
|
|
12
|
+
async getPostPurchaseOffers(orderId) {
|
|
13
|
+
const response = await this.apiClient.get(`/api/v1/post-purchase/${orderId}/offers`);
|
|
14
|
+
return response || [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Accept a post-purchase offer
|
|
18
|
+
*/
|
|
19
|
+
async acceptOffer(orderId, offerId, items) {
|
|
20
|
+
return this.apiClient.post(`/api/v1/orders/${orderId}/post-purchase-offers/${offerId}/accept`, {
|
|
21
|
+
items,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decline a post-purchase offer
|
|
26
|
+
*/
|
|
27
|
+
async declineOffer(orderId, offerId) {
|
|
28
|
+
return this.apiClient.post(`/api/v1/orders/${orderId}/post-purchase-offers/${offerId}/decline`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Preview a post-purchase offer
|
|
32
|
+
*/
|
|
33
|
+
async previewOffer(orderId, offerId, items) {
|
|
34
|
+
return this.apiClient.post(`/api/v1/orders/${orderId}/post-purchase-offers/${offerId}/preview`, {
|
|
35
|
+
items,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a post-purchase order
|
|
40
|
+
*/
|
|
41
|
+
async createPostPurchaseOrder(orderId, offers) {
|
|
42
|
+
try {
|
|
43
|
+
const response = await this.apiClient.post(`/api/v1/orders/${orderId}/post-purchase`, {
|
|
44
|
+
offers, // Use all offers since they don't have isSelected property
|
|
45
|
+
});
|
|
46
|
+
if (response.success) {
|
|
47
|
+
return { success: true, orderId: response.orderId };
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return { success: false, error: response.error || 'Failed to create post-purchase order' };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
success: false,
|
|
56
|
+
error: error instanceof Error ? error.message : 'Failed to create post-purchase order',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Initialize a checkout session for a post-purchase offer
|
|
62
|
+
*/
|
|
63
|
+
async initCheckoutSession(offerId, orderId, customerId) {
|
|
64
|
+
const response = await this.apiClient.post('/api/v1/checkout/offer/init', {
|
|
65
|
+
offerId,
|
|
66
|
+
returnUrl: typeof window !== 'undefined' ? window.location.href : '',
|
|
67
|
+
customerId: customerId || '',
|
|
68
|
+
orderId,
|
|
69
|
+
});
|
|
70
|
+
return { checkoutSessionId: response.checkoutSessionId };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Initialize a checkout session for a post-purchase offer with specific variants
|
|
74
|
+
*/
|
|
75
|
+
async initCheckoutSessionWithVariants(offerId, orderId, lineItems) {
|
|
76
|
+
const response = await this.apiClient.post(`/api/v1/offers/${offerId}/transform-to-checkout`, {
|
|
77
|
+
offerId,
|
|
78
|
+
lineItems,
|
|
79
|
+
returnUrl: typeof window !== 'undefined' ? window.location.href : '',
|
|
80
|
+
mainOrderId: orderId,
|
|
81
|
+
});
|
|
82
|
+
return { checkoutSessionId: response.checkoutSessionId };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Pay with a checkout session for a post-purchase offer
|
|
86
|
+
*/
|
|
87
|
+
async payWithCheckoutSession(checkoutSessionId, orderId) {
|
|
88
|
+
await this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/pay`, {
|
|
89
|
+
checkoutSessionId,
|
|
90
|
+
draft: false,
|
|
91
|
+
returnUrl: typeof window !== 'undefined' ? window.location.href : '',
|
|
92
|
+
metadata: {
|
|
93
|
+
comingFromPostPurchase: true,
|
|
94
|
+
postOrder: orderId,
|
|
95
|
+
upsell: true,
|
|
96
|
+
source: 'post_purchase_offer',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get order summary for a checkout session
|
|
102
|
+
*/
|
|
103
|
+
async getOrderSummary(sessionId, includeVariantOptions = false) {
|
|
104
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${sessionId}/order-summary`, {
|
|
105
|
+
includeVariantOptions,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Update line items for a checkout session
|
|
110
|
+
*/
|
|
111
|
+
async updateLineItems(sessionId, lineItems) {
|
|
112
|
+
return this.apiClient.post(`/api/v1/checkout-sessions/${sessionId}/line-items`, {
|
|
113
|
+
lineItems,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Products Resource Client
|
|
3
|
+
* Axios-based API client for product endpoints
|
|
4
|
+
*/
|
|
5
|
+
import type { Product, ProductVariant, ProductPrice } from '../utils/products';
|
|
6
|
+
import { ApiClient } from './apiClient';
|
|
7
|
+
export interface GetProductsOptions {
|
|
8
|
+
storeId: string;
|
|
9
|
+
productIds?: string[];
|
|
10
|
+
includeVariants?: boolean;
|
|
11
|
+
includePrices?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type { Product, ProductVariant, ProductPrice };
|
|
14
|
+
export declare class ProductsResource {
|
|
15
|
+
private apiClient;
|
|
16
|
+
constructor(apiClient: ApiClient);
|
|
17
|
+
/**
|
|
18
|
+
* Get all products for a store
|
|
19
|
+
*/
|
|
20
|
+
getProducts(options: GetProductsOptions): Promise<Product[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific product by ID
|
|
23
|
+
*/
|
|
24
|
+
getProduct(productId: string, options: GetProductsOptions): Promise<Product | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Get multiple products by IDs
|
|
27
|
+
*/
|
|
28
|
+
getProductsByIds(productIds: string[], options: GetProductsOptions): Promise<Product[]>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Products Resource Client
|
|
3
|
+
* Axios-based API client for product endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class ProductsResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get all products for a store
|
|
11
|
+
*/
|
|
12
|
+
async getProducts(options) {
|
|
13
|
+
const { storeId, includeVariants = true, includePrices = true } = options;
|
|
14
|
+
const response = await this.apiClient.post('/api/v1/products', {
|
|
15
|
+
storeId,
|
|
16
|
+
includeVariants,
|
|
17
|
+
includePrices,
|
|
18
|
+
});
|
|
19
|
+
return Array.isArray(response) ? response : response.items ?? [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific product by ID
|
|
23
|
+
*/
|
|
24
|
+
async getProduct(productId, options) {
|
|
25
|
+
const { storeId } = options;
|
|
26
|
+
try {
|
|
27
|
+
const response = await this.apiClient.post(`/api/v1/products/${productId}`, {
|
|
28
|
+
productId,
|
|
29
|
+
storeId,
|
|
30
|
+
});
|
|
31
|
+
return response || null;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error('Error fetching product:', error);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get multiple products by IDs
|
|
40
|
+
*/
|
|
41
|
+
async getProductsByIds(productIds, options) {
|
|
42
|
+
const { storeId, includeVariants = true, includePrices = true } = options;
|
|
43
|
+
const fetchPromises = productIds.map(async (productId) => {
|
|
44
|
+
return this.getProduct(productId, { storeId, includeVariants, includePrices });
|
|
45
|
+
});
|
|
46
|
+
const results = await Promise.all(fetchPromises);
|
|
47
|
+
return results.filter((product) => product !== null);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promotions Resource Client
|
|
3
|
+
* Axios-based API client for promotion endpoints
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
import { Promotion } from './checkout';
|
|
7
|
+
export interface PromotionCodeValidation {
|
|
8
|
+
isValid: boolean;
|
|
9
|
+
code: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
promotion?: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
value: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class PromotionsResource {
|
|
20
|
+
private apiClient;
|
|
21
|
+
constructor(apiClient: ApiClient);
|
|
22
|
+
/**
|
|
23
|
+
* Get applied promotions for a checkout session
|
|
24
|
+
*/
|
|
25
|
+
getAppliedPromotions(checkoutSessionId: string): Promise<Promotion[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Apply a promotion code to a checkout session
|
|
28
|
+
*/
|
|
29
|
+
applyPromotionCode(checkoutSessionId: string, code: string): Promise<{
|
|
30
|
+
success: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
promotion?: Promotion;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Remove a promotion from a checkout session
|
|
36
|
+
*/
|
|
37
|
+
removePromotionCode(checkoutSessionId: string, promotionId: string): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Validate a promotion code without applying it
|
|
43
|
+
*/
|
|
44
|
+
validatePromotionCode(checkoutSessionId: string, code: string): Promise<PromotionCodeValidation>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promotions Resource Client
|
|
3
|
+
* Axios-based API client for promotion endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class PromotionsResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get applied promotions for a checkout session
|
|
11
|
+
*/
|
|
12
|
+
async getAppliedPromotions(checkoutSessionId) {
|
|
13
|
+
return this.apiClient.get(`/api/v1/checkout-sessions/${checkoutSessionId}/promotions`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply a promotion code to a checkout session
|
|
17
|
+
*/
|
|
18
|
+
async applyPromotionCode(checkoutSessionId, code) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/promotions/apply`, { code: code.trim() });
|
|
21
|
+
if (response.success) {
|
|
22
|
+
return { success: true, promotion: response.promotion };
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return { success: false, error: response.error?.message || 'Failed to apply promotion code' };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
// Try to extract error message from API response
|
|
30
|
+
let errorMessage = 'Failed to apply promotion code';
|
|
31
|
+
if (err && typeof err === 'object' && 'response' in err) {
|
|
32
|
+
const apiError = err;
|
|
33
|
+
if (apiError.response?.data?.error?.message) {
|
|
34
|
+
errorMessage = apiError.response.data.error.message;
|
|
35
|
+
}
|
|
36
|
+
else if (apiError.response?.data?.message) {
|
|
37
|
+
errorMessage = apiError.response.data.message;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { success: false, error: errorMessage };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Remove a promotion from a checkout session
|
|
45
|
+
*/
|
|
46
|
+
async removePromotionCode(checkoutSessionId, promotionId) {
|
|
47
|
+
try {
|
|
48
|
+
const response = await this.apiClient.delete(`/api/v1/checkout-sessions/${checkoutSessionId}/promotions/${promotionId}`);
|
|
49
|
+
if (response.success) {
|
|
50
|
+
return { success: true };
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return { success: false, error: response.error?.message || 'Failed to remove promotion' };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// Try to extract error message from API response
|
|
58
|
+
let errorMessage = 'Failed to remove promotion';
|
|
59
|
+
if (err && typeof err === 'object' && 'response' in err) {
|
|
60
|
+
const apiError = err;
|
|
61
|
+
if (apiError.response?.data?.error?.message) {
|
|
62
|
+
errorMessage = apiError.response.data.error.message;
|
|
63
|
+
}
|
|
64
|
+
else if (apiError.response?.data?.message) {
|
|
65
|
+
errorMessage = apiError.response.data.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { success: false, error: errorMessage };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate a promotion code without applying it
|
|
73
|
+
*/
|
|
74
|
+
async validatePromotionCode(checkoutSessionId, code) {
|
|
75
|
+
try {
|
|
76
|
+
const response = await this.apiClient.post(`/api/v1/checkout-sessions/${checkoutSessionId}/promotions/validate`, { code: code.trim() });
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return {
|
|
81
|
+
isValid: false,
|
|
82
|
+
code: code.trim(),
|
|
83
|
+
error: 'Failed to validate promotion code',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threeds Resource Client
|
|
3
|
+
* Axios-based API client for 3DS endpoints
|
|
4
|
+
*/
|
|
5
|
+
import { ApiClient } from './apiClient';
|
|
6
|
+
export interface ThreedsSession {
|
|
7
|
+
id: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateSessionRequest {
|
|
12
|
+
provider: string;
|
|
13
|
+
sessionData: any;
|
|
14
|
+
paymentInstrumentId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class ThreedsResource {
|
|
17
|
+
private apiClient;
|
|
18
|
+
constructor(apiClient: ApiClient);
|
|
19
|
+
/**
|
|
20
|
+
* Create a 3DS session
|
|
21
|
+
*/
|
|
22
|
+
createSession(request: CreateSessionRequest): Promise<ThreedsSession>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threeds Resource Client
|
|
3
|
+
* Axios-based API client for 3DS endpoints
|
|
4
|
+
*/
|
|
5
|
+
export class ThreedsResource {
|
|
6
|
+
constructor(apiClient) {
|
|
7
|
+
this.apiClient = apiClient;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a 3DS session
|
|
11
|
+
*/
|
|
12
|
+
async createSession(request) {
|
|
13
|
+
return this.apiClient.post('/api/v1/threeds/create-session', request);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkout Utility Functions
|
|
3
|
+
* Pure functions for checkout data manipulation
|
|
4
|
+
*/
|
|
5
|
+
import type { CheckoutData, CheckoutSession, CheckoutLineItem, CheckoutInitParams, Promotion } from '../resources/checkout';
|
|
6
|
+
export type { CheckoutData, CheckoutSession, CheckoutLineItem, CheckoutInitParams, Promotion, };
|
|
7
|
+
export declare class CheckoutUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Get checkout session ID
|
|
10
|
+
*/
|
|
11
|
+
static getCheckoutSessionId(checkoutData: CheckoutData): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get checkout line items
|
|
14
|
+
*/
|
|
15
|
+
static getLineItems(checkoutData: CheckoutData): CheckoutLineItem[];
|
|
16
|
+
/**
|
|
17
|
+
* Get checkout total
|
|
18
|
+
*/
|
|
19
|
+
static getTotal(checkoutData: CheckoutData): number;
|
|
20
|
+
/**
|
|
21
|
+
* Check if customer is club member
|
|
22
|
+
*/
|
|
23
|
+
static isClubMember(checkoutData: CheckoutData): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkout Utility Functions
|
|
3
|
+
* Pure functions for checkout data manipulation
|
|
4
|
+
*/
|
|
5
|
+
export class CheckoutUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Get checkout session ID
|
|
8
|
+
*/
|
|
9
|
+
static getCheckoutSessionId(checkoutData) {
|
|
10
|
+
return checkoutData.checkoutSession?.id || '';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get checkout line items
|
|
14
|
+
*/
|
|
15
|
+
static getLineItems(checkoutData) {
|
|
16
|
+
return checkoutData.checkoutSession?.lineItems || [];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get checkout total
|
|
20
|
+
*/
|
|
21
|
+
static getTotal(checkoutData) {
|
|
22
|
+
return checkoutData.checkoutSession?.totalPrice || 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if customer is club member
|
|
26
|
+
*/
|
|
27
|
+
static isClubMember(checkoutData) {
|
|
28
|
+
return checkoutData.customerIsClubMember || false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Utility Functions
|
|
3
|
+
* Pure functions for currency management
|
|
4
|
+
*/
|
|
5
|
+
export interface Currency {
|
|
6
|
+
code: string;
|
|
7
|
+
symbol: string;
|
|
8
|
+
name: string;
|
|
9
|
+
decimalPlaces: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class CurrencyUtils {
|
|
12
|
+
/**
|
|
13
|
+
* Get currency from context or fallback to default
|
|
14
|
+
*/
|
|
15
|
+
static getCurrency(context: any, defaultCurrency?: string): Currency;
|
|
16
|
+
/**
|
|
17
|
+
* Get currency symbol
|
|
18
|
+
*/
|
|
19
|
+
static getCurrencySymbol(code: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get currency name
|
|
22
|
+
*/
|
|
23
|
+
static getCurrencyName(code: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get decimal places for currency
|
|
26
|
+
*/
|
|
27
|
+
static getDecimalPlaces(code: string): number;
|
|
28
|
+
}
|