@storepecker/storefront-core 2.7.0 → 2.9.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.
Files changed (63) hide show
  1. package/dist/api/index.cjs +94 -46
  2. package/dist/api/index.d.cts +108 -11
  3. package/dist/api/index.d.ts +108 -11
  4. package/dist/api/index.js +3 -3
  5. package/dist/buy-now-BqVWXyy8.d.cts +197 -0
  6. package/dist/buy-now-DFdnuLjO.d.ts +197 -0
  7. package/dist/{cart-BGIsIZdM.d.ts → cart-DZq1ZEnE.d.ts} +1 -1
  8. package/dist/{cart-CyN2JQTw.d.cts → cart-DwMFBmpC.d.cts} +1 -1
  9. package/dist/checkout/index.cjs +85 -38
  10. package/dist/checkout/index.d.cts +49 -11
  11. package/dist/checkout/index.d.ts +49 -11
  12. package/dist/checkout/index.js +65 -19
  13. package/dist/{chunk-KWYFA2LJ.cjs → chunk-34Y7Y5FU.cjs} +49 -31
  14. package/dist/{chunk-GTV42PDK.cjs → chunk-57UU7IJ2.cjs} +1 -0
  15. package/dist/{chunk-RNGQUWQW.cjs → chunk-H6FJYRO3.cjs} +49 -1
  16. package/dist/{chunk-CHRTGR3G.js → chunk-KCLVR6G5.js} +39 -2
  17. package/dist/{chunk-IWYO22XV.cjs → chunk-NOT6VKXA.cjs} +37 -39
  18. package/dist/{chunk-LCMJYFHC.cjs → chunk-NQZ5GUOG.cjs} +0 -1
  19. package/dist/{chunk-5BT3MH4A.cjs → chunk-NRPK5GCJ.cjs} +11 -3
  20. package/dist/{chunk-K44JZ5NL.cjs → chunk-NSAHGMS7.cjs} +6 -1
  21. package/dist/{chunk-4C4NTH6O.js → chunk-OOFYY6GR.js} +1 -0
  22. package/dist/{chunk-6QHEH5XE.js → chunk-QQHQTBAM.js} +20 -22
  23. package/dist/{chunk-H32TICAM.js → chunk-TH7OAMGC.js} +0 -1
  24. package/dist/{chunk-WFDKKOO7.js → chunk-VAU5OL72.js} +6 -1
  25. package/dist/{chunk-5JD6MRVS.js → chunk-VPTN4YXD.js} +36 -18
  26. package/dist/{chunk-TY5NK7NW.js → chunk-ZAWZ3RB6.js} +9 -2
  27. package/dist/{collections-ycrA2cPL.d.ts → collections-CNh2OGbl.d.ts} +1 -1
  28. package/dist/{collections-8YdINtUf.d.cts → collections-CXgOv5_G.d.cts} +1 -1
  29. package/dist/components/digital-product-download-modal.d.cts +2 -2
  30. package/dist/components/digital-product-download-modal.d.ts +2 -2
  31. package/dist/components/index.d.cts +5 -5
  32. package/dist/components/index.d.ts +5 -5
  33. package/dist/components/share-button.d.cts +1 -1
  34. package/dist/components/share-button.d.ts +1 -1
  35. package/dist/components/theme-data-initializer.d.cts +5 -5
  36. package/dist/components/theme-data-initializer.d.ts +5 -5
  37. package/dist/hooks/index.cjs +592 -30
  38. package/dist/hooks/index.d.cts +183 -5
  39. package/dist/hooks/index.d.ts +183 -5
  40. package/dist/hooks/index.js +569 -11
  41. package/dist/{instagram-CqJBZ-0X.d.ts → instagram-BADLnNQ3.d.ts} +1 -1
  42. package/dist/{instagram-D4JUT4ZU.d.cts → instagram-DalreBu6.d.cts} +1 -1
  43. package/dist/middleware/index.cjs +3 -3
  44. package/dist/middleware/index.js +1 -1
  45. package/dist/models/index.d.cts +7 -6
  46. package/dist/models/index.d.ts +7 -6
  47. package/dist/{orders-C1XZr8tx.d.ts → orders-B3G4CyhH.d.cts} +2 -1
  48. package/dist/{orders-9_scVq_M.d.cts → orders-Bl-Slh72.d.ts} +2 -1
  49. package/dist/{pixelEvents-uiPHbiAQ.d.cts → pixelEvents-BtEO5QAR.d.cts} +5 -4
  50. package/dist/{pixelEvents-D0sH22Er.d.ts → pixelEvents-LsealscG.d.ts} +5 -4
  51. package/dist/{product-CZtFWhxO.d.ts → product-D9liEtl4.d.cts} +1 -0
  52. package/dist/{product-CZtFWhxO.d.cts → product-D9liEtl4.d.ts} +1 -0
  53. package/dist/store/index.cjs +9 -9
  54. package/dist/store/index.d.cts +12 -7
  55. package/dist/store/index.d.ts +12 -7
  56. package/dist/store/index.js +4 -4
  57. package/dist/utils/index.cjs +9 -9
  58. package/dist/utils/index.d.cts +8 -7
  59. package/dist/utils/index.d.ts +8 -7
  60. package/dist/utils/index.js +3 -3
  61. package/dist/{wishlist-Cx9Vrszq.d.cts → wishlist-BakHvIFN.d.cts} +1 -1
  62. package/dist/{wishlist-CRNbfFIx.d.ts → wishlist-Cj0sQxiY.d.ts} +1 -1
  63. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import * as Yup from 'yup';
