@sazito/checkout 0.4.3 → 0.4.5
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 +1 -1
- package/dist/chunks/{labels-DxIkDijU.js → labels-Cyryfqd7.js} +16 -30
- package/dist/chunks/labels-Cyryfqd7.js.map +1 -0
- package/dist/chunks/{labels-DlZCs2z3.cjs → labels-DCruUx_W.cjs} +16 -30
- package/dist/chunks/labels-DCruUx_W.cjs.map +1 -0
- package/dist/chunks/{use-checkout-BPcxdj0A.cjs → use-checkout-Bv1EWwHX.cjs} +2 -2
- package/dist/chunks/{use-checkout-BPcxdj0A.cjs.map → use-checkout-Bv1EWwHX.cjs.map} +1 -1
- package/dist/chunks/{use-checkout-tQfM_-7X.js → use-checkout-CNJcOUIZ.js} +2 -2
- package/dist/chunks/{use-checkout-tQfM_-7X.js.map → use-checkout-CNJcOUIZ.js.map} +1 -1
- package/dist/core/index.cjs +2 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +12 -7
- package/dist/core/index.d.ts +12 -7
- package/dist/core/index.js +2 -2
- package/dist/next/index.cjs +6 -5
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +3 -3
- package/dist/next/index.d.ts +3 -3
- package/dist/next/index.js +7 -6
- package/dist/next/index.js.map +1 -1
- package/dist/next/payment-return.cjs +22 -4
- package/dist/next/payment-return.cjs.map +1 -1
- package/dist/next/payment-return.d.cts +9 -4
- package/dist/next/payment-return.d.ts +9 -4
- package/dist/next/payment-return.js +22 -5
- package/dist/next/payment-return.js.map +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/styles.css +130 -12
- package/package.json +1 -1
- package/dist/chunks/labels-DlZCs2z3.cjs.map +0 -1
- package/dist/chunks/labels-DxIkDijU.js.map +0 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod,
|
|
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';
|
|
1
|
+
import { Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod, CheckoutOrder, SazitoClient, CredentialsManager, SazitoResponse, PaymentGateway, ShippingAssignment, CartProduct } from '@sazito/client-sdk';
|
|
2
|
+
export { ApplicableShippingMethods, Cart, CartProduct, CheckoutInvoice, CheckoutInvoiceItem, CheckoutOrder, CheckoutShippingItem, 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.
|
|
@@ -108,6 +108,10 @@ interface CheckoutPaymentReturn {
|
|
|
108
108
|
}
|
|
109
109
|
/** Search-param shape exposed by current Next.js App Router pages. */
|
|
110
110
|
type PaymentReturnSearchParams = Record<string, string | string[] | undefined>;
|
|
111
|
+
interface PaymentReturnParserOptions {
|
|
112
|
+
/** Replace the built-in Sazito gateway-result marker allowlist. */
|
|
113
|
+
gatewayResultMarkers?: readonly string[];
|
|
114
|
+
}
|
|
111
115
|
interface CheckoutConfig {
|
|
112
116
|
locale?: CheckoutLocale;
|
|
113
117
|
direction?: CheckoutDirection;
|
|
@@ -153,7 +157,7 @@ interface ShippingGroup {
|
|
|
153
157
|
}
|
|
154
158
|
interface CheckoutResult {
|
|
155
159
|
status: CheckoutResultStatus;
|
|
156
|
-
order?:
|
|
160
|
+
order?: CheckoutOrder;
|
|
157
161
|
message?: string;
|
|
158
162
|
}
|
|
159
163
|
interface CheckoutError {
|
|
@@ -303,17 +307,18 @@ declare function createBrowserEffectExecutor(config?: CheckoutConfig): CheckoutE
|
|
|
303
307
|
/** A no-op executor for SSR / tests. */
|
|
304
308
|
declare const noopEffectExecutor: CheckoutEffectExecutor;
|
|
305
309
|
|
|
310
|
+
declare const SAZITO_PAYMENT_RESULT_MARKERS: readonly ["mellatpaymentresult", "pecpaymentresult", "uppaymentresult", "seppaymentresult", "vandarpaymentresult", "yourgatepaymentresult", "bazarpaymentresult", "zifypaymentresult", "zibalpaymentresult", "snapppaypaymentresult", "torobpaypaymentresult", "ghestapaypaymentresult", "azkipaymentresult", "digipaypaymentresult", "greenpaypaymentresult", "novapaypaymentresult", "zarinpluspaymentresult", "tomanpaymentresult", "tarapaymentresult", "ozonpaymentresult", "millipaypaymentresult", "ayriapaymentresult", "sadadpaymentresult", "freepaymentresult", "paymentinplaceresult", "cardtocardpaymentresult", "zarinpalpaymentresult", "directpayresult", "paypingpaymentresult", "podpaymentresult", "sabinpaymentresult", "firoozepaymentresult", "technopaypaymentresult", "buywithdigikalaresult"];
|
|
306
311
|
/**
|
|
307
312
|
* Parse Sazito's nested payment callback path into checkout-ready data.
|
|
308
313
|
* Returns undefined for ordinary checkout URLs and malformed callbacks.
|
|
309
314
|
*/
|
|
310
|
-
declare function parsePaymentReturn(segments: readonly string[] | undefined, searchParams?: PaymentReturnSearchParams): CheckoutPaymentReturn | undefined;
|
|
315
|
+
declare function parsePaymentReturn(segments: readonly string[] | undefined, searchParams?: PaymentReturnSearchParams, options?: PaymentReturnParserOptions): CheckoutPaymentReturn | undefined;
|
|
311
316
|
/**
|
|
312
317
|
* Parse a complete checkout URL containing Sazito's nested payment callback.
|
|
313
318
|
* The callback may be mounted below any checkout base path; only its final
|
|
314
319
|
* five path segments are significant.
|
|
315
320
|
*/
|
|
316
|
-
declare function parsePaymentReturnUrl(url: string | URL): CheckoutPaymentReturn | undefined;
|
|
321
|
+
declare function parsePaymentReturnUrl(url: string | URL, options?: PaymentReturnParserOptions): CheckoutPaymentReturn | undefined;
|
|
317
322
|
|
|
318
323
|
/**
|
|
319
324
|
* Typed event bus helpers.
|
|
@@ -528,5 +533,5 @@ declare function selectSummary(invoice: Invoice | null): CheckoutSummary;
|
|
|
528
533
|
/** Items that don't require shipping (digital), for display in the shipping step. */
|
|
529
534
|
declare function selectDigitalItems(invoice: Invoice | null, groups: ShippingGroup[], applicable: ApplicableShippingMethods | null): InvoiceItem[];
|
|
530
535
|
|
|
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 };
|
|
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 };
|
|
536
|
+
export { SAZITO_PAYMENT_RESULT_MARKERS, 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 };
|
|
537
|
+
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, PaymentReturnParserOptions, 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, parsePaymentReturnUrl } 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-Cyryfqd7.js';
|
|
2
|
+
export { SAZITO_PAYMENT_RESULT_MARKERS, 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,8 @@
|
|
|
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-Bv1EWwHX.cjs');
|
|
7
|
+
var labels = require('../chunks/labels-DCruUx_W.cjs');
|
|
8
8
|
var next_paymentReturn = require('./payment-return.cjs');
|
|
9
9
|
require('@sazito/client-sdk');
|
|
10
10
|
|
|
@@ -717,21 +717,22 @@ function ResultStep({ continueShoppingUrl }) {
|
|
|
717
717
|
const order = result?.order;
|
|
718
718
|
const invoice = order?.invoice;
|
|
719
719
|
const showDetails = Boolean(order && (status === 'success' || status === 'pending'));
|
|
720
|
+
const showSummary = invoice?.netTotal != null || invoice?.finalTotal != null;
|
|
721
|
+
const isFailure = status === 'failed' || status === 'stock_violated';
|
|
720
722
|
const titleMap = {
|
|
721
723
|
success: t.paymentSuccess,
|
|
722
724
|
failed: t.paymentFailed,
|
|
723
725
|
pending: t.paymentPending,
|
|
724
726
|
stock_violated: t.paymentFailed
|
|
725
727
|
};
|
|
726
|
-
return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxRuntime.jsxs("div", { className: "szc-result__hero", role:
|
|
728
|
+
return (jsxRuntime.jsxs("section", { className: `szc-result szc-result--${status}${showDetails ? '' : ' szc-result--compact'}`, children: [jsxRuntime.jsxs("div", { className: "szc-result__hero", role: isFailure ? 'alert' : 'status', "aria-live": isFailure ? 'assertive' : 'polite', children: [jsxRuntime.jsx("div", { className: "szc-result__icon", children: jsxRuntime.jsx("span", { className: "szc-result__icon-mark", children: status === 'success' ? (jsxRuntime.jsx(CheckCircle, {})) : status === 'pending' ? (jsxRuntime.jsx(Spinner, {})) : (jsxRuntime.jsx(CrossCircle, {})) }) }), jsxRuntime.jsxs("div", { className: "szc-result__copy", children: [jsxRuntime.jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsxRuntime.jsx("p", { className: "szc-result__hint", children: t.paymentPendingHint }) : null, result?.message ? (jsxRuntime.jsx("p", { className: "szc-result__message", dir: "auto", 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, showSummary ? jsxRuntime.jsxs("dl", { className: "szc-result-summary", children: [invoice.netTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) })) : null, 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, invoice.finalTotal != null ? (jsxRuntime.jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })) : null] }) : null] })) : null] }));
|
|
727
729
|
}
|
|
728
730
|
function formatPublicId(value, locale) {
|
|
729
731
|
const text = String(value);
|
|
730
732
|
return locale === 'fa' ? labels.toPersianDigits(text) : text;
|
|
731
733
|
}
|
|
732
734
|
function formatAttribute(attribute) {
|
|
733
|
-
|
|
734
|
-
return `${attribute.name}: ${value}`;
|
|
735
|
+
return `${attribute.name}: ${attribute.value}`;
|
|
735
736
|
}
|
|
736
737
|
function SummaryRow({ label, value, savings = false, total = false }) {
|
|
737
738
|
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 })] }));
|