@storepecker/storefront-core 2.9.1 → 2.10.1
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/address-BdIB6IuI.d.cts +42 -0
- package/dist/address-BdIB6IuI.d.ts +42 -0
- package/dist/api/index.cjs +36 -32
- package/dist/api/index.d.cts +20 -17
- package/dist/api/index.d.ts +20 -17
- package/dist/api/index.js +4 -4
- package/dist/{buy-now-BqVWXyy8.d.cts → buy-now-CDug6LJ_.d.ts} +2 -2
- package/dist/{buy-now-DFdnuLjO.d.ts → buy-now-DrKY5_9R.d.cts} +2 -2
- package/dist/checkout/index.cjs +163 -76
- package/dist/checkout/index.d.cts +37 -26
- package/dist/checkout/index.d.ts +37 -26
- package/dist/checkout/index.js +50 -64
- package/dist/checkout-totals-CbmXM9L7.d.cts +220 -0
- package/dist/checkout-totals-DU8l-Wyb.d.ts +220 -0
- package/dist/{chunk-IG4BW3ZB.cjs → chunk-32X4SWN4.cjs} +3 -3
- package/dist/{chunk-NQZ5GUOG.cjs → chunk-3YPE6UPC.cjs} +24 -16
- package/dist/{chunk-RDUT4W3B.cjs → chunk-6APRQ2ED.cjs} +4 -1
- package/dist/{chunk-ICKTXS6B.js → chunk-6IXTFZFS.js} +3 -3
- package/dist/{chunk-7M5CVYZJ.js → chunk-A7EI7XLU.js} +8 -1
- package/dist/chunk-DZPK7GPG.js +601 -0
- package/dist/{chunk-TH7OAMGC.js → chunk-E4D4XOAE.js} +24 -16
- package/dist/{chunk-NRPK5GCJ.cjs → chunk-EFYAFXIS.cjs} +3 -3
- package/dist/{chunk-CBKJ3Y2I.js → chunk-EWZ7TGI7.js} +11 -1
- package/dist/{chunk-5XVHYPOC.js → chunk-FF5N7PTB.js} +1 -1
- package/dist/{chunk-NOT6VKXA.cjs → chunk-H6UZTS5O.cjs} +67 -23
- package/dist/{chunk-XFOUNOKO.cjs → chunk-KNG4OMS5.cjs} +8 -0
- package/dist/{chunk-ZAWZ3RB6.js → chunk-NNE42NMP.js} +1 -1
- package/dist/chunk-PN6KH5PX.cjs +661 -0
- package/dist/{chunk-QQHQTBAM.js → chunk-QSRVMOXT.js} +48 -6
- package/dist/{chunk-W6BDMNSU.js → chunk-QVO56X4E.js} +1 -1
- package/dist/{chunk-6LS5F4R3.cjs → chunk-SGJUMI3M.cjs} +11 -0
- package/dist/{chunk-YLLAP3H2.cjs → chunk-SGKLMS7W.cjs} +2 -2
- package/dist/{chunk-ZGMLOLTC.js → chunk-VRZRV2BR.js} +4 -1
- package/dist/{chunk-IVKJJLG7.cjs → chunk-WWJAPKRQ.cjs} +8 -8
- package/dist/{collections-CXgOv5_G.d.cts → collections-CKNFcE2d.d.cts} +1 -1
- package/dist/{collections-CNh2OGbl.d.ts → collections-CtRKsWVx.d.ts} +1 -1
- package/dist/components/address-form.cjs +6 -6
- package/dist/components/address-form.d.cts +10 -6
- package/dist/components/address-form.d.ts +10 -6
- package/dist/components/address-form.js +5 -5
- package/dist/components/digital-product-download-modal.d.cts +2 -2
- package/dist/components/digital-product-download-modal.d.ts +2 -2
- package/dist/components/index.cjs +8 -8
- package/dist/components/index.d.cts +6 -7
- package/dist/components/index.d.ts +6 -7
- package/dist/components/index.js +6 -6
- package/dist/components/search-dropdown.d.cts +4 -4
- package/dist/components/search-dropdown.d.ts +4 -4
- package/dist/components/share-button.cjs +3 -3
- package/dist/components/share-button.d.cts +1 -1
- package/dist/components/share-button.d.ts +1 -1
- package/dist/components/share-button.js +2 -2
- package/dist/components/theme-data-initializer.d.cts +4 -5
- package/dist/components/theme-data-initializer.d.ts +4 -5
- package/dist/hooks/index.cjs +672 -44
- package/dist/hooks/index.d.cts +239 -13
- package/dist/hooks/index.d.ts +239 -13
- package/dist/hooks/index.js +630 -11
- package/dist/{instagram-DalreBu6.d.cts → instagram-CSzrxk10.d.cts} +8 -2
- package/dist/{instagram-BADLnNQ3.d.ts → instagram-CagTLmyq.d.ts} +8 -2
- package/dist/models/index.d.cts +8 -8
- package/dist/models/index.d.ts +8 -8
- package/dist/orders-B6BmHCJN.d.ts +337 -0
- package/dist/orders-ZKP0lqRN.d.cts +337 -0
- package/dist/pincode-8u7yWLpQ.d.cts +29 -0
- package/dist/pincode-8u7yWLpQ.d.ts +29 -0
- package/dist/{pixelEvents-LsealscG.d.ts → pixelEvents-DqJ_CEEr.d.ts} +4 -4
- package/dist/{pixelEvents-BtEO5QAR.d.cts → pixelEvents-bahgVW4_.d.cts} +4 -4
- package/dist/{product-D9liEtl4.d.cts → product-D4kol-Z-.d.cts} +26 -2
- package/dist/{product-D9liEtl4.d.ts → product-D4kol-Z-.d.ts} +26 -2
- package/dist/store/index.cjs +20 -30
- package/dist/store/index.d.cts +21 -7
- package/dist/store/index.d.ts +21 -7
- package/dist/store/index.js +9 -26
- package/dist/{useAddressForm-DGbEn91-.d.cts → useAddressForm-fMOb5Z-a.d.ts} +6 -1
- package/dist/{useAddressForm-cO3Au33k.d.ts → useAddressForm-wleIo78M.d.cts} +6 -1
- package/dist/utils/index.cjs +60 -56
- package/dist/utils/index.d.cts +24 -9
- package/dist/utils/index.d.ts +24 -9
- package/dist/utils/index.js +4 -4
- package/dist/{wishlist-Cj0sQxiY.d.ts → wishlist-L3fM5-ie.d.ts} +1 -1
- package/dist/{wishlist-BakHvIFN.d.cts → wishlist-_0x0r1jt.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/address-DwBZHzbI.d.cts +0 -19
- package/dist/address-DwBZHzbI.d.ts +0 -19
- package/dist/cart-DZq1ZEnE.d.ts +0 -153
- package/dist/cart-DwMFBmpC.d.cts +0 -153
- package/dist/chunk-34Y7Y5FU.cjs +0 -246
- package/dist/chunk-VPTN4YXD.js +0 -232
- package/dist/orders-B3G4CyhH.d.cts +0 -166
- package/dist/orders-Bl-Slh72.d.ts +0 -166
package/dist/cart-DZq1ZEnE.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { g as SLICE_STATUS, d as Product, f as ProductDetail } from './product-D9liEtl4.js';
|
|
2
|
-
|
|
3
|
-
declare namespace User {
|
|
4
|
-
interface Root {
|
|
5
|
-
customer_name: string;
|
|
6
|
-
phone: string;
|
|
7
|
-
email: string;
|
|
8
|
-
date_of_birth: string;
|
|
9
|
-
country_code: string;
|
|
10
|
-
gender: string;
|
|
11
|
-
}
|
|
12
|
-
interface UserState {
|
|
13
|
-
user: LoginUserData | null;
|
|
14
|
-
isAuthenticated: boolean;
|
|
15
|
-
status: SLICE_STATUS;
|
|
16
|
-
}
|
|
17
|
-
interface LoginUserData {
|
|
18
|
-
email: string;
|
|
19
|
-
first_name: string;
|
|
20
|
-
last_name: string;
|
|
21
|
-
access: string;
|
|
22
|
-
refresh: string;
|
|
23
|
-
user_id: number;
|
|
24
|
-
phone_number: string;
|
|
25
|
-
}
|
|
26
|
-
interface UserDetailsPayload {
|
|
27
|
-
customer_name: string;
|
|
28
|
-
gender: string;
|
|
29
|
-
date_of_birth: string;
|
|
30
|
-
}
|
|
31
|
-
type LoginMethod = "email_otp" | "phone_otp";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare namespace Category {
|
|
35
|
-
interface Root {
|
|
36
|
-
id: number;
|
|
37
|
-
name: string;
|
|
38
|
-
photo: string;
|
|
39
|
-
slug: string;
|
|
40
|
-
description: string;
|
|
41
|
-
children?: Root[];
|
|
42
|
-
}
|
|
43
|
-
interface CategoriesState {
|
|
44
|
-
data: Root[];
|
|
45
|
-
status: SLICE_STATUS;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type DiscountType = "discount";
|
|
50
|
-
type ValueType = "percentage" | "fixed";
|
|
51
|
-
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
52
|
-
type CouponStatus = "active" | "inactive" | "expired";
|
|
53
|
-
interface Coupon {
|
|
54
|
-
id: number;
|
|
55
|
-
coupon_code: string;
|
|
56
|
-
discount_type: DiscountType;
|
|
57
|
-
value: string;
|
|
58
|
-
value_type: ValueType;
|
|
59
|
-
min_order_amount: string;
|
|
60
|
-
max_discount_amount: string;
|
|
61
|
-
start_date: string;
|
|
62
|
-
end_date: string;
|
|
63
|
-
status: CouponStatus;
|
|
64
|
-
is_deleted: boolean;
|
|
65
|
-
usage_limit: number;
|
|
66
|
-
usage_count: number;
|
|
67
|
-
applicable_target: ApplicableTarget;
|
|
68
|
-
applicable_product_variants: Product.ProductVariant[];
|
|
69
|
-
applicable_product_bundles: any[];
|
|
70
|
-
applicable_product_categories: Category.Root[];
|
|
71
|
-
applicable_customers: User.Root[];
|
|
72
|
-
auto_apply: boolean;
|
|
73
|
-
created_at: string;
|
|
74
|
-
updated_at: string;
|
|
75
|
-
is_cart_applicable: boolean;
|
|
76
|
-
coupon_message: string;
|
|
77
|
-
}
|
|
78
|
-
type Coupons = Coupon[];
|
|
79
|
-
interface CouponResponse {
|
|
80
|
-
coupon: Coupon;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface CartState {
|
|
84
|
-
cart: Cart.Root | null;
|
|
85
|
-
total_quantity: number;
|
|
86
|
-
status: SLICE_STATUS;
|
|
87
|
-
}
|
|
88
|
-
declare namespace Cart {
|
|
89
|
-
interface Root {
|
|
90
|
-
product_variants: ProductDetail.Root[];
|
|
91
|
-
total_amount: number;
|
|
92
|
-
total_quantity: number;
|
|
93
|
-
products_quantity: ProductsQuantity;
|
|
94
|
-
cart_count: number;
|
|
95
|
-
missing_items: {
|
|
96
|
-
[key: number]: number;
|
|
97
|
-
};
|
|
98
|
-
missing_cart_items: {
|
|
99
|
-
[key: string]: number;
|
|
100
|
-
};
|
|
101
|
-
customization_inputs: Array<CustomizationInput>;
|
|
102
|
-
total_coupon_discount: number;
|
|
103
|
-
variant_discounts: {
|
|
104
|
-
[key: number]: number;
|
|
105
|
-
};
|
|
106
|
-
total_shipping: number;
|
|
107
|
-
total_tax_amount: number;
|
|
108
|
-
applied_coupon: Coupon | {};
|
|
109
|
-
shipping_options: ShippingOption[];
|
|
110
|
-
selected_shipping_option_id: number | null;
|
|
111
|
-
selected_address_id: number | null;
|
|
112
|
-
split_preview?: {
|
|
113
|
-
has_split: boolean;
|
|
114
|
-
regular_total: string;
|
|
115
|
-
preorder_total: string;
|
|
116
|
-
preorder_ship_days: number;
|
|
117
|
-
} | null;
|
|
118
|
-
}
|
|
119
|
-
interface CustomizationInput {
|
|
120
|
-
id: number;
|
|
121
|
-
product_variant: number;
|
|
122
|
-
customization_option: number;
|
|
123
|
-
customer_wishlist: null;
|
|
124
|
-
customer_order: null;
|
|
125
|
-
customer_cart: number;
|
|
126
|
-
customer_input: string;
|
|
127
|
-
customization_option_name: string;
|
|
128
|
-
customization_option_type: string;
|
|
129
|
-
is_mandatory: boolean;
|
|
130
|
-
}
|
|
131
|
-
interface ProductsQuantity {
|
|
132
|
-
[key: number]: number;
|
|
133
|
-
}
|
|
134
|
-
interface ShippingOption {
|
|
135
|
-
id: number;
|
|
136
|
-
name: string;
|
|
137
|
-
description: string;
|
|
138
|
-
pricing_type: string;
|
|
139
|
-
base_price: string;
|
|
140
|
-
shipping_profile: number | null;
|
|
141
|
-
shipping_partner: string;
|
|
142
|
-
estimated_days_min: number;
|
|
143
|
-
estimated_days_max: number;
|
|
144
|
-
display_order: number;
|
|
145
|
-
is_active: boolean;
|
|
146
|
-
allowed_zones: any[];
|
|
147
|
-
price: string | null;
|
|
148
|
-
price_note: string | null;
|
|
149
|
-
estimated_delivery: string | null;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { type ApplicableTarget as A, Cart as C, type DiscountType as D, User as U, type ValueType as V, type CartState as a, Category as b, type Coupon as c, type CouponResponse as d, type CouponStatus as e, type Coupons as f };
|
package/dist/cart-DwMFBmpC.d.cts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { g as SLICE_STATUS, d as Product, f as ProductDetail } from './product-D9liEtl4.cjs';
|
|
2
|
-
|
|
3
|
-
declare namespace User {
|
|
4
|
-
interface Root {
|
|
5
|
-
customer_name: string;
|
|
6
|
-
phone: string;
|
|
7
|
-
email: string;
|
|
8
|
-
date_of_birth: string;
|
|
9
|
-
country_code: string;
|
|
10
|
-
gender: string;
|
|
11
|
-
}
|
|
12
|
-
interface UserState {
|
|
13
|
-
user: LoginUserData | null;
|
|
14
|
-
isAuthenticated: boolean;
|
|
15
|
-
status: SLICE_STATUS;
|
|
16
|
-
}
|
|
17
|
-
interface LoginUserData {
|
|
18
|
-
email: string;
|
|
19
|
-
first_name: string;
|
|
20
|
-
last_name: string;
|
|
21
|
-
access: string;
|
|
22
|
-
refresh: string;
|
|
23
|
-
user_id: number;
|
|
24
|
-
phone_number: string;
|
|
25
|
-
}
|
|
26
|
-
interface UserDetailsPayload {
|
|
27
|
-
customer_name: string;
|
|
28
|
-
gender: string;
|
|
29
|
-
date_of_birth: string;
|
|
30
|
-
}
|
|
31
|
-
type LoginMethod = "email_otp" | "phone_otp";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare namespace Category {
|
|
35
|
-
interface Root {
|
|
36
|
-
id: number;
|
|
37
|
-
name: string;
|
|
38
|
-
photo: string;
|
|
39
|
-
slug: string;
|
|
40
|
-
description: string;
|
|
41
|
-
children?: Root[];
|
|
42
|
-
}
|
|
43
|
-
interface CategoriesState {
|
|
44
|
-
data: Root[];
|
|
45
|
-
status: SLICE_STATUS;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type DiscountType = "discount";
|
|
50
|
-
type ValueType = "percentage" | "fixed";
|
|
51
|
-
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
52
|
-
type CouponStatus = "active" | "inactive" | "expired";
|
|
53
|
-
interface Coupon {
|
|
54
|
-
id: number;
|
|
55
|
-
coupon_code: string;
|
|
56
|
-
discount_type: DiscountType;
|
|
57
|
-
value: string;
|
|
58
|
-
value_type: ValueType;
|
|
59
|
-
min_order_amount: string;
|
|
60
|
-
max_discount_amount: string;
|
|
61
|
-
start_date: string;
|
|
62
|
-
end_date: string;
|
|
63
|
-
status: CouponStatus;
|
|
64
|
-
is_deleted: boolean;
|
|
65
|
-
usage_limit: number;
|
|
66
|
-
usage_count: number;
|
|
67
|
-
applicable_target: ApplicableTarget;
|
|
68
|
-
applicable_product_variants: Product.ProductVariant[];
|
|
69
|
-
applicable_product_bundles: any[];
|
|
70
|
-
applicable_product_categories: Category.Root[];
|
|
71
|
-
applicable_customers: User.Root[];
|
|
72
|
-
auto_apply: boolean;
|
|
73
|
-
created_at: string;
|
|
74
|
-
updated_at: string;
|
|
75
|
-
is_cart_applicable: boolean;
|
|
76
|
-
coupon_message: string;
|
|
77
|
-
}
|
|
78
|
-
type Coupons = Coupon[];
|
|
79
|
-
interface CouponResponse {
|
|
80
|
-
coupon: Coupon;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface CartState {
|
|
84
|
-
cart: Cart.Root | null;
|
|
85
|
-
total_quantity: number;
|
|
86
|
-
status: SLICE_STATUS;
|
|
87
|
-
}
|
|
88
|
-
declare namespace Cart {
|
|
89
|
-
interface Root {
|
|
90
|
-
product_variants: ProductDetail.Root[];
|
|
91
|
-
total_amount: number;
|
|
92
|
-
total_quantity: number;
|
|
93
|
-
products_quantity: ProductsQuantity;
|
|
94
|
-
cart_count: number;
|
|
95
|
-
missing_items: {
|
|
96
|
-
[key: number]: number;
|
|
97
|
-
};
|
|
98
|
-
missing_cart_items: {
|
|
99
|
-
[key: string]: number;
|
|
100
|
-
};
|
|
101
|
-
customization_inputs: Array<CustomizationInput>;
|
|
102
|
-
total_coupon_discount: number;
|
|
103
|
-
variant_discounts: {
|
|
104
|
-
[key: number]: number;
|
|
105
|
-
};
|
|
106
|
-
total_shipping: number;
|
|
107
|
-
total_tax_amount: number;
|
|
108
|
-
applied_coupon: Coupon | {};
|
|
109
|
-
shipping_options: ShippingOption[];
|
|
110
|
-
selected_shipping_option_id: number | null;
|
|
111
|
-
selected_address_id: number | null;
|
|
112
|
-
split_preview?: {
|
|
113
|
-
has_split: boolean;
|
|
114
|
-
regular_total: string;
|
|
115
|
-
preorder_total: string;
|
|
116
|
-
preorder_ship_days: number;
|
|
117
|
-
} | null;
|
|
118
|
-
}
|
|
119
|
-
interface CustomizationInput {
|
|
120
|
-
id: number;
|
|
121
|
-
product_variant: number;
|
|
122
|
-
customization_option: number;
|
|
123
|
-
customer_wishlist: null;
|
|
124
|
-
customer_order: null;
|
|
125
|
-
customer_cart: number;
|
|
126
|
-
customer_input: string;
|
|
127
|
-
customization_option_name: string;
|
|
128
|
-
customization_option_type: string;
|
|
129
|
-
is_mandatory: boolean;
|
|
130
|
-
}
|
|
131
|
-
interface ProductsQuantity {
|
|
132
|
-
[key: number]: number;
|
|
133
|
-
}
|
|
134
|
-
interface ShippingOption {
|
|
135
|
-
id: number;
|
|
136
|
-
name: string;
|
|
137
|
-
description: string;
|
|
138
|
-
pricing_type: string;
|
|
139
|
-
base_price: string;
|
|
140
|
-
shipping_profile: number | null;
|
|
141
|
-
shipping_partner: string;
|
|
142
|
-
estimated_days_min: number;
|
|
143
|
-
estimated_days_max: number;
|
|
144
|
-
display_order: number;
|
|
145
|
-
is_active: boolean;
|
|
146
|
-
allowed_zones: any[];
|
|
147
|
-
price: string | null;
|
|
148
|
-
price_note: string | null;
|
|
149
|
-
estimated_delivery: string | null;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { type ApplicableTarget as A, Cart as C, type DiscountType as D, User as U, type ValueType as V, type CartState as a, Category as b, type Coupon as c, type CouponResponse as d, type CouponStatus as e, type Coupons as f };
|
package/dist/chunk-34Y7Y5FU.cjs
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkXFOUNOKO_cjs = require('./chunk-XFOUNOKO.cjs');
|
|
4
|
-
var chunkNSAHGMS7_cjs = require('./chunk-NSAHGMS7.cjs');
|
|
5
|
-
var chunkH6FJYRO3_cjs = require('./chunk-H6FJYRO3.cjs');
|
|
6
|
-
var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
|
|
7
|
-
var axios = require('axios');
|
|
8
|
-
|
|
9
|
-
// src/checkout/payment.ts
|
|
10
|
-
function openRazorpayCheckout(order, callbacks, paymentOptions) {
|
|
11
|
-
if (!order) return;
|
|
12
|
-
chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "razorpay");
|
|
13
|
-
const {
|
|
14
|
-
razorpay_order_id,
|
|
15
|
-
razorpay_public_token,
|
|
16
|
-
total_amount,
|
|
17
|
-
razorpay_order_currency,
|
|
18
|
-
store_color_scheme,
|
|
19
|
-
store_logo,
|
|
20
|
-
store_name,
|
|
21
|
-
customer_name,
|
|
22
|
-
customer_phone,
|
|
23
|
-
customer_email
|
|
24
|
-
} = order;
|
|
25
|
-
const cloudFront = chunkN3CTXRFT_cjs.getCloudFront();
|
|
26
|
-
const options = {
|
|
27
|
-
key: razorpay_public_token,
|
|
28
|
-
amount: Number(total_amount) * 100,
|
|
29
|
-
currency: razorpay_order_currency,
|
|
30
|
-
name: store_name,
|
|
31
|
-
image: cloudFront ? `${cloudFront}${store_logo}` : store_logo,
|
|
32
|
-
order_id: razorpay_order_id,
|
|
33
|
-
handler: async (response) => {
|
|
34
|
-
handleRazorpaySuccess(
|
|
35
|
-
{
|
|
36
|
-
razorpay_payment_id: response.razorpay_payment_id,
|
|
37
|
-
razorpay_subscription_id: response.razorpay_subscription_id,
|
|
38
|
-
razorpay_signature: response.razorpay_signature,
|
|
39
|
-
order_id: order.id,
|
|
40
|
-
razorpay_order_id,
|
|
41
|
-
payment_id: response.razorpay_payment_id
|
|
42
|
-
},
|
|
43
|
-
order,
|
|
44
|
-
callbacks,
|
|
45
|
-
paymentOptions
|
|
46
|
-
);
|
|
47
|
-
},
|
|
48
|
-
theme: {
|
|
49
|
-
color: store_color_scheme?.primary,
|
|
50
|
-
accent: store_color_scheme?.secondary
|
|
51
|
-
},
|
|
52
|
-
prefill: {
|
|
53
|
-
name: customer_name,
|
|
54
|
-
email: customer_email?.endsWith("@test.com") ? void 0 : customer_email,
|
|
55
|
-
phone: customer_phone
|
|
56
|
-
},
|
|
57
|
-
modal: {
|
|
58
|
-
ondismiss: () => handleRazorpayFail(
|
|
59
|
-
order,
|
|
60
|
-
callbacks,
|
|
61
|
-
{
|
|
62
|
-
description: "User cancelled the payment manually",
|
|
63
|
-
reason: "user_cancelled_payment_manually"
|
|
64
|
-
},
|
|
65
|
-
{ isPublic: paymentOptions?.isPublic }
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const paymentObject = new window.Razorpay(options);
|
|
70
|
-
paymentObject.on("payment.failed", (response) => {
|
|
71
|
-
handleRazorpayFail(order, callbacks, response?.error, {
|
|
72
|
-
isPublic: paymentOptions?.isPublic
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
paymentObject.open();
|
|
76
|
-
}
|
|
77
|
-
async function handleRazorpaySuccess(data, order, callbacks, options) {
|
|
78
|
-
try {
|
|
79
|
-
callbacks.onPaymentStart?.();
|
|
80
|
-
if (options?.isPublic) {
|
|
81
|
-
await chunkH6FJYRO3_cjs.razorpayPublicOrderSuccess(data);
|
|
82
|
-
} else {
|
|
83
|
-
await chunkH6FJYRO3_cjs.razorpayOrderSuccess(data);
|
|
84
|
-
}
|
|
85
|
-
chunkNSAHGMS7_cjs.pixelEvents.purchase(order);
|
|
86
|
-
chunkNSAHGMS7_cjs.pixelEvents.checkoutCompleted(order);
|
|
87
|
-
callbacks.onCartReset();
|
|
88
|
-
callbacks.onSuccess(order);
|
|
89
|
-
} catch {
|
|
90
|
-
callbacks.onFailure(order);
|
|
91
|
-
} finally {
|
|
92
|
-
callbacks.onPaymentEnd?.();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
async function handleRazorpayFail(order, callbacks, error, options) {
|
|
96
|
-
try {
|
|
97
|
-
const payload = {
|
|
98
|
-
order_id: order.id,
|
|
99
|
-
razorpay_order_id: order.razorpay_order_id,
|
|
100
|
-
error
|
|
101
|
-
};
|
|
102
|
-
options?.isPublic ? await chunkH6FJYRO3_cjs.publicRazorpayOrderFailure(payload) : await chunkH6FJYRO3_cjs.razorpayOrderFail(payload);
|
|
103
|
-
} catch {
|
|
104
|
-
}
|
|
105
|
-
callbacks.onFailure(order);
|
|
106
|
-
}
|
|
107
|
-
function handlePhonepePayment(order, callbacks) {
|
|
108
|
-
if (!order) return;
|
|
109
|
-
chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "phonepe");
|
|
110
|
-
if (!order.phonepe_redirect_url) {
|
|
111
|
-
callbacks.onFailure(order);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
callbacks.onRedirect(order.phonepe_redirect_url);
|
|
115
|
-
}
|
|
116
|
-
function handleTabbyPayment(order, callbacks) {
|
|
117
|
-
if (!order) return;
|
|
118
|
-
chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "tabby");
|
|
119
|
-
if (!order.tabby_redirect_url) {
|
|
120
|
-
callbacks.onFailure(order);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
callbacks.onRedirect(order.tabby_redirect_url);
|
|
124
|
-
}
|
|
125
|
-
async function handleCODPayment(order, callbacks, options) {
|
|
126
|
-
if (!order) return;
|
|
127
|
-
try {
|
|
128
|
-
callbacks.onPaymentStart?.();
|
|
129
|
-
chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "cod");
|
|
130
|
-
if (options?.isPublic) {
|
|
131
|
-
await chunkH6FJYRO3_cjs.publicMakeCODOrder(order.order_number, {
|
|
132
|
-
customer_phone: order.customer_phone,
|
|
133
|
-
customer_email: order.customer_email
|
|
134
|
-
});
|
|
135
|
-
} else {
|
|
136
|
-
await chunkH6FJYRO3_cjs.makeCODOrder(order.id);
|
|
137
|
-
}
|
|
138
|
-
chunkNSAHGMS7_cjs.pixelEvents.purchase(order);
|
|
139
|
-
chunkNSAHGMS7_cjs.pixelEvents.checkoutCompleted(order);
|
|
140
|
-
callbacks.onCartReset();
|
|
141
|
-
callbacks.onSuccess(order);
|
|
142
|
-
} catch {
|
|
143
|
-
callbacks.onFailure(order);
|
|
144
|
-
} finally {
|
|
145
|
-
callbacks.onPaymentEnd?.();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function handleStripePayment(order, callbacks) {
|
|
149
|
-
if (!order) return;
|
|
150
|
-
chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "stripe");
|
|
151
|
-
if (order.stripe_payment_link_url) {
|
|
152
|
-
callbacks.onRedirect(order.stripe_payment_link_url);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (order.stripe_client_secret) {
|
|
156
|
-
callbacks.onStripeModalOpen?.(order);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
callbacks.onFailure(order);
|
|
160
|
-
}
|
|
161
|
-
async function handleStripeSuccess(order, paymentIntentId, callbacks, options) {
|
|
162
|
-
try {
|
|
163
|
-
callbacks.onPaymentStart?.();
|
|
164
|
-
const stripeSuccessPayload = {
|
|
165
|
-
order_id: order.id,
|
|
166
|
-
payment_intent_id: paymentIntentId
|
|
167
|
-
};
|
|
168
|
-
if (options?.isPublic) {
|
|
169
|
-
await chunkH6FJYRO3_cjs.stripePublicOrderSuccess(stripeSuccessPayload);
|
|
170
|
-
} else {
|
|
171
|
-
await chunkH6FJYRO3_cjs.stripeOrderSuccess(stripeSuccessPayload);
|
|
172
|
-
}
|
|
173
|
-
chunkNSAHGMS7_cjs.pixelEvents.purchase(order);
|
|
174
|
-
chunkNSAHGMS7_cjs.pixelEvents.checkoutCompleted(order);
|
|
175
|
-
callbacks.onCartReset();
|
|
176
|
-
callbacks.onSuccess(order);
|
|
177
|
-
} catch {
|
|
178
|
-
callbacks.onFailure(order);
|
|
179
|
-
} finally {
|
|
180
|
-
callbacks.onPaymentEnd?.();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function processPayment(order, paymentMethod, callbacks, options) {
|
|
184
|
-
if (paymentMethod === "cod") {
|
|
185
|
-
handleCODPayment(order, callbacks, options);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (order.tabby_redirect_url) {
|
|
189
|
-
handleTabbyPayment(order, callbacks);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (order.stripe_client_secret || order.stripe_payment_link_url) {
|
|
193
|
-
handleStripePayment(order, callbacks);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (order.razorpay_public_token) {
|
|
197
|
-
openRazorpayCheckout(order, callbacks, options);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
handlePhonepePayment(order, callbacks);
|
|
201
|
-
}
|
|
202
|
-
async function fetchAvailableCoupons() {
|
|
203
|
-
const response = await chunkXFOUNOKO_cjs.getCoupons();
|
|
204
|
-
return response.data;
|
|
205
|
-
}
|
|
206
|
-
async function fetchAppliedCoupon() {
|
|
207
|
-
try {
|
|
208
|
-
const response = await chunkXFOUNOKO_cjs.getAppliedCoupon();
|
|
209
|
-
return response.data || null;
|
|
210
|
-
} catch {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
async function applyCheckoutCoupon(code, callbacks) {
|
|
215
|
-
try {
|
|
216
|
-
const response = await chunkXFOUNOKO_cjs.applyCoupon(code);
|
|
217
|
-
if (response.data?.coupon) {
|
|
218
|
-
await callbacks.onCartRefresh();
|
|
219
|
-
return response.data.coupon;
|
|
220
|
-
}
|
|
221
|
-
throw new Error("Failed to apply coupon");
|
|
222
|
-
} catch (error) {
|
|
223
|
-
if (error instanceof axios.AxiosError) {
|
|
224
|
-
throw new Error(error.response?.data?.detail || "Failed to apply coupon");
|
|
225
|
-
}
|
|
226
|
-
throw error;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async function removeCheckoutCoupon(couponCode, callbacks) {
|
|
230
|
-
await chunkXFOUNOKO_cjs.removeCoupon(couponCode);
|
|
231
|
-
await callbacks.onCartRefresh();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
exports.applyCheckoutCoupon = applyCheckoutCoupon;
|
|
235
|
-
exports.fetchAppliedCoupon = fetchAppliedCoupon;
|
|
236
|
-
exports.fetchAvailableCoupons = fetchAvailableCoupons;
|
|
237
|
-
exports.handleCODPayment = handleCODPayment;
|
|
238
|
-
exports.handlePhonepePayment = handlePhonepePayment;
|
|
239
|
-
exports.handleRazorpayFail = handleRazorpayFail;
|
|
240
|
-
exports.handleRazorpaySuccess = handleRazorpaySuccess;
|
|
241
|
-
exports.handleStripePayment = handleStripePayment;
|
|
242
|
-
exports.handleStripeSuccess = handleStripeSuccess;
|
|
243
|
-
exports.handleTabbyPayment = handleTabbyPayment;
|
|
244
|
-
exports.openRazorpayCheckout = openRazorpayCheckout;
|
|
245
|
-
exports.processPayment = processPayment;
|
|
246
|
-
exports.removeCheckoutCoupon = removeCheckoutCoupon;
|