2
- import { C as Cart, c as Coupon } from '../cart-CyN2JQTw.cjs';
3
- import { O as Order } from '../orders-9_scVq_M.cjs';
4
- import '../product-CZtFWhxO.cjs';
2
+ import { C as Cart, c as Coupon } from '../cart-DwMFBmpC.cjs';
3
+ import { O as Order } from '../orders-B3G4CyhH.cjs';
4
+ import '../product-D9liEtl4.cjs';
5
5
  import 'react-toastify';
6
6
 
7
7
  /**
@@ -179,7 +179,9 @@ interface PaymentCallbacks {
179
179
  /**
180
180
  * Open the Razorpay checkout widget with the order details.
181
181
  */
182
- declare function openRazorpayCheckout(order: Order.OrderSummary, callbacks: PaymentCallbacks): void;
182
+ declare function openRazorpayCheckout(order: Order.OrderSummary, callbacks: PaymentCallbacks, paymentOptions?: {
183
+ isPublic?: boolean;
184
+ }): void;
183
185
  /**
184
186
  * Handle Razorpay payment success — call the backend API and fire pixel events.
185
187
  */
@@ -190,11 +192,15 @@ declare function handleRazorpaySuccess(data: {
190
192
  order_id: number;
191
193
  razorpay_order_id: string;
192
194
  payment_id: string;
193
- }, order: Order.OrderSummary, callbacks: PaymentCallbacks): Promise<void>;
195
+ }, order: Order.OrderSummary, callbacks: PaymentCallbacks, options?: {
196
+ isPublic?: boolean;
197
+ }): Promise<void>;
194
198
  /**
195
199
  * Handle Razorpay payment failure — notify the backend.
196
200
  */
197
- declare function handleRazorpayFail(order: Order.OrderSummary, callbacks: PaymentCallbacks, error?: any): Promise<void>;
201
+ declare function handleRazorpayFail(order: Order.OrderSummary, callbacks: PaymentCallbacks, error?: any, options?: {
202
+ isPublic?: boolean;
203
+ }): Promise<void>;
198
204
  /**
199
205
  * Handle PhonePe payment — redirect to the PhonePe URL.
200
206
  */
@@ -216,7 +222,9 @@ declare function handleStripePayment(order: Order.OrderSummary, callbacks: Payme
216
222
  /**
217
223
  * Handle Stripe order success after payment intent confirmation.
218
224
  */
219
- declare function handleStripeSuccess(order: Order.OrderSummary, paymentIntentId: string, callbacks: PaymentCallbacks): Promise<void>;
225
+ declare function handleStripeSuccess(order: Order.OrderSummary, paymentIntentId: string, callbacks: PaymentCallbacks, options?: {
226
+ isPublic?: boolean;
227
+ }): Promise<void>;
220
228
  /**
221
229
  * Route payment to the appropriate gateway based on payment method and order data.
222
230
  *
@@ -229,6 +237,30 @@ declare function processPayment(order: Order.OrderSummary, paymentMethod: string
229
237
  isPublic?: boolean;
230
238
  }): void;
231
239
 
240
+ /**
241
+ * Order placement can be refused for reasons the customer can fix on the spot —
242
+ * a shipping option that expired, stock that ran out while they were deciding.
243
+ * Those must surface as a toast on the live page with a corrective action, NOT
244
+ * as the payment-failure modal: no order exists yet, so there is nothing to
245
+ * retry or link to.
246
+ */
247
+ type PlacementErrorAction =
248
+ /** Clear the chosen shipping option so the customer picks a valid one. */
249
+ "reset-shipping"
250
+ /** Re-price the cart/preview so the stock-shortfall warning renders. */
251
+ | "refresh-preview" | "none";
252
+ interface PlacementErrorInfo {
253
+ code?: string;
254
+ message: string;
255
+ action: PlacementErrorAction;
256
+ }
257
+ /**
258
+ * Classify a failed placement request into on-screen copy plus the corrective
259
+ * action the page should apply. Shared by every checkout surface so the error
260
+ * codes stay mapped in one place.
261
+ */
262
+ declare function describePlacementError(error: any): PlacementErrorInfo;
263
+
232
264
  interface PaymentStatusCallbacks {
233
265
  onSuccess: (order: Order.OrderSummary) => void;
234
266
  onFailure: () => void;
@@ -237,11 +269,15 @@ interface PaymentStatusCallbacks {
237
269
  /**
238
270
  * Check PhonePe payment status after redirect back from PhonePe.
239
271
  */
240
- declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks): Promise<void>;
272
+ declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?: {
273
+ isPublic?: boolean;
274
+ }): Promise<void>;
241
275
  /**
242
276
  * Check PhonePe payment status with order details for pixel events.
243
277
  */
244
- declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
278
+ declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
279
+ isPublic?: boolean;
280
+ }): Promise<void>;
245
281
  /**
246
282
  * Check Stripe payment status after redirect back from Stripe checkout.
247
283
  */
