@sazito/checkout 0.4.0 → 0.4.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/README.md +5 -0
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +7 -1
- package/dist/core/index.d.ts +7 -1
- package/dist/core/index.js +1 -1
- package/dist/next/index.cjs +14 -3
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +14 -3
- package/dist/next/index.js.map +1 -1
- package/dist/next/payment-return.cjs +40 -0
- package/dist/next/payment-return.cjs.map +1 -1
- package/dist/next/payment-return.d.cts +7 -1
- package/dist/next/payment-return.d.ts +7 -1
- package/dist/next/payment-return.js +40 -1
- package/dist/next/payment-return.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { isValidElement, cloneElement, useMemo, useState, useRef, useEffect, use
|
|
|
4
4
|
import { u as useCheckout, b as useSazitoClient, C as CheckoutProvider } from '../chunks/use-checkout-BM810__v.js';
|
|
5
5
|
export { S as SazitoProvider } from '../chunks/use-checkout-BM810__v.js';
|
|
6
6
|
import { m as formatPercent, E as sortCartItemsNewestFirst, H as toPersianDigits, r as isDigitalServiceGroup, t as isValidIranianMobile, z as normalizeIranianPhone, A as paymentMethodInfo, l as formatNumber } from '../chunks/labels-e8w4zRbg.js';
|
|
7
|
+
import { parsePaymentReturnUrl } from './payment-return.js';
|
|
7
8
|
import '@sazito/client-sdk';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -848,10 +849,20 @@ function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButto
|
|
|
848
849
|
}
|
|
849
850
|
|
|
850
851
|
function SazitoCheckoutPage({ credentials, config, paymentReturn, paymentReturnParams, className, renderNextButton, renderBackButton, renderEmptyCart, emptyCart, }) {
|
|
851
|
-
|
|
852
|
+
// The explicit server-parsed value remains authoritative. As a fallback,
|
|
853
|
+
// detect Sazito's well-known nested callback in the browser. This prevents a
|
|
854
|
+
// caught callback route from silently booting a fresh checkout when the host
|
|
855
|
+
// forgot to forward its catch-all params.
|
|
856
|
+
const detectedPaymentReturn = paymentReturn == null &&
|
|
857
|
+
paymentReturnParams == null &&
|
|
858
|
+
typeof window !== 'undefined'
|
|
859
|
+
? parsePaymentReturnUrl(window.location.href)
|
|
860
|
+
: undefined;
|
|
861
|
+
const resolvedPaymentReturn = paymentReturn ?? detectedPaymentReturn;
|
|
862
|
+
const returnParams = resolvedPaymentReturn?.params ?? paymentReturnParams;
|
|
852
863
|
const isReturn = returnParams != null;
|
|
853
|
-
const checkoutCredentials =
|
|
854
|
-
? { ...credentials, payment:
|
|
864
|
+
const checkoutCredentials = resolvedPaymentReturn
|
|
865
|
+
? { ...credentials, payment: resolvedPaymentReturn.payment }
|
|
855
866
|
: credentials;
|
|
856
867
|
const client = useSazitoClient();
|
|
857
868
|
return (jsxs(CheckoutProvider, { client: client, credentials: checkoutCredentials, config: config, autoStart: !isReturn, children: [returnParams ? jsx(ResolveReturn, { params: returnParams }) : null, jsx(SazitoCheckout, { theme: config?.theme, continueShoppingUrl: config?.continueShoppingUrl, className: className, renderNextButton: renderNextButton, renderBackButton: renderBackButton, renderEmptyCart: renderEmptyCart, emptyCart: emptyCart })] }));
|