@sazito/checkout 0.4.0 → 0.4.2
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 +46 -1
- package/dist/chunks/{labels-CnPllzhT.cjs → labels-DlZCs2z3.cjs} +24 -10
- package/dist/chunks/labels-DlZCs2z3.cjs.map +1 -0
- package/dist/chunks/{labels-e8w4zRbg.js → labels-DxIkDijU.js} +24 -10
- package/dist/chunks/labels-DxIkDijU.js.map +1 -0
- package/dist/chunks/{use-checkout-DPtLgxlA.cjs → use-checkout-BPcxdj0A.cjs} +31 -10
- package/dist/chunks/use-checkout-BPcxdj0A.cjs.map +1 -0
- package/dist/chunks/{use-checkout-BM810__v.js → use-checkout-tQfM_-7X.js} +31 -10
- package/dist/chunks/use-checkout-tQfM_-7X.js.map +1 -0
- package/dist/core/index.cjs +2 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +14 -2
- package/dist/core/index.d.ts +14 -2
- package/dist/core/index.js +2 -2
- package/dist/next/index.cjs +48 -11
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +26 -4
- package/dist/next/index.d.ts +26 -4
- package/dist/next/index.js +49 -12
- 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/dist/react/index.cjs +3 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +3 -2
- package/dist/react/index.js.map +1 -1
- package/dist/styles.css +263 -5
- package/package.json +1 -1
- package/dist/chunks/labels-CnPllzhT.cjs.map +0 -1
- package/dist/chunks/labels-e8w4zRbg.js.map +0 -1
- package/dist/chunks/use-checkout-BM810__v.js.map +0 -1
- package/dist/chunks/use-checkout-DPtLgxlA.cjs.map +0 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod, Order, SazitoClient, CredentialsManager, SazitoResponse, PaymentGateway, ShippingAssignment, CartProduct } from '@sazito/client-sdk';
|
|
2
|
-
export { ApplicableShippingMethods, Cart, CartProduct, Invoice, InvoiceItem, InvoiceShippingAddress, ItemShippingRate, Order, PaymentAction, PaymentGateway, PaymentMethod, ShippingAddress, ShippingAddressInput, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate } from '@sazito/client-sdk';
|
|
2
|
+
export { ApplicableShippingMethods, Cart, CartProduct, Invoice, InvoiceItem, InvoiceShippingAddress, ItemShippingRate, Order, OrderInvoice, OrderInvoiceItem, OrderPublicId, OrderShippingItem, PaymentAction, PaymentGateway, PaymentMethod, ShippingAddress, ShippingAddressInput, ShippingAssignment, ShippingItem, ShippingMethod, ShippingRate } from '@sazito/client-sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checkout domain types.
|
|
@@ -308,6 +308,12 @@ declare const noopEffectExecutor: CheckoutEffectExecutor;
|
|
|
308
308
|
* Returns undefined for ordinary checkout URLs and malformed callbacks.
|
|
309
309
|
*/
|
|
310
310
|
declare function parsePaymentReturn(segments: readonly string[] | undefined, searchParams?: PaymentReturnSearchParams): CheckoutPaymentReturn | undefined;
|
|
311
|
+
/**
|
|
312
|
+
* Parse a complete checkout URL containing Sazito's nested payment callback.
|
|
313
|
+
* The callback may be mounted below any checkout base path; only its final
|
|
314
|
+
* five path segments are significant.
|
|
315
|
+
*/
|
|
316
|
+
declare function parsePaymentReturnUrl(url: string | URL): CheckoutPaymentReturn | undefined;
|
|
311
317
|
|
|
312
318
|
/**
|
|
313
319
|
* Typed event bus helpers.
|
|
@@ -435,6 +441,12 @@ interface Strings {
|
|
|
435
441
|
paymentPending: string;
|
|
436
442
|
paymentPendingHint: string;
|
|
437
443
|
orderNumber: string;
|
|
444
|
+
orderId: string;
|
|
445
|
+
orderConfirmedHint: string;
|
|
446
|
+
orderDetails: string;
|
|
447
|
+
orderItems: string;
|
|
448
|
+
product: string;
|
|
449
|
+
lineTotal: string;
|
|
438
450
|
tryAgain: string;
|
|
439
451
|
loading: string;
|
|
440
452
|
processing: string;
|
|
@@ -516,5 +528,5 @@ declare function selectSummary(invoice: Invoice | null): CheckoutSummary;
|
|
|
516
528
|
/** Items that don't require shipping (digital), for display in the shipping step. */
|
|
517
529
|
declare function selectDigitalItems(invoice: Invoice | null, groups: ShippingGroup[], applicable: ApplicableShippingMethods | null): InvoiceItem[];
|
|
518
530
|
|
|
519
|
-
export { addressFormFromInvoice, buildShippingAssignments, classifyAppliedDiscount, createBrowserEffectExecutor, createCheckoutEngine, createSdkBinding, createStore, defaultCurrencyLabel, deriveShippingGroups, emptyAddressForm, formatMoney, formatNumber, formatPercent, formatPrice, fromSdkError, isAddressComplete, isAddressDirty, isDigitalServiceGroup, isShippingComplete, isValidIranianMobile, isValidIranianPhone, makeError, makeEvent, messageForCode, noopEffectExecutor, normalizeIranianPhone, parsePaymentReturn, paymentMethodInfo, paymentMethodLabel, selectDigitalItems, selectSummary, sortCartItemsNewestFirst, strings, toEnglishDigits, toPersianDigits };
|
|
531
|
+
export { addressFormFromInvoice, buildShippingAssignments, classifyAppliedDiscount, createBrowserEffectExecutor, createCheckoutEngine, createSdkBinding, createStore, defaultCurrencyLabel, deriveShippingGroups, emptyAddressForm, formatMoney, formatNumber, formatPercent, formatPrice, fromSdkError, isAddressComplete, isAddressDirty, isDigitalServiceGroup, isShippingComplete, isValidIranianMobile, isValidIranianPhone, makeError, makeEvent, messageForCode, noopEffectExecutor, normalizeIranianPhone, parsePaymentReturn, parsePaymentReturnUrl, paymentMethodInfo, paymentMethodLabel, selectDigitalItems, selectSummary, sortCartItemsNewestFirst, strings, toEnglishDigits, toPersianDigits };
|
|
520
532
|
export type { AddressFormValues, AppliedDiscount, CheckoutActions, CheckoutCity, CheckoutConfig, CheckoutCredentials, CheckoutDirection, CheckoutEffect, CheckoutEffectExecutor, CheckoutEngine, CheckoutEngineOptions, CheckoutError, CheckoutErrorCode, CheckoutEvent, CheckoutEventName, CheckoutFlags, CheckoutLocale, CheckoutPaymentReturn, CheckoutRegion, CheckoutResult, CheckoutResultStatus, CheckoutSdkBinding, CheckoutState, CheckoutStatus, CheckoutStep, CheckoutSummary, CheckoutTheme, DiscountKind, PaymentMethodInfo, PaymentMethodKind, PaymentReturnSearchParams, ShippingGroup, Store, Strings, SummaryLine, SummaryLineKey };
|
package/dist/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as addressFormFromInvoice, b as buildShippingAssignments, c as classifyAppliedDiscount, d as createBrowserEffectExecutor, e as createCheckoutEngine, f as createSdkBinding, g as createStore, h as defaultCurrencyLabel, i as deriveShippingGroups, j as emptyAddressForm, k as formatMoney, l as formatNumber, m as formatPercent, n as formatPrice, o as fromSdkError, p as isAddressComplete, q as isAddressDirty, r as isDigitalServiceGroup, s as isShippingComplete, t as isValidIranianMobile, u as isValidIranianPhone, v as makeError, w as makeEvent, x as messageForCode, y as noopEffectExecutor, z as normalizeIranianPhone, A as paymentMethodInfo, B as paymentMethodLabel, C as selectDigitalItems, D as selectSummary, E as sortCartItemsNewestFirst, F as strings, G as toEnglishDigits, H as toPersianDigits } from '../chunks/labels-
|
|
2
|
-
export { parsePaymentReturn } from '../next/payment-return.js';
|
|
1
|
+
export { a as addressFormFromInvoice, b as buildShippingAssignments, c as classifyAppliedDiscount, d as createBrowserEffectExecutor, e as createCheckoutEngine, f as createSdkBinding, g as createStore, h as defaultCurrencyLabel, i as deriveShippingGroups, j as emptyAddressForm, k as formatMoney, l as formatNumber, m as formatPercent, n as formatPrice, o as fromSdkError, p as isAddressComplete, q as isAddressDirty, r as isDigitalServiceGroup, s as isShippingComplete, t as isValidIranianMobile, u as isValidIranianPhone, v as makeError, w as makeEvent, x as messageForCode, y as noopEffectExecutor, z as normalizeIranianPhone, A as paymentMethodInfo, B as paymentMethodLabel, C as selectDigitalItems, D as selectSummary, E as sortCartItemsNewestFirst, F as strings, G as toEnglishDigits, H as toPersianDigits } from '../chunks/labels-DxIkDijU.js';
|
|
2
|
+
export { parsePaymentReturn, parsePaymentReturnUrl } from '../next/payment-return.js';
|
|
3
3
|
import '@sazito/client-sdk';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/next/index.cjs
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('react');
|
|
6
|
-
var useCheckout = require('../chunks/use-checkout-
|
|
7
|
-
var labels = require('../chunks/labels-
|
|
6
|
+
var useCheckout = require('../chunks/use-checkout-BPcxdj0A.cjs');
|
|
7
|
+
var labels = require('../chunks/labels-DlZCs2z3.cjs');
|
|
8
|
+
var next_paymentReturn = require('./payment-return.cjs');
|
|
8
9
|
require('@sazito/client-sdk');
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -710,16 +711,29 @@ function PaymentIcon({ kind }) {
|
|
|
710
711
|
}
|
|
711
712
|
|
|
712
713
|
function ResultStep({ continueShoppingUrl }) {
|
|
713
|
-
const { state, actions, t } = useCheckout.useCheckout();
|
|
714
|
+
const { state, actions, money, price, t } = useCheckout.useCheckout();
|
|
714
715
|
const result = state.result;
|
|
715
716
|
const status = result?.status ?? 'pending';
|
|
717
|
+
const order = result?.order;
|
|
718
|
+
const invoice = order?.invoice;
|
|
719
|
+
const showDetails = Boolean(order && (status === 'success' || status === 'pending'));
|
|
716
720
|
const titleMap = {
|
|
717
721
|
success: t.paymentSuccess,
|
|
718
722
|
failed: t.paymentFailed,
|
|
719
723
|
pending: t.paymentPending,
|
|
720
724
|
stock_violated: t.paymentFailed
|
|
721
725
|
};
|
|
722
|
-
return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxRuntime.jsx("div", { className: "szc-result__icon", children: status === 'success' ? (jsxRuntime.jsx(CheckCircle, {})) : status === 'pending' ? (jsxRuntime.jsx(Spinner, {})) : (jsxRuntime.jsx(CrossCircle, {})) }), jsxRuntime.jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsxRuntime.jsx("p", { className: "szc-muted", children: t.paymentPendingHint }) : null, result?.message ? jsxRuntime.jsx("p", { className: "szc-muted", children: result.message }) : null,
|
|
726
|
+
return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxRuntime.jsxs("div", { className: "szc-result__hero", role: "status", "aria-live": "polite", children: [jsxRuntime.jsx("div", { className: "szc-result__icon", children: status === 'success' ? (jsxRuntime.jsx(CheckCircle, {})) : status === 'pending' ? (jsxRuntime.jsx(Spinner, {})) : (jsxRuntime.jsx(CrossCircle, {})) }), jsxRuntime.jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsxRuntime.jsx("p", { className: "szc-muted", children: t.paymentPendingHint }) : null, result?.message ? jsxRuntime.jsx("p", { className: "szc-muted", children: result.message }) : null, status === 'success' && order ? (jsxRuntime.jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null, order ? (jsxRuntime.jsxs("dl", { className: "szc-result__reference", children: [jsxRuntime.jsxs("div", { className: "szc-result__reference-primary", children: [jsxRuntime.jsx("dt", { children: t.orderNumber }), jsxRuntime.jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("dt", { children: t.orderId }), jsxRuntime.jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxRuntime.jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsxRuntime.jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsxRuntime.jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsxRuntime.jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxRuntime.jsxs("div", { className: "szc-result__details", children: [jsxRuntime.jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsxRuntime.jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsxRuntime.jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsxRuntime.jsx("article", { className: "szc-result-group", children: jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsxRuntime.jsx("img", { src: shipping.rate.icon, alt: "" }) : jsxRuntime.jsx(DeliveryIcon, {}) }), jsxRuntime.jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsxRuntime.jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxRuntime.jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxRuntime.jsxs("header", { className: "szc-result-group__head", children: [jsxRuntime.jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsxRuntime.jsx(OrderItemsIcon, {}) }), jsxRuntime.jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxRuntime.jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsxRuntime.jsx("span", { children: t.product }), jsxRuntime.jsx("span", { children: t.quantity }), jsxRuntime.jsx("span", { children: t.lineTotal })] }), jsxRuntime.jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxRuntime.jsxs("li", { className: "szc-result-item", children: [jsxRuntime.jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsxRuntime.jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsxRuntime.jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("strong", { children: item.name }), item.variantAttributes.length ? (jsxRuntime.jsx("small", { children: item.variantAttributes.map(formatAttribute).join(' · ') })) : null] })] }), jsxRuntime.jsxs("span", { className: "szc-result-item__quantity", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.quantity }), labels.formatNumber(item.noOfItems, state.locale)] }), jsxRuntime.jsxs("span", { className: "szc-result-item__total", children: [jsxRuntime.jsx("span", { className: "szc-result-item__mobile-label", children: t.lineTotal }), money(item.totalItemsPrice)] })] }, `${String(item.productVariantId)}-${index}`))) })] })) : null, jsxRuntime.jsxs("dl", { className: "szc-result-summary", children: [jsxRuntime.jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) }), invoice.shippingTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.shipping, value: money(invoice.shippingTotal) })) : null, invoice.discountTotal != null && invoice.discountTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.discount, value: `−${money(invoice.discountTotal)}` })) : null, invoice.creditTotal != null && invoice.creditTotal > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.credit, value: `−${money(invoice.creditTotal)}` })) : null, invoice.vat != null && invoice.vat > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.vat, value: money(invoice.vat) })) : null, invoice.customerProfit != null && invoice.customerProfit > 0 ? (jsxRuntime.jsx(SummaryRow, { label: t.yourSavings, value: money(invoice.customerProfit), savings: true })) : null, jsxRuntime.jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })] })] })) : null] }));
|
|
727
|
+
}
|
|
728
|
+
function formatPublicId(value, locale) {
|
|
729
|
+
const text = String(value);
|
|
730
|
+
return locale === 'fa' ? labels.toPersianDigits(text) : text;
|
|
731
|
+
}
|
|
732
|
+
function formatAttribute(attribute) {
|
|
733
|
+
return `${attribute.name}: ${attribute.value}`;
|
|
734
|
+
}
|
|
735
|
+
function SummaryRow({ label, value, savings = false, total = false }) {
|
|
736
|
+
return (jsxRuntime.jsxs("div", { className: `${total ? 'szc-result-summary__total' : ''} ${savings ? 'szc-result-summary__savings' : ''}`.trim(), children: [jsxRuntime.jsx("dt", { children: label }), jsxRuntime.jsx("dd", { children: value })] }));
|
|
723
737
|
}
|
|
724
738
|
function CheckCircle() {
|
|
725
739
|
return (jsxRuntime.jsxs("svg", { viewBox: "0 0 48 48", width: "48", height: "48", fill: "none", "aria-hidden": "true", children: [jsxRuntime.jsx("circle", { cx: "24", cy: "24", r: "22", stroke: "currentColor", strokeWidth: "2.5" }), jsxRuntime.jsx("path", { d: "M15 24.5l6 6 12-13", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
@@ -727,6 +741,12 @@ function CheckCircle() {
|
|
|
727
741
|
function CrossCircle() {
|
|
728
742
|
return (jsxRuntime.jsxs("svg", { viewBox: "0 0 48 48", width: "48", height: "48", fill: "none", "aria-hidden": "true", children: [jsxRuntime.jsx("circle", { cx: "24", cy: "24", r: "22", stroke: "currentColor", strokeWidth: "2.5" }), jsxRuntime.jsx("path", { d: "M17 17l14 14M31 17L17 31", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" })] }));
|
|
729
743
|
}
|
|
744
|
+
function DeliveryIcon() {
|
|
745
|
+
return (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", width: "22", height: "22", fill: "none", "aria-hidden": "true", children: [jsxRuntime.jsx("path", { d: "M3 6.5h11v10H3zM14 10h3.5l3 3v3.5H14z", stroke: "currentColor", strokeWidth: "1.6", strokeLinejoin: "round" }), jsxRuntime.jsx("circle", { cx: "7", cy: "18", r: "1.75", stroke: "currentColor", strokeWidth: "1.6" }), jsxRuntime.jsx("circle", { cx: "17.5", cy: "18", r: "1.75", stroke: "currentColor", strokeWidth: "1.6" })] }));
|
|
746
|
+
}
|
|
747
|
+
function OrderItemsIcon() {
|
|
748
|
+
return (jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", width: "22", height: "22", fill: "none", "aria-hidden": "true", children: [jsxRuntime.jsx("path", { d: "M5 7.5h14v11H5zM8 7.5V5h8v2.5", stroke: "currentColor", strokeWidth: "1.6", strokeLinejoin: "round" }), jsxRuntime.jsx("path", { d: "M8.5 12h7M8.5 15h5", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })] }));
|
|
749
|
+
}
|
|
730
750
|
|
|
731
751
|
function themeVars(theme) {
|
|
732
752
|
const vars = {};
|
|
@@ -771,10 +791,11 @@ function themeVars(theme) {
|
|
|
771
791
|
function CheckoutLoading({ label }) {
|
|
772
792
|
return (jsxRuntime.jsxs("div", { className: "szc-checkout-loading", role: "status", "aria-live": "polite", children: [jsxRuntime.jsx(Spinner, { className: "szc-checkout-loading__spinner" }), jsxRuntime.jsx("span", { children: label })] }));
|
|
773
793
|
}
|
|
774
|
-
function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButton, renderBackButton, renderEmptyCart, emptyCart, }) {
|
|
794
|
+
function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButton, renderBackButton, renderEmptyCart, renderResult, emptyCart, }) {
|
|
775
795
|
const { state, actions, t, summary, money } = useCheckout.useCheckout();
|
|
776
796
|
const { step, direction, flags, error } = state;
|
|
777
797
|
const isResult = step === 'result';
|
|
798
|
+
const resultStatus = state.result?.status ?? 'pending';
|
|
778
799
|
const bootstrapping = step === 'cart' && !error && (!state.cart || !state.invoice || flags.bootstrapping);
|
|
779
800
|
const emptyCartError = error?.code === 'no_cart';
|
|
780
801
|
const fatal = error && !state.cart && step === 'cart' && !emptyCartError;
|
|
@@ -845,17 +866,33 @@ function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButto
|
|
|
845
866
|
? CardIcon
|
|
846
867
|
: ClipboardIcon;
|
|
847
868
|
const mobileHead = (jsxRuntime.jsxs("div", { className: "szc-mobile-head", children: [footerVisible && backVisible ? (jsxRuntime.jsx("button", { type: "button", className: "szc-mobile-head__back", "aria-label": t.back, onClick: backOnClick, children: jsxRuntime.jsx("svg", { className: "szc-back-arrow", viewBox: "0 0 16 16", width: "18", height: "18", fill: "none", "aria-hidden": "true", children: jsxRuntime.jsx("path", { d: "M9.5 3.5 5 8l4.5 4.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) })) : (jsxRuntime.jsx("span", {})), jsxRuntime.jsxs("span", { className: "szc-mobile-head__title", children: [jsxRuntime.jsx("span", { className: "szc-mobile-head__dot", children: jsxRuntime.jsx(HeadIcon, {}) }), headTitle] }), flowIndex >= 0 ? (jsxRuntime.jsx("span", { className: "szc-mobile-head__count", children: t.stepOf(labels.formatNumber(flowIndex + 1, state.locale), labels.formatNumber(flowSteps.length, state.locale)) })) : (jsxRuntime.jsx("span", {}))] }));
|
|
848
|
-
return (jsxRuntime.jsxs("div", { className: `szc-root${className ? ` ${className}` : ''}`, dir: direction, style: themeVars(theme), children: [mobileHead, jsxRuntime.jsx(Stepper, {}), bootstrapping ? (jsxRuntime.jsx(CheckoutLoading, { label: t.loading })) : fatal ? (jsxRuntime.jsx(ErrorBanner, { message: error.message })) : isResult ? (jsxRuntime.jsx("div", { className: "szc-result-wrap", children:
|
|
869
|
+
return (jsxRuntime.jsxs("div", { className: `szc-root${className ? ` ${className}` : ''}`, dir: direction, style: themeVars(theme), children: [mobileHead, jsxRuntime.jsx(Stepper, {}), bootstrapping ? (jsxRuntime.jsx(CheckoutLoading, { label: t.loading })) : fatal ? (jsxRuntime.jsx(ErrorBanner, { message: error.message })) : isResult ? (jsxRuntime.jsx("div", { className: "szc-result-wrap", children: renderResult ? (renderResult({
|
|
870
|
+
result: state.result,
|
|
871
|
+
status: resultStatus,
|
|
872
|
+
order: state.result?.order,
|
|
873
|
+
continueShoppingUrl,
|
|
874
|
+
onRetry: () => actions.goToStep('payment')
|
|
875
|
+
})) : (jsxRuntime.jsx(ResultStep, { continueShoppingUrl: continueShoppingUrl })) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: `szc-layout${cartEmpty ? ' szc-layout--full' : ''}`, children: [jsxRuntime.jsxs("main", { className: "szc-main", children: [error && !emptyCartError ? jsxRuntime.jsx(ErrorBanner, { message: error.message }) : null, step === 'cart' ? (jsxRuntime.jsx(CartStep, { continueShoppingUrl: continueShoppingUrl, emptyCart: emptyCart, renderEmpty: renderEmptyCart })) : null, step === 'shipping' ? jsxRuntime.jsx(ShippingStep, {}) : null, step === 'payment' ? jsxRuntime.jsx(PaymentStep, {}) : null, actionsVisible && backButtonNode ? (jsxRuntime.jsx("div", { className: "szc-back-row", children: backButtonNode })) : null] }), !cartEmpty ? (jsxRuntime.jsxs("div", { className: "szc-side", children: [jsxRuntime.jsx(OrderSummary, {}), actionsVisible ? jsxRuntime.jsx("div", { className: "szc-side__cta", children: nextButtonNode }) : null] })) : null] }) })), actionsVisible ? (jsxRuntime.jsx("div", { className: "szc-footer-bar", children: jsxRuntime.jsxs("div", { className: "szc-footer", children: [jsxRuntime.jsxs("div", { className: "szc-footer__total", children: [jsxRuntime.jsx("span", { className: "szc-footer__total-label", children: t.total }), jsxRuntime.jsx("span", { className: "szc-footer__total-value", children: money(summary.total) })] }), jsxRuntime.jsx("div", { className: "szc-footer__actions", children: nextButtonNode })] }) })) : null] }));
|
|
849
876
|
}
|
|
850
877
|
|
|
851
|
-
function SazitoCheckoutPage({ credentials, config, paymentReturn, paymentReturnParams, className, renderNextButton, renderBackButton, renderEmptyCart, emptyCart, }) {
|
|
852
|
-
|
|
878
|
+
function SazitoCheckoutPage({ credentials, config, paymentReturn, paymentReturnParams, className, renderNextButton, renderBackButton, renderEmptyCart, renderResult, emptyCart, }) {
|
|
879
|
+
// The explicit server-parsed value remains authoritative. As a fallback,
|
|
880
|
+
// detect Sazito's well-known nested callback in the browser. This prevents a
|
|
881
|
+
// caught callback route from silently booting a fresh checkout when the host
|
|
882
|
+
// forgot to forward its catch-all params.
|
|
883
|
+
const detectedPaymentReturn = paymentReturn == null &&
|
|
884
|
+
paymentReturnParams == null &&
|
|
885
|
+
typeof window !== 'undefined'
|
|
886
|
+
? next_paymentReturn.parsePaymentReturnUrl(window.location.href)
|
|
887
|
+
: undefined;
|
|
888
|
+
const resolvedPaymentReturn = paymentReturn ?? detectedPaymentReturn;
|
|
889
|
+
const returnParams = resolvedPaymentReturn?.params ?? paymentReturnParams;
|
|
853
890
|
const isReturn = returnParams != null;
|
|
854
|
-
const checkoutCredentials =
|
|
855
|
-
? { ...credentials, payment:
|
|
891
|
+
const checkoutCredentials = resolvedPaymentReturn
|
|
892
|
+
? { ...credentials, payment: resolvedPaymentReturn.payment }
|
|
856
893
|
: credentials;
|
|
857
894
|
const client = useCheckout.useSazitoClient();
|
|
858
|
-
return (jsxRuntime.jsxs(useCheckout.CheckoutProvider, { client: client, credentials: checkoutCredentials, config: config, autoStart: !isReturn, children: [returnParams ? jsxRuntime.jsx(ResolveReturn, { params: returnParams }) : null, jsxRuntime.jsx(SazitoCheckout, { theme: config?.theme, continueShoppingUrl: config?.continueShoppingUrl, className: className, renderNextButton: renderNextButton, renderBackButton: renderBackButton, renderEmptyCart: renderEmptyCart, emptyCart: emptyCart })] }));
|
|
895
|
+
return (jsxRuntime.jsxs(useCheckout.CheckoutProvider, { client: client, credentials: checkoutCredentials, config: config, autoStart: !isReturn, children: [returnParams ? jsxRuntime.jsx(ResolveReturn, { params: returnParams }) : null, jsxRuntime.jsx(SazitoCheckout, { theme: config?.theme, continueShoppingUrl: config?.continueShoppingUrl, className: className, renderNextButton: renderNextButton, renderBackButton: renderBackButton, renderEmptyCart: renderEmptyCart, renderResult: renderResult, emptyCart: emptyCart })] }));
|
|
859
896
|
}
|
|
860
897
|
function ResolveReturn({ params }) {
|
|
861
898
|
const { actions } = useCheckout.useCheckout();
|