@@ -251,6 +287,8 @@ declare function checkStripeReturnStatus(sessionId: string, orderNumber: number,
251
287
  /**
252
288
  * Check Tabby payment status after redirect back from Tabby.
253
289
  */
254
- declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
290
+ declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
291
+ isPublic?: boolean;
292
+ }): Promise<void>;
255
293
 
256
- export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
294
+ export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, type PlacementErrorAction, type PlacementErrorInfo, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, describePlacementError, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
@@ -1,7 +1,7 @@
1
1
  import * as Yup from 'yup';
2
- import { C as Cart, c as Coupon } from '../cart-BGIsIZdM.js';
3
- import { O as Order } from '../orders-C1XZr8tx.js';
4
- import '../product-CZtFWhxO.js';
2
+ import { C as Cart, c as Coupon } from '../cart-DZq1ZEnE.js';
3
+ import { O as Order } from '../orders-Bl-Slh72.js';
4
+ import '../product-D9liEtl4.js';
5
5
  import 'react-toastify';
6
6
 
7
7
  /**
@@ -179,7 +179,9 @@ interface PaymentCallbacks {
179
179
  /**
180
180
  * Open the Razorpay checkout widget with the order details.
181
181
  */
182
- declare function openRazorpayCheckout(order: Order.OrderSummary, callbacks: PaymentCallbacks): void;
182
+ declare function openRazorpayCheckout(order: Order.OrderSummary, callbacks: PaymentCallbacks, paymentOptions?: {
183
+ isPublic?: boolean;
184
+ }): void;
183
185
  /**
184
186
  * Handle Razorpay payment success — call the backend API and fire pixel events.
185
187
  */
@@ -190,11 +192,15 @@ declare function handleRazorpaySuccess(data: {
190
192
  order_id: number;
191
193
  razorpay_order_id: string;
192
194
  payment_id: string;
193
- }, order: Order.OrderSummary, callbacks: PaymentCallbacks): Promise<void>;
195
+ }, order: Order.OrderSummary, callbacks: PaymentCallbacks, options?: {
196
+ isPublic?: boolean;
197
+ }): Promise<void>;
194
198
  /**
195
199
  * Handle Razorpay payment failure — notify the backend.
196
200
  */
197
- declare function handleRazorpayFail(order: Order.OrderSummary, callbacks: PaymentCallbacks, error?: any): Promise<void>;
201
+ declare function handleRazorpayFail(order: Order.OrderSummary, callbacks: PaymentCallbacks, error?: any, options?: {
202
+ isPublic?: boolean;
203
+ }): Promise<void>;
198
204
  /**
199
205
  * Handle PhonePe payment — redirect to the PhonePe URL.
200
206
  */
