@sazito/checkout 0.4.3 → 0.4.4
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/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/next/index.cjs +2 -3
- 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 +2 -3
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ polling remain managed by the checkout engine.
|
|
|
209
209
|
|---|---|---|
|
|
210
210
|
| `result` | `CheckoutResult \| null` | Full result, backend message, and optional order |
|
|
211
211
|
| `status` | `success \| failed \| pending \| stock_violated` | Normalized result status |
|
|
212
|
-
| `order` | `
|
|
212
|
+
| `order` | `CheckoutOrder \| undefined` | Finalized order convenience reference |
|
|
213
213
|
| `continueShoppingUrl` | `string \| undefined` | Configured storefront destination |
|
|
214
214
|
| `onRetry` | `() => void` | Return to the payment step |
|
|
215
215
|
|
package/dist/core/index.d.cts
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.
|
|
@@ -153,7 +153,7 @@ interface ShippingGroup {
|
|
|
153
153
|
}
|
|
154
154
|
interface CheckoutResult {
|
|
155
155
|
status: CheckoutResultStatus;
|
|
156
|
-
order?:
|
|
156
|
+
order?: CheckoutOrder;
|
|
157
157
|
message?: string;
|
|
158
158
|
}
|
|
159
159
|
interface CheckoutError {
|
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.
|
|
@@ -153,7 +153,7 @@ interface ShippingGroup {
|
|
|
153
153
|
}
|
|
154
154
|
interface CheckoutResult {
|
|
155
155
|
status: CheckoutResultStatus;
|
|
156
|
-
order?:
|
|
156
|
+
order?: CheckoutOrder;
|
|
157
157
|
message?: string;
|
|
158
158
|
}
|
|
159
159
|
interface CheckoutError {
|
package/dist/next/index.cjs
CHANGED
|
@@ -723,15 +723,14 @@ function ResultStep({ continueShoppingUrl }) {
|
|
|
723
723
|
pending: t.paymentPending,
|
|
724
724
|
stock_violated: t.paymentFailed
|
|
725
725
|
};
|
|
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.
|
|
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
727
|
}
|
|
728
728
|
function formatPublicId(value, locale) {
|
|
729
729
|
const text = String(value);
|
|
730
730
|
return locale === 'fa' ? labels.toPersianDigits(text) : text;
|
|
731
731
|
}
|
|
732
732
|
function formatAttribute(attribute) {
|
|
733
|
-
|
|
734
|
-
return `${attribute.name}: ${value}`;
|
|
733
|
+
return `${attribute.name}: ${attribute.value}`;
|
|
735
734
|
}
|
|
736
735
|
function SummaryRow({ label, value, savings = false, total = false }) {
|
|
737
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 })] }));
|