@storepecker/storefront-core 2.9.1 → 2.10.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/address-BdIB6IuI.d.cts +42 -0
- package/dist/address-BdIB6IuI.d.ts +42 -0
- package/dist/api/index.cjs +16 -12
- package/dist/api/index.d.cts +13 -3
- package/dist/api/index.d.ts +13 -3
- package/dist/api/index.js +2 -2
- package/dist/{buy-now-BqVWXyy8.d.cts → buy-now-B_15RUVT.d.cts} +1 -1
- package/dist/{buy-now-DFdnuLjO.d.ts → buy-now-kII0KrhP.d.ts} +1 -1
- package/dist/checkout/index.cjs +108 -15
- package/dist/checkout/index.d.cts +25 -1
- package/dist/checkout/index.d.ts +25 -1
- package/dist/checkout/index.js +3 -2
- package/dist/{chunk-IG4BW3ZB.cjs → chunk-32X4SWN4.cjs} +3 -3
- 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-CBKJ3Y2I.js → chunk-EWZ7TGI7.js} +11 -1
- package/dist/{chunk-5XVHYPOC.js → chunk-FF5N7PTB.js} +1 -1
- package/dist/{chunk-XFOUNOKO.cjs → chunk-KNG4OMS5.cjs} +8 -0
- package/dist/chunk-QED6QJZC.cjs +603 -0
- 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/chunk-Y4RNRPBC.js +545 -0
- 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/index.cjs +8 -8
- package/dist/components/index.d.cts +3 -3
- package/dist/components/index.d.ts +3 -3
- 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.js +2 -2
- package/dist/components/theme-data-initializer.d.cts +1 -1
- package/dist/components/theme-data-initializer.d.ts +1 -1
- package/dist/hooks/index.cjs +644 -20
- package/dist/hooks/index.d.cts +233 -9
- package/dist/hooks/index.d.ts +233 -9
- package/dist/hooks/index.js +624 -8
- package/dist/models/index.d.cts +3 -2
- package/dist/models/index.d.ts +3 -2
- package/dist/pincode-8u7yWLpQ.d.cts +29 -0
- package/dist/pincode-8u7yWLpQ.d.ts +29 -0
- package/dist/pincode-CHM-ZD3H.d.ts +179 -0
- package/dist/pincode-Ch3bZSJz.d.cts +179 -0
- package/dist/{pixelEvents-BtEO5QAR.d.cts → pixelEvents-COqZIgTu.d.cts} +1 -0
- package/dist/{pixelEvents-LsealscG.d.ts → pixelEvents-Ds6fwS9t.d.ts} +1 -0
- package/dist/store/index.d.cts +1 -1
- package/dist/store/index.d.ts +1 -1
- 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 +58 -54
- package/dist/utils/index.d.cts +12 -3
- package/dist/utils/index.d.ts +12 -3
- package/dist/utils/index.js +3 -3
- package/package.json +1 -1
- package/dist/address-DwBZHzbI.d.cts +0 -19
- package/dist/address-DwBZHzbI.d.ts +0 -19
- package/dist/chunk-34Y7Y5FU.cjs +0 -246
- package/dist/chunk-VPTN4YXD.js +0 -232
package/dist/chunk-VPTN4YXD.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-7M5CVYZJ.js';
|
|
2
|
-
import { pixelEvents } from './chunk-VAU5OL72.js';
|
|
3
|
-
import { razorpayPublicOrderSuccess, razorpayOrderSuccess, publicRazorpayOrderFailure, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripePublicOrderSuccess, stripeOrderSuccess } from './chunk-KCLVR6G5.js';
|
|
4
|
-
import { getCloudFront } from './chunk-JQMLHRWL.js';
|
|
5
|
-
import { AxiosError } from 'axios';
|
|
6
|
-
|
|
7
|
-
// src/checkout/payment.ts
|
|
8
|
-
function openRazorpayCheckout(order, callbacks, paymentOptions) {
|
|
9
|
-
if (!order) return;
|
|
10
|
-
pixelEvents.initiateCheckout(order, "razorpay");
|
|
11
|
-
const {
|
|
12
|
-
razorpay_order_id,
|
|
13
|
-
razorpay_public_token,
|
|
14
|
-
total_amount,
|
|
15
|
-
razorpay_order_currency,
|
|
16
|
-
store_color_scheme,
|
|
17
|
-
store_logo,
|
|
18
|
-
store_name,
|
|
19
|
-
customer_name,
|
|
20
|
-
customer_phone,
|
|
21
|
-
customer_email
|
|
22
|
-
} = order;
|
|
23
|
-
const cloudFront = getCloudFront();
|
|
24
|
-
const options = {
|
|
25
|
-
key: razorpay_public_token,
|
|
26
|
-
amount: Number(total_amount) * 100,
|
|
27
|
-
currency: razorpay_order_currency,
|
|
28
|
-
name: store_name,
|
|
29
|
-
image: cloudFront ? `${cloudFront}${store_logo}` : store_logo,
|
|
30
|
-
order_id: razorpay_order_id,
|
|
31
|
-
handler: async (response) => {
|
|
32
|
-
handleRazorpaySuccess(
|
|
33
|
-
{
|
|
34
|
-
razorpay_payment_id: response.razorpay_payment_id,
|
|
35
|
-
razorpay_subscription_id: response.razorpay_subscription_id,
|
|
36
|
-
razorpay_signature: response.razorpay_signature,
|
|
37
|
-
order_id: order.id,
|
|
38
|
-
razorpay_order_id,
|
|
39
|
-
payment_id: response.razorpay_payment_id
|
|
40
|
-
},
|
|
41
|
-
order,
|
|
42
|
-
callbacks,
|
|
43
|
-
paymentOptions
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
theme: {
|
|
47
|
-
color: store_color_scheme?.primary,
|
|
48
|
-
accent: store_color_scheme?.secondary
|
|
49
|
-
},
|
|
50
|
-
prefill: {
|
|
51
|
-
name: customer_name,
|
|
52
|
-
email: customer_email?.endsWith("@test.com") ? void 0 : customer_email,
|
|
53
|
-
phone: customer_phone
|
|
54
|
-
},
|
|
55
|
-
modal: {
|
|
56
|
-
ondismiss: () => handleRazorpayFail(
|
|
57
|
-
order,
|
|
58
|
-
callbacks,
|
|
59
|
-
{
|
|
60
|
-
description: "User cancelled the payment manually",
|
|
61
|
-
reason: "user_cancelled_payment_manually"
|
|
62
|
-
},
|
|
63
|
-
{ isPublic: paymentOptions?.isPublic }
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const paymentObject = new window.Razorpay(options);
|
|
68
|
-
paymentObject.on("payment.failed", (response) => {
|
|
69
|
-
handleRazorpayFail(order, callbacks, response?.error, {
|
|
70
|
-
isPublic: paymentOptions?.isPublic
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
paymentObject.open();
|
|
74
|
-
}
|
|
75
|
-
async function handleRazorpaySuccess(data, order, callbacks, options) {
|
|
76
|
-
try {
|
|
77
|
-
callbacks.onPaymentStart?.();
|
|
78
|
-
if (options?.isPublic) {
|
|
79
|
-
await razorpayPublicOrderSuccess(data);
|
|
80
|
-
} else {
|
|
81
|
-
await razorpayOrderSuccess(data);
|
|
82
|
-
}
|
|
83
|
-
pixelEvents.purchase(order);
|
|
84
|
-
pixelEvents.checkoutCompleted(order);
|
|
85
|
-
callbacks.onCartReset();
|
|
86
|
-
callbacks.onSuccess(order);
|
|
87
|
-
} catch {
|
|
88
|
-
callbacks.onFailure(order);
|
|
89
|
-
} finally {
|
|
90
|
-
callbacks.onPaymentEnd?.();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async function handleRazorpayFail(order, callbacks, error, options) {
|
|
94
|
-
try {
|
|
95
|
-
const payload = {
|
|
96
|
-
order_id: order.id,
|
|
97
|
-
razorpay_order_id: order.razorpay_order_id,
|
|
98
|
-
error
|
|
99
|
-
};
|
|
100
|
-
options?.isPublic ? await publicRazorpayOrderFailure(payload) : await razorpayOrderFail(payload);
|
|
101
|
-
} catch {
|
|
102
|
-
}
|
|
103
|
-
callbacks.onFailure(order);
|
|
104
|
-
}
|
|
105
|
-
function handlePhonepePayment(order, callbacks) {
|
|
106
|
-
if (!order) return;
|
|
107
|
-
pixelEvents.initiateCheckout(order, "phonepe");
|
|
108
|
-
if (!order.phonepe_redirect_url) {
|
|
109
|
-
callbacks.onFailure(order);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
callbacks.onRedirect(order.phonepe_redirect_url);
|
|
113
|
-
}
|
|
114
|
-
function handleTabbyPayment(order, callbacks) {
|
|
115
|
-
if (!order) return;
|
|
116
|
-
pixelEvents.initiateCheckout(order, "tabby");
|
|
117
|
-
if (!order.tabby_redirect_url) {
|
|
118
|
-
callbacks.onFailure(order);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
callbacks.onRedirect(order.tabby_redirect_url);
|
|
122
|
-
}
|
|
123
|
-
async function handleCODPayment(order, callbacks, options) {
|
|
124
|
-
if (!order) return;
|
|
125
|
-
try {
|
|
126
|
-
callbacks.onPaymentStart?.();
|
|
127
|
-
pixelEvents.initiateCheckout(order, "cod");
|
|
128
|
-
if (options?.isPublic) {
|
|
129
|
-
await publicMakeCODOrder(order.order_number, {
|
|
130
|
-
customer_phone: order.customer_phone,
|
|
131
|
-
customer_email: order.customer_email
|
|
132
|
-
});
|
|
133
|
-
} else {
|
|
134
|
-
await makeCODOrder(order.id);
|
|
135
|
-
}
|
|
136
|
-
pixelEvents.purchase(order);
|
|
137
|
-
pixelEvents.checkoutCompleted(order);
|
|
138
|
-
callbacks.onCartReset();
|
|
139
|
-
callbacks.onSuccess(order);
|
|
140
|
-
} catch {
|
|
141
|
-
callbacks.onFailure(order);
|
|
142
|
-
} finally {
|
|
143
|
-
callbacks.onPaymentEnd?.();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function handleStripePayment(order, callbacks) {
|
|
147
|
-
if (!order) return;
|
|
148
|
-
pixelEvents.initiateCheckout(order, "stripe");
|
|
149
|
-
if (order.stripe_payment_link_url) {
|
|
150
|
-
callbacks.onRedirect(order.stripe_payment_link_url);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (order.stripe_client_secret) {
|
|
154
|
-
callbacks.onStripeModalOpen?.(order);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
callbacks.onFailure(order);
|
|
158
|
-
}
|
|
159
|
-
async function handleStripeSuccess(order, paymentIntentId, callbacks, options) {
|
|
160
|
-
try {
|
|
161
|
-
callbacks.onPaymentStart?.();
|
|
162
|
-
const stripeSuccessPayload = {
|
|
163
|
-
order_id: order.id,
|
|
164
|
-
payment_intent_id: paymentIntentId
|
|
165
|
-
};
|
|
166
|
-
if (options?.isPublic) {
|
|
167
|
-
await stripePublicOrderSuccess(stripeSuccessPayload);
|
|
168
|
-
} else {
|
|
169
|
-
await stripeOrderSuccess(stripeSuccessPayload);
|
|
170
|
-
}
|
|
171
|
-
pixelEvents.purchase(order);
|
|
172
|
-
pixelEvents.checkoutCompleted(order);
|
|
173
|
-
callbacks.onCartReset();
|
|
174
|
-
callbacks.onSuccess(order);
|
|
175
|
-
} catch {
|
|
176
|
-
callbacks.onFailure(order);
|
|
177
|
-
} finally {
|
|
178
|
-
callbacks.onPaymentEnd?.();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function processPayment(order, paymentMethod, callbacks, options) {
|
|
182
|
-
if (paymentMethod === "cod") {
|
|
183
|
-
handleCODPayment(order, callbacks, options);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (order.tabby_redirect_url) {
|
|
187
|
-
handleTabbyPayment(order, callbacks);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (order.stripe_client_secret || order.stripe_payment_link_url) {
|
|
191
|
-
handleStripePayment(order, callbacks);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (order.razorpay_public_token) {
|
|
195
|
-
openRazorpayCheckout(order, callbacks, options);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
handlePhonepePayment(order, callbacks);
|
|
199
|
-
}
|
|
200
|
-
async function fetchAvailableCoupons() {
|
|
201
|
-
const response = await getCoupons();
|
|
202
|
-
return response.data;
|
|
203
|
-
}
|
|
204
|
-
async function fetchAppliedCoupon() {
|
|
205
|
-
try {
|
|
206
|
-
const response = await getAppliedCoupon();
|
|
207
|
-
return response.data || null;
|
|
208
|
-
} catch {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
async function applyCheckoutCoupon(code, callbacks) {
|
|
213
|
-
try {
|
|
214
|
-
const response = await applyCoupon(code);
|
|
215
|
-
if (response.data?.coupon) {
|
|
216
|
-
await callbacks.onCartRefresh();
|
|
217
|
-
return response.data.coupon;
|
|
218
|
-
}
|
|
219
|
-
throw new Error("Failed to apply coupon");
|
|
220
|
-
} catch (error) {
|
|
221
|
-
if (error instanceof AxiosError) {
|
|
222
|
-
throw new Error(error.response?.data?.detail || "Failed to apply coupon");
|
|
223
|
-
}
|
|
224
|
-
throw error;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
async function removeCheckoutCoupon(couponCode, callbacks) {
|
|
228
|
-
await removeCoupon(couponCode);
|
|
229
|
-
await callbacks.onCartRefresh();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export { applyCheckoutCoupon, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, openRazorpayCheckout, processPayment, removeCheckoutCoupon };
|