@@ -216,7 +222,9 @@ declare function handleStripePayment(order: Order.OrderSummary, callbacks: Payme
216
222
  /**
217
223
  * Handle Stripe order success after payment intent confirmation.
218
224
  */
219
- declare function handleStripeSuccess(order: Order.OrderSummary, paymentIntentId: string, callbacks: PaymentCallbacks): Promise<void>;
225
+ declare function handleStripeSuccess(order: Order.OrderSummary, paymentIntentId: string, callbacks: PaymentCallbacks, options?: {
226
+ isPublic?: boolean;
227
+ }): Promise<void>;
220
228
  /**
221
229
  * Route payment to the appropriate gateway based on payment method and order data.
222
230
  *
@@ -229,6 +237,30 @@ declare function processPayment(order: Order.OrderSummary, paymentMethod: string
229
237
  isPublic?: boolean;
230
238
  }): void;
231
239
 
240
+ /**
241
+ * Order placement can be refused for reasons the customer can fix on the spot —
242
+ * a shipping option that expired, stock that ran out while they were deciding.
243
+ * Those must surface as a toast on the live page with a corrective action, NOT
244
+ * as the payment-failure modal: no order exists yet, so there is nothing to
245
+ * retry or link to.
246
+ */
247
+ type PlacementErrorAction =
248
+ /** Clear the chosen shipping option so the customer picks a valid one. */
249
+ "reset-shipping"
250
+ /** Re-price the cart/preview so the stock-shortfall warning renders. */
251
+ | "refresh-preview" | "none";
252
+ interface PlacementErrorInfo {
253
+ code?: string;
254
+ message: string;
255
+ action: PlacementErrorAction;
256
+ }
257
+ /**
258
+ * Classify a failed placement request into on-screen copy plus the corrective
259
+ * action the page should apply. Shared by every checkout surface so the error
260
+ * codes stay mapped in one place.
261
+ */
262
+ declare function describePlacementError(error: any): PlacementErrorInfo;
263
+
232
264
  interface PaymentStatusCallbacks {
233
265
  onSuccess: (order: Order.OrderSummary) => void;
234
266
  onFailure: () => void;
@@ -237,11 +269,15 @@ interface PaymentStatusCallbacks {
237
269
  /**
238
270
  * Check PhonePe payment status after redirect back from PhonePe.
239
271
  */
240
- declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks): Promise<void>;
272
+ declare function checkPhonepeReturnStatus(transactionId: string, callbacks: PaymentStatusCallbacks, options?: {
273
+ isPublic?: boolean;
274
+ }): Promise<void>;
241
275
  /**
242
276
  * Check PhonePe payment status with order details for pixel events.
243
277
  */
244
- declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
278
+ declare function checkPhonepeReturnStatusWithOrder(transactionId: string, orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
279
+ isPublic?: boolean;
280
+ }): Promise<void>;
245
281
  /**
246
282
  * Check Stripe payment status after redirect back from Stripe checkout.
247
283
  */
@@ -251,6 +287,8 @@ declare function checkStripeReturnStatus(sessionId: string, orderNumber: number,
251
287
  /**
252
288
  * Check Tabby payment status after redirect back from Tabby.
253
289
  */
254
- declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks): Promise<void>;
290
+ declare function checkTabbyReturnStatus(orderNumber: number, callbacks: PaymentStatusCallbacks, options?: {
291
+ isPublic?: boolean;
292
+ }): Promise<void>;
255
293
 
256
- export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
294
+ export { type AddressFormValues, type CartTotals, type CouponCallbacks, IP_API_CACHE_KEY, type PaymentCallbacks, type PaymentStatusCallbacks, type PlacementErrorAction, type PlacementErrorInfo, addressFormInitialValues, addressValidationSchema, applyCheckoutCoupon, buildAddressPayload, buildSubmitPayload, calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, clearAddressFormSession, decodeAddress, describePlacementError, encodeAddress, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, isValidPhoneNumber, loadAddressFormFromSession, openRazorpayCheckout, parseEditAddress, processPayment, removeCheckoutCoupon, sanitizePhoneNumber, saveAddressFormToSession };
@@ -1,7 +1,7 @@
1
- export { applyCheckoutCoupon, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, openRazorpayCheckout, processPayment, removeCheckoutCoupon } from '../chunk-5JD6MRVS.js';
1
+ export { applyCheckoutCoupon, fetchAppliedCoupon, fetchAvailableCoupons, handleCODPayment, handlePhonepePayment, handleRazorpayFail, handleRazorpaySuccess, handleStripePayment, handleStripeSuccess, handleTabbyPayment, openRazorpayCheckout, processPayment, removeCheckoutCoupon } from '../chunk-VPTN4YXD.js';
2
2
  import '../chunk-7M5CVYZJ.js';
3
- import { pixelEvents } from '../chunk-WFDKKOO7.js';
4
- import { checkPhonepePaymentStatus, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment } from '../chunk-CHRTGR3G.js';
3
+ import { pixelEvents } from '../chunk-VAU5OL72.js';
4
+ import { checkPhonepePaymentStatusPublic, checkPhonepePaymentStatus, getPublicOrderDetailsByNumber, getOrderDetailsByNumber, getStripePaymentStatusPublic, getStripePaymentStatus, verifyTabbyPayment } from '../chunk-KCLVR6G5.js';
5
5
  export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, sanitizePhoneNumber, saveAddressFormToSession } from '../chunk-ELP23UGF.js';
6
6
  import '../chunk-3SYYP3XV.js';
7
7
  import '../chunk-WEMNXIRS.js';
@@ -44,10 +44,52 @@ function calculateCartTotals(cart) {
44
44
  };
45
45
  }
46
46
 
