@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/next/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ButtonHTMLAttributes, InputHTMLAttributes } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutOrder, Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod } from '@sazito/client-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Checkout domain types.
|
|
@@ -154,7 +154,7 @@ interface ShippingGroup {
|
|
|
154
154
|
}
|
|
155
155
|
interface CheckoutResult {
|
|
156
156
|
status: CheckoutResultStatus;
|
|
157
|
-
order?:
|
|
157
|
+
order?: CheckoutOrder;
|
|
158
158
|
message?: string;
|
|
159
159
|
}
|
|
160
160
|
interface CheckoutError {
|
|
@@ -373,7 +373,7 @@ interface RenderResultProps {
|
|
|
373
373
|
/** Normalized result status. Falls back to `pending` while resolving. */
|
|
374
374
|
status: CheckoutResultStatus;
|
|
375
375
|
/** Finalized order returned by Sazito on a successful payment. */
|
|
376
|
-
order?:
|
|
376
|
+
order?: CheckoutOrder;
|
|
377
377
|
/** Configured destination for the continue-shopping action. */
|
|
378
378
|
continueShoppingUrl?: string;
|
|
379
379
|
/** Return to the payment step after a failed or stock-violated result. */
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, ButtonHTMLAttributes, InputHTMLAttributes } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckoutOrder, Cart, Invoice, ApplicableShippingMethods, InvoiceItem, ShippingRate, PaymentMethod } from '@sazito/client-sdk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Checkout domain types.
|
|
@@ -154,7 +154,7 @@ interface ShippingGroup {
|
|
|
154
154
|
}
|
|
155
155
|
interface CheckoutResult {
|
|
156
156
|
status: CheckoutResultStatus;
|
|
157
|
-
order?:
|
|
157
|
+
order?: CheckoutOrder;
|
|
158
158
|
message?: string;
|
|
159
159
|
}
|
|
160
160
|
interface CheckoutError {
|
|
@@ -373,7 +373,7 @@ interface RenderResultProps {
|
|
|
373
373
|
/** Normalized result status. Falls back to `pending` while resolving. */
|
|
374
374
|
status: CheckoutResultStatus;
|
|
375
375
|
/** Finalized order returned by Sazito on a successful payment. */
|
|
376
|
-
order?:
|
|
376
|
+
order?: CheckoutOrder;
|
|
377
377
|
/** Configured destination for the continue-shopping action. */
|
|
378
378
|
continueShoppingUrl?: string;
|
|
379
379
|
/** Return to the payment step after a failed or stock-violated result. */
|
package/dist/next/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { isValidElement, cloneElement, useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
4
|
-
import { u as useCheckout, b as useSazitoClient, C as CheckoutProvider } from '../chunks/use-checkout-
|
|
5
|
-
export { S as SazitoProvider } from '../chunks/use-checkout-
|
|
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-
|
|
4
|
+
import { u as useCheckout, b as useSazitoClient, C as CheckoutProvider } from '../chunks/use-checkout-CNJcOUIZ.js';
|
|
5
|
+
export { S as SazitoProvider } from '../chunks/use-checkout-CNJcOUIZ.js';
|
|
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-Cyryfqd7.js';
|
|
7
7
|
import { parsePaymentReturnUrl } from './payment-return.js';
|
|
8
8
|
import '@sazito/client-sdk';
|
|
9
9
|
|
|
@@ -716,21 +716,22 @@ function ResultStep({ continueShoppingUrl }) {
|
|
|
716
716
|
const order = result?.order;
|
|
717
717
|
const invoice = order?.invoice;
|
|
718
718
|
const showDetails = Boolean(order && (status === 'success' || status === 'pending'));
|
|
719
|
+
const showSummary = invoice?.netTotal != null || invoice?.finalTotal != null;
|
|
720
|
+
const isFailure = status === 'failed' || status === 'stock_violated';
|
|
719
721
|
const titleMap = {
|
|
720
722
|
success: t.paymentSuccess,
|
|
721
723
|
failed: t.paymentFailed,
|
|
722
724
|
pending: t.paymentPending,
|
|
723
725
|
stock_violated: t.paymentFailed
|
|
724
726
|
};
|
|
725
|
-
return (jsxs("section", { className: `szc-result szc-result--${status}`, children: [jsxs("div", { className: "szc-result__hero", role:
|
|
727
|
+
return (jsxs("section", { className: `szc-result szc-result--${status}${showDetails ? '' : ' szc-result--compact'}`, children: [jsxs("div", { className: "szc-result__hero", role: isFailure ? 'alert' : 'status', "aria-live": isFailure ? 'assertive' : 'polite', children: [jsx("div", { className: "szc-result__icon", children: jsx("span", { className: "szc-result__icon-mark", children: status === 'success' ? (jsx(CheckCircle, {})) : status === 'pending' ? (jsx(Spinner, {})) : (jsx(CrossCircle, {})) }) }), jsxs("div", { className: "szc-result__copy", children: [jsx("h2", { className: "szc-result__title", children: titleMap[status] }), status === 'pending' ? jsx("p", { className: "szc-result__hint", children: t.paymentPendingHint }) : null, result?.message ? (jsx("p", { className: "szc-result__message", dir: "auto", children: result.message })) : null, status === 'success' && order ? (jsx("p", { className: "szc-result__hint", children: t.orderConfirmedHint })) : null] }), order ? (jsxs("dl", { className: "szc-result__reference", children: [jsxs("div", { className: "szc-result__reference-primary", children: [jsx("dt", { children: t.orderNumber }), jsx("dd", { children: formatPublicId(order.orderNumber, state.locale) })] }), jsxs("div", { children: [jsx("dt", { children: t.orderId }), jsx("dd", { children: formatPublicId(order.id, state.locale) })] })] })) : null, jsxs("div", { className: "szc-result__actions", children: [status === 'failed' || status === 'stock_violated' ? (jsx(Button, { onClick: () => actions.goToStep('payment'), children: t.tryAgain })) : null, continueShoppingUrl ? (jsx(Button, { variant: status === 'success' ? 'primary' : 'outline', asChild: true, children: jsx("a", { href: continueShoppingUrl, children: t.continueShopping }) })) : null] })] }), showDetails && order && invoice ? (jsxs("div", { className: "szc-result__details", children: [jsx("h3", { className: "szc-result__details-title", children: t.orderDetails }), invoice.shippingItems.length > 0 ? (jsxs("section", { className: "szc-result__section", "aria-labelledby": "szc-result-shipping-title", children: [jsx("h4", { id: "szc-result-shipping-title", className: "szc-result__section-title", children: t.shippingMethods }), jsx("div", { className: "szc-result-shipping-list", children: invoice.shippingItems.map((shipping) => (jsx("article", { className: "szc-result-group", children: jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: shipping.rate.icon ? jsx("img", { src: shipping.rate.icon, alt: "" }) : jsx(DeliveryIcon, {}) }), jsx("span", { className: "szc-result-group__title", children: shipping.rate.name }), jsx("span", { className: "szc-result-group__price", children: price(shipping.rate.price) })] }) }, String(shipping.id)))) })] })) : null, invoice.invoiceItems.length > 0 ? (jsxs("section", { className: "szc-result-group", "aria-labelledby": "szc-result-items-title", children: [jsxs("header", { className: "szc-result-group__head", children: [jsx("span", { className: "szc-result-group__mark", "aria-hidden": "true", children: jsx(OrderItemsIcon, {}) }), jsx("h4", { id: "szc-result-items-title", className: "szc-result-group__title", children: t.orderItems })] }), jsxs("div", { className: "szc-result-items__head", "aria-hidden": "true", children: [jsx("span", { children: t.product }), jsx("span", { children: t.quantity }), jsx("span", { children: t.lineTotal })] }), jsx("ul", { className: "szc-result-items", children: invoice.invoiceItems.map((item, index) => (jsxs("li", { className: "szc-result-item", children: [jsxs("span", { className: "szc-result-item__product", children: [item.image?.url ? (jsx("img", { className: "szc-result-item__thumb", src: item.image.url, alt: "" })) : (jsx(ProductPlaceholder, { className: "szc-result-item__thumb" })), jsxs("span", { children: [jsx("strong", { children: item.name }), item.variantAttributes.length ? (jsx("small", { children: item.variantAttributes.map(formatAttribute).join(' · ') })) : null] })] }), jsxs("span", { className: "szc-result-item__quantity", children: [jsx("span", { className: "szc-result-item__mobile-label", children: t.quantity }), formatNumber(item.noOfItems, state.locale)] }), jsxs("span", { className: "szc-result-item__total", children: [jsx("span", { className: "szc-result-item__mobile-label", children: t.lineTotal }), money(item.totalItemsPrice)] })] }, `${String(item.productVariantId)}-${index}`))) })] })) : null, showSummary ? jsxs("dl", { className: "szc-result-summary", children: [invoice.netTotal != null ? (jsx(SummaryRow, { label: t.subtotal, value: money(invoice.netTotal) })) : null, invoice.shippingTotal != null ? (jsx(SummaryRow, { label: t.shipping, value: money(invoice.shippingTotal) })) : null, invoice.discountTotal != null && invoice.discountTotal > 0 ? (jsx(SummaryRow, { label: t.discount, value: `−${money(invoice.discountTotal)}` })) : null, invoice.creditTotal != null && invoice.creditTotal > 0 ? (jsx(SummaryRow, { label: t.credit, value: `−${money(invoice.creditTotal)}` })) : null, invoice.vat != null && invoice.vat > 0 ? (jsx(SummaryRow, { label: t.vat, value: money(invoice.vat) })) : null, invoice.customerProfit != null && invoice.customerProfit > 0 ? (jsx(SummaryRow, { label: t.yourSavings, value: money(invoice.customerProfit), savings: true })) : null, invoice.finalTotal != null ? (jsx(SummaryRow, { label: t.total, value: money(invoice.finalTotal), total: true })) : null] }) : null] })) : null] }));
|
|
726
728
|
}
|
|
727
729
|
function formatPublicId(value, locale) {
|
|
728
730
|
const text = String(value);
|
|
729
731
|
return locale === 'fa' ? toPersianDigits(text) : text;
|
|
730
732
|
}
|
|
731
733
|
function formatAttribute(attribute) {
|
|
732
|
-
|
|
733
|
-
return `${attribute.name}: ${value}`;
|
|
734
|
+
return `${attribute.name}: ${attribute.value}`;
|
|
734
735
|
}
|
|
735
736
|
function SummaryRow({ label, value, savings = false, total = false }) {
|
|
736
737
|
return (jsxs("div", { className: `${total ? 'szc-result-summary__total' : ''} ${savings ? 'szc-result-summary__savings' : ''}`.trim(), children: [jsx("dt", { children: label }), jsx("dd", { children: value })] }));
|