47
+ // src/checkout/placement-error.ts
48
+ function describePlacementError(error) {
49
+ const code = error?.response?.data?.error_code || error?.response?.data?.code;
50
+ if (["INVALID_SHIPPING_OPTION", "SHIPPING_OPTION_UNAVAILABLE", "SHIPPING_OPTION_REQUIRED"].includes(code)) {
51
+ return {
52
+ code,
53
+ action: "reset-shipping",
54
+ message: "That shipping option is no longer available. Please choose another."
55
+ };
56
+ }
57
+ if (code === "SHIPPING_OPTION_NOT_AVAILABLE_FOR_LOCATION") {
58
+ return {
59
+ code,
60
+ action: "reset-shipping",
61
+ message: "The selected shipping option isn't available for your delivery address."
62
+ };
63
+ }
64
+ if (code === "CART_EMPTY") {
65
+ return { code, action: "none", message: "Your cart is no longer available." };
66
+ }
67
+ if (code === "PREORDER_DIRECT_ONLY") {
68
+ return {
69
+ code,
70
+ action: "none",
71
+ message: "A pre-order product is in your cart. Please remove it and purchase it directly with Pre Order."
72
+ };
73
+ }
74
+ if (["ITEM_UNAVAILABLE", "CHECKOUT_STOCK_ERROR"].includes(code)) {
75
+ return {
76
+ code,
77
+ action: "refresh-preview",
78
+ message: "Some items are no longer available in the requested quantity."
79
+ };
80
+ }
81
+ return {
82
+ code,
83
+ action: "none",
84
+ message: error?.response?.data?.error || "Unable to place your order. Please try again."
85
+ };
86
+ }
87
+
47
88
  // src/checkout/payment-status.ts
48
- async function checkPhonepeReturnStatus(transactionId, callbacks) {
89
+ async function checkPhonepeReturnStatus(transactionId, callbacks, options) {
49
90
  try {
50
- const response = await checkPhonepePaymentStatus(transactionId);
91
+ const checkStatus = options?.isPublic ? checkPhonepePaymentStatusPublic : checkPhonepePaymentStatus;
92
+ const response = await checkStatus(transactionId);
51
93
  if (response.data.success) {
52
94
  callbacks.onSuccess(void 0);
53
95
  } else {
@@ -57,11 +99,13 @@ async function checkPhonepeReturnStatus(transactionId, callbacks) {
57
99
  callbacks.onFailure();
58
100
  }
59
101
  }
60
- async function checkPhonepeReturnStatusWithOrder(transactionId, orderNumber, callbacks) {
102
+ async function checkPhonepeReturnStatusWithOrder(transactionId, orderNumber, callbacks, options) {
61
103
  try {
104
+ const checkStatus = options?.isPublic ? checkPhonepePaymentStatusPublic : checkPhonepePaymentStatus;
105
+ const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
62
106
  const [paymentResponse, orderResponse] = await Promise.all([
63
- checkPhonepePaymentStatus(transactionId),
64
- getOrderDetailsByNumber(orderNumber)
107
+ checkStatus(transactionId),
108
+ getOrder(orderNumber)
65
109
  ]);
66
110
  const order = orderResponse.data;
67
111
  callbacks.onOrderLoaded?.(order);
@@ -83,7 +127,8 @@ async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, c
83
127
  const data = response.data;
84
128
  if (data.payment_status === "paid" || data.status === "complete") {
85
129
  try {
86
- const orderResponse = await getOrderDetailsByNumber(orderNumber);
130
+ const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
131
+ const orderResponse = await getOrder(orderNumber);
87
132
  const order = orderResponse.data;
88
133
  callbacks.onOrderLoaded?.(order);
89
134
  pixelEvents.purchase(order);
@@ -99,20 +144,21 @@ async function checkStripeReturnStatus(sessionId, orderNumber, paymentLinkUrl, c
99
144
  callbacks.onFailure();
100
145
  }
101
146
  }
102
- async function checkTabbyReturnStatus(orderNumber, callbacks) {
147
+ async function checkTabbyReturnStatus(orderNumber, callbacks, options) {
103
148
  try {
104
- const response = await verifyTabbyPayment(orderNumber);
149
+ const getOrder = options?.isPublic ? getPublicOrderDetailsByNumber : getOrderDetailsByNumber;
150
+ const [response, orderResponse] = await Promise.all([
151
+ verifyTabbyPayment(orderNumber),
152
+ getOrder(orderNumber).catch(() => null)
153
+ ]);
154
+ const order = orderResponse?.data;
155
+ if (order) callbacks.onOrderLoaded?.(order);
105
156
  if (response.data.order_status === "paid" || response.data.order_status === "confirmed" || response.data.status === "paid") {
106
- try {
107
- const orderResponse = await getOrderDetailsByNumber(orderNumber);
108
- const order = orderResponse.data;
109
- callbacks.onOrderLoaded?.(order);
157
+ if (order) {
110
158
  pixelEvents.purchase(order);
111
159
  pixelEvents.checkoutCompleted(order);
112
- callbacks.onSuccess(order);
113
- } catch {
114
- callbacks.onSuccess(void 0);
115
160
  }
161
+ callbacks.onSuccess(order ?? void 0);
116
162
  } else {
117
163
  callbacks.onFailure();
118
164
  }
@@ -121,4 +167,4 @@ async function checkTabbyReturnStatus(orderNumber, callbacks) {
121
167
  }
122
168
  }
123
169
 
124
- export { calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus };
170
+ export { calculateCartTotals, checkPhonepeReturnStatus, checkPhonepeReturnStatusWithOrder, checkStripeReturnStatus, checkTabbyReturnStatus, describePlacementError };
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkXFOUNOKO_cjs = require('./chunk-XFOUNOKO.cjs');
4
- var chunkK44JZ5NL_cjs = require('./chunk-K44JZ5NL.cjs');
5
- var chunkRNGQUWQW_cjs = require('./chunk-RNGQUWQW.cjs');
4
+ var chunkNSAHGMS7_cjs = require('./chunk-NSAHGMS7.cjs');
5
+ var chunkH6FJYRO3_cjs = require('./chunk-H6FJYRO3.cjs');
6
6
  var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
7
7
  var axios = require('axios');
8
8
 
9
9
  // src/checkout/payment.ts
10
- function openRazorpayCheckout(order, callbacks) {
10
+ function openRazorpayCheckout(order, callbacks, paymentOptions) {
11
11
  if (!order) return;
12
- chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "razorpay");
12
+ chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "razorpay");
13
13
  const {
14
14
  razorpay_order_id,
15
15
  razorpay_public_token,
@@ -41,7 +41,8 @@ function openRazorpayCheckout(order, callbacks) {
41
41
  payment_id: response.razorpay_payment_id
42
42
  },
43
43
  order,
44
- callbacks
44
+ callbacks,
45
+ paymentOptions
45
46
  );
46
47
  },
47
48
  theme: {
@@ -54,24 +55,35 @@ function openRazorpayCheckout(order, callbacks) {
54
55
  phone: customer_phone
55
56
  },
56
57
  modal: {
57
- ondismiss: () => handleRazorpayFail(order, callbacks, {
58
- description: "User cancelled the payment manually",
59
- reason: "user_cancelled_payment_manually"
60
- })
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
+ )
61
67
  }
62
68
  };
63
69
  const paymentObject = new window.Razorpay(options);
64
70
  paymentObject.on("payment.failed", (response) => {
65
- handleRazorpayFail(order, callbacks, response?.error);
71
+ handleRazorpayFail(order, callbacks, response?.error, {
72
+ isPublic: paymentOptions?.isPublic
73
+ });
66
74
  });
67
75
  paymentObject.open();
68
76
  }
69
- async function handleRazorpaySuccess(data, order, callbacks) {
77
+ async function handleRazorpaySuccess(data, order, callbacks, options) {
70
78
  try {
71
79
  callbacks.onPaymentStart?.();
72
- await chunkRNGQUWQW_cjs.razorpayOrderSuccess(data);
73
- chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
74
- chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
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);
75
87
  callbacks.onCartReset();
76
88
  callbacks.onSuccess(order);
77
89
  } catch {
@@ -80,20 +92,21 @@ async function handleRazorpaySuccess(data, order, callbacks) {
80
92
  callbacks.onPaymentEnd?.();
81
93
  }
82
94
  }
83
- async function handleRazorpayFail(order, callbacks, error) {
95
+ async function handleRazorpayFail(order, callbacks, error, options) {
84
96
  try {
85
- await chunkRNGQUWQW_cjs.razorpayOrderFail({
97
+ const payload = {
86
98
  order_id: order.id,
87
99
  razorpay_order_id: order.razorpay_order_id,
88
100
  error
89
- });
101
+ };
102
+ options?.isPublic ? await chunkH6FJYRO3_cjs.publicRazorpayOrderFailure(payload) : await chunkH6FJYRO3_cjs.razorpayOrderFail(payload);
90
103
  } catch {
91
104
  }
92
105
  callbacks.onFailure(order);
93
106
  }
94
107
  function handlePhonepePayment(order, callbacks) {
95
108
  if (!order) return;
96
- chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "phonepe");
109
+ chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "phonepe");
97
110
  if (!order.phonepe_redirect_url) {
98
111
  callbacks.onFailure(order);
99
112
  return;
@@ -102,7 +115,7 @@ function handlePhonepePayment(order, callbacks) {
102
115
  }
103
116
  function handleTabbyPayment(order, callbacks) {
104
117
  if (!order) return;
105
- chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "tabby");
118
+ chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "tabby");
106
119
  if (!order.tabby_redirect_url) {
107
120
  callbacks.onFailure(order);
108
121
  return;
@@ -113,17 +126,17 @@ async function handleCODPayment(order, callbacks, options) {
113
126
  if (!order) return;
114
127
  try {
115
128
  callbacks.onPaymentStart?.();
116
- chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "cod");
129
+ chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "cod");
117
130
  if (options?.isPublic) {
118
- await chunkRNGQUWQW_cjs.publicMakeCODOrder(order.order_number, {
131
+ await chunkH6FJYRO3_cjs.publicMakeCODOrder(order.order_number, {
119
132
  customer_phone: order.customer_phone,
120
133
  customer_email: order.customer_email
121
134
  });
122
135
  } else {
123
- await chunkRNGQUWQW_cjs.makeCODOrder(order.id);
136
+ await chunkH6FJYRO3_cjs.makeCODOrder(order.id);
124
137
  }
125
- chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
126
- chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
138
+ chunkNSAHGMS7_cjs.pixelEvents.purchase(order);
139
+ chunkNSAHGMS7_cjs.pixelEvents.checkoutCompleted(order);
127
140
  callbacks.onCartReset();
128
141
  callbacks.onSuccess(order);
129
142
  } catch {
@@ -134,7 +147,7 @@ async function handleCODPayment(order, callbacks, options) {
134
147
  }
135
148
  function handleStripePayment(order, callbacks) {
136
149
  if (!order) return;
137
- chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "stripe");
150
+ chunkNSAHGMS7_cjs.pixelEvents.initiateCheckout(order, "stripe");
138
151
  if (order.stripe_payment_link_url) {
139
152
  callbacks.onRedirect(order.stripe_payment_link_url);
140
153
  return;
@@ -145,15 +158,20 @@ function handleStripePayment(order, callbacks) {
145
158
  }
146
159
  callbacks.onFailure(order);
147
160
  }
148
- async function handleStripeSuccess(order, paymentIntentId, callbacks) {
161
+ async function handleStripeSuccess(order, paymentIntentId, callbacks, options) {
149
162
  try {
150
163
  callbacks.onPaymentStart?.();
151
- await chunkRNGQUWQW_cjs.stripeOrderSuccess({
164
+ const stripeSuccessPayload = {
152
165
  order_id: order.id,
153
166
  payment_intent_id: paymentIntentId
154
- });
155
- chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
156
- chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
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);
157
175
  callbacks.onCartReset();
158
176
  callbacks.onSuccess(order);
159
177
  } catch {
@@ -176,7 +194,7 @@ function processPayment(order, paymentMethod, callbacks, options) {
176
194
  return;
177
195
  }
178
196
  if (order.razorpay_public_token) {
179
- openRazorpayCheckout(order, callbacks);
197
+ openRazorpayCheckout(order, callbacks, options);
180
198
  return;
181
199
  }
182
200
  handlePhonepePayment(order, callbacks);
@@ -28,6 +28,7 @@ var urls = {
28
28
  cart: "/checkout/cart",
29
29
  address: "/checkout/address",
30
30
  payment: "/checkout/payment",
31
+ buyNow: "/checkout/buy-now",
31
32
  wishlist: "/wishlist",
32
33
  privacyPolicy: "/privacy-policy",
33
34
  faq: "/faq",
@@ -56,12 +56,44 @@ async function publicPlaceOrder(address, redirect, orderDetails, stripeRedirect,
56
56
  ...orderDetails
57
57
  });
58
58
  }
59
+ async function buyNowPreview(payload) {
60
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/buy_now/preview/", payload);
61
+ }
62
+ async function placeBuyNowOrder(payload) {
63
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/buy_now/", payload);
64
+ }
65
+ async function placeGuestBuyNowOrder(payload) {
66
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/public_order/", payload);
67
+ }
68
+ async function publicCheckoutPreview(payload) {
69
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/public_order/preview/", payload);
70
+ }
71
+ async function placePublicOrder(payload) {
72
+ return chunkECHV2JSY_cjs.http_service_default.post("/customer/public_order/", payload);
73
+ }
59
74
  async function updateOrder(orderDetails) {
60
75
  return chunkECHV2JSY_cjs.http_service_default.patch("/customer/order/", orderDetails);
61
76
  }
62
77
  async function razorpayPublicOrderSuccess(orderDetails) {
63
78
  return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-razorpay-order-success/", orderDetails);
64
79
  }
80
+ async function publicRazorpayOrderFailure(orderDetails) {
81
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-razorpay-order-failure/", orderDetails);
82
+ }
83
+ async function publicPhonepeOrderFailure(payload) {
84
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-phonepe-order-failure/", payload);
85
+ }
86
+ async function phonepePaymentFailure(payload) {
87
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/phonepe-order-failure/", payload);
88
+ }
89
+ async function publicStripeOrderFailure(orderDetails) {
90
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-stripe-order-failure/", orderDetails);
91
+ }
92
+ async function tabbyPaymentFailure(paymentId) {
93
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/tabby-payment-failure/", {
94
+ payment_id: paymentId
95
+ });
96
+ }
65
97
  async function razorpayOrderSuccess(orderDetails) {
66
98
  return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-success/", orderDetails);
67
99
  }
@@ -79,6 +111,11 @@ async function checkPhonepePaymentStatus(transactionId) {
79
111
  params: { phonepe_transaction_id: transactionId }
80
112
  });
81
113
  }
114
+ async function checkPhonepePaymentStatusPublic(transactionId) {
115
+ return chunkECHV2JSY_cjs.http_service_default.get("/payment/public-phonepe-order-success/", {
116
+ params: { phonepe_transaction_id: transactionId }
117
+ });
118
+ }
82
119
  async function getStripePaymentStatus(stripeCheckoutSessionId, order_number, payment_link_id) {
83
120
  return chunkECHV2JSY_cjs.http_service_default.get("/payment/stripe-payment-status/", {
84
121
  params: {
@@ -104,7 +141,7 @@ async function stripeOrderSuccess(orderDetails) {
104
141
  return chunkECHV2JSY_cjs.http_service_default.post("/payment/stripe-order-success/", orderDetails);
105
142
  }
106
143
  async function stripeOrderFail(orderDetails) {
107
- return chunkECHV2JSY_cjs.http_service_default.post("/payment/stripe-order-fail/", orderDetails);
144
+ return chunkECHV2JSY_cjs.http_service_default.post("/payment/stripe-order-failure/", orderDetails);
108
145
  }
109
146
  async function makeCODOrder(orderId) {
110
147
  return chunkECHV2JSY_cjs.http_service_default.post("/customer/order_cod/", { order_id: orderId });
@@ -128,7 +165,9 @@ async function verifyTabbyPayment(orderNumber) {
128
165
  });
129
166
  }
130
167
 
168
+ exports.buyNowPreview = buyNowPreview;
131
169
  exports.checkPhonepePaymentStatus = checkPhonepePaymentStatus;
170
+ exports.checkPhonepePaymentStatusPublic = checkPhonepePaymentStatusPublic;
132
171
  exports.getOrderDetails = getOrderDetails;
133
172
  exports.getOrderDetailsByNumber = getOrderDetailsByNumber;
134
173
  exports.getOrderDetailsByRef = getOrderDetailsByRef;
@@ -140,16 +179,25 @@ exports.getStripePaymentStatus = getStripePaymentStatus;
140
179
  exports.getStripePaymentStatusPublic = getStripePaymentStatusPublic;
141
180
  exports.makeCODOrder = makeCODOrder;
142
181
  exports.phonepeOrderSuccess = phonepeOrderSuccess;
182
+ exports.phonepePaymentFailure = phonepePaymentFailure;
143
183
  exports.phonepePublicOrderSuccess = phonepePublicOrderSuccess;
184
+ exports.placeBuyNowOrder = placeBuyNowOrder;
185
+ exports.placeGuestBuyNowOrder = placeGuestBuyNowOrder;
144
186
  exports.placeOrder = placeOrder;
187
+ exports.placePublicOrder = placePublicOrder;
188
+ exports.publicCheckoutPreview = publicCheckoutPreview;
145
189
  exports.publicMakeCODOrder = publicMakeCODOrder;
190
+ exports.publicPhonepeOrderFailure = publicPhonepeOrderFailure;
146
191
  exports.publicPlaceOrder = publicPlaceOrder;
192
+ exports.publicRazorpayOrderFailure = publicRazorpayOrderFailure;
193
+ exports.publicStripeOrderFailure = publicStripeOrderFailure;
147
194
  exports.razorpayOrderFail = razorpayOrderFail;
148
195
  exports.razorpayOrderSuccess = razorpayOrderSuccess;
149
196
  exports.razorpayPublicOrderSuccess = razorpayPublicOrderSuccess;
150
197
  exports.stripeOrderFail = stripeOrderFail;
151
198
  exports.stripeOrderSuccess = stripeOrderSuccess;
152
199
  exports.stripePublicOrderSuccess = stripePublicOrderSuccess;
200
+ exports.tabbyPaymentFailure = tabbyPaymentFailure;
153
201
  exports.updateOrder = updateOrder;
154
202
  exports.updateOrderCustomization = updateOrderCustomization;
155
203
  exports.uploadCustomizationImage = uploadCustomizationImage;