@cimplify/sdk 0.104.0 → 0.104.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/dist/advanced.d.mts +3 -7
- package/dist/advanced.d.ts +3 -7
- package/dist/advanced.js +23 -23
- package/dist/advanced.mjs +4 -4
- package/dist/{client-BuLcOWLv.d.ts → catalogue-BlQ85Uma.d.mts} +415 -763
- package/dist/{client-D5AoobFc.d.mts → catalogue-C8TqOj9K.d.ts} +415 -763
- package/dist/{payment-g0HFkEDU.d.mts → checkout-BqK9XUz5.d.mts} +3824 -1446
- package/dist/{payment-g0HFkEDU.d.ts → checkout-BqK9XUz5.d.ts} +3824 -1446
- package/dist/{chunk-GOHSXBKW.mjs → chunk-33VCYWVL.mjs} +25 -1
- package/dist/{chunk-2WPVUIHX.mjs → chunk-6G3ANKQA.mjs} +1030 -360
- package/dist/{chunk-E4K2VQDD.js → chunk-BWEIMKLF.js} +541 -16
- package/dist/{chunk-IQFFSKE2.js → chunk-DQEXY542.js} +1345 -746
- package/dist/{chunk-CNN7Z2IP.js → chunk-EV2EVOYS.js} +27 -0
- package/dist/{chunk-YVAEY3VC.js → chunk-HYFA67A7.js} +1034 -364
- package/dist/{chunk-5RT4HYMP.mjs → chunk-L5SNEU2O.mjs} +524 -15
- package/dist/{chunk-4BKOKHE3.js → chunk-RBNBSQI7.mjs} +217 -19
- package/dist/{chunk-H3RATH4B.mjs → chunk-SFUJMS5E.js} +261 -2
- package/dist/{chunk-DYIAX3WI.mjs → chunk-U54CWUUT.mjs} +11 -2
- package/dist/{chunk-OKADBZAI.mjs → chunk-UFOWPN3D.mjs} +808 -574
- package/dist/{chunk-OCCNG6MO.mjs → chunk-V4457OKB.mjs} +1310 -722
- package/dist/{chunk-5BDYDZ4U.js → chunk-WXREIBFW.js} +892 -657
- package/dist/{chunk-7PDEX54K.js → chunk-XAUSDMMZ.js} +13 -3
- package/dist/{client-BVNWjk6W.d.ts → client-DhXeiUrf.d.ts} +2 -2
- package/dist/{client-fM716k7G.d.mts → client-mXiUrV4X.d.mts} +2 -2
- package/dist/{index-BtcoqrY1.d.ts → index-B0AdZvrM.d.mts} +9 -4
- package/dist/{index-D7Tf3v7c.d.mts → index-CK8Nk5uQ.d.ts} +9 -4
- package/dist/index-DPWI5XcU.d.ts +8 -0
- package/dist/index-DVfUh-ci.d.mts +8 -0
- package/dist/index.d.mts +31 -14
- package/dist/index.d.ts +31 -14
- package/dist/index.js +305 -133
- package/dist/index.mjs +6 -6
- package/dist/mock/cli.mjs +1442 -386
- package/dist/mock/library.js +1168 -352
- package/dist/mock/library.mjs +1168 -352
- package/dist/mock/msw.js +1168 -352
- package/dist/mock/msw.mjs +1168 -352
- package/dist/{price-BLIeAb8K.d.ts → price-6hQIIac9.d.ts} +1 -1
- package/dist/{price-Czq_cTC_.d.mts → price-BUDv1rI7.d.mts} +1 -1
- package/dist/react.d.mts +10 -5
- package/dist/react.d.ts +10 -5
- package/dist/react.js +227 -197
- package/dist/react.mjs +90 -60
- package/dist/{server-DKK_D-PP.d.ts → server-DJ0mSs9i.d.mts} +31 -57
- package/dist/{server-BkVhOIwn.d.mts → server-DSTX76Ki.d.ts} +31 -57
- package/dist/server.d.mts +3 -4
- package/dist/server.d.ts +3 -4
- package/dist/server.js +11 -11
- package/dist/server.mjs +5 -5
- package/dist/styles.css +2 -2
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +4 -4
- package/dist/testing/msw.mjs +3 -3
- package/dist/testing/suite.d.mts +5 -6
- package/dist/testing/suite.d.ts +5 -6
- package/dist/testing/suite.js +29 -28
- package/dist/testing/suite.mjs +10 -9
- package/dist/testing.d.mts +2177 -14
- package/dist/testing.d.ts +2177 -14
- package/dist/testing.js +167 -89
- package/dist/testing.mjs +24 -10
- package/dist/utils.d.mts +3 -4
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +35 -31
- package/dist/utils.mjs +2 -2
- package/package.json +9 -9
- package/registry/order-history.json +1 -1
- package/registry/order-summary.json +1 -1
- package/dist/link-D9iSVxt5.d.mts +0 -308
- package/dist/link-D9iSVxt5.d.ts +0 -308
package/dist/react.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayService, serviceBillingMultiplier, PRODUCT_TYPE, BOUNDARY_KIND, resolveGallery, chatMessageCards, RENDER_HINT, displaysGrossPrices, DEFAULT_CDN_BASE_URL } from './chunk-3V4DVXV3.mjs';
|
|
3
3
|
export { getVariantDisplayName } from './chunk-3V4DVXV3.mjs';
|
|
4
|
-
import { chatRealtimeUpdateFromWire, SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-
|
|
4
|
+
import { chatRealtimeUpdateFromWire, SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-UFOWPN3D.mjs';
|
|
5
5
|
import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
|
|
6
6
|
export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
|
|
7
|
-
import {
|
|
8
|
-
import './chunk-
|
|
9
|
-
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-
|
|
10
|
-
import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-
|
|
7
|
+
import { ELEMENT_TYPES, EVENT_TYPES, generateIdempotencyKey, startSignIn } from './chunk-V4457OKB.mjs';
|
|
8
|
+
import { ORDER_TYPE, CHECKOUT_STATUS } from './chunk-33VCYWVL.mjs';
|
|
9
|
+
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-U54CWUUT.mjs';
|
|
10
|
+
import { isSupportedCurrency, ErrorCode, currencyCode, CimplifyError } from './chunk-RBNBSQI7.mjs';
|
|
11
11
|
import './chunk-3G6RQLXK.mjs';
|
|
12
12
|
import React14, { createContext, lazy, memo, Suspense, useMemo, useContext, useRef, useCallback, useState, useEffect, useId, useSyncExternalStore } from 'react';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1494,25 +1494,28 @@ function statusToLabel(status) {
|
|
|
1494
1494
|
if (!status) {
|
|
1495
1495
|
return "";
|
|
1496
1496
|
}
|
|
1497
|
-
if (status ===
|
|
1497
|
+
if (status === CHECKOUT_STATUS.PREPARING) {
|
|
1498
1498
|
return "Preparing checkout";
|
|
1499
1499
|
}
|
|
1500
|
-
if (status ===
|
|
1500
|
+
if (status === CHECKOUT_STATUS.REVIEWING_TERMS) {
|
|
1501
|
+
return "Review updated terms";
|
|
1502
|
+
}
|
|
1503
|
+
if (status === CHECKOUT_STATUS.RECOVERING) {
|
|
1501
1504
|
return "Resuming payment";
|
|
1502
1505
|
}
|
|
1503
|
-
if (status ===
|
|
1506
|
+
if (status === CHECKOUT_STATUS.PROCESSING) {
|
|
1504
1507
|
return "Processing payment";
|
|
1505
1508
|
}
|
|
1506
|
-
if (status ===
|
|
1509
|
+
if (status === CHECKOUT_STATUS.AWAITING_AUTHORIZATION) {
|
|
1507
1510
|
return "Waiting for authorization";
|
|
1508
1511
|
}
|
|
1509
|
-
if (status ===
|
|
1512
|
+
if (status === CHECKOUT_STATUS.POLLING) {
|
|
1510
1513
|
return "Confirming payment";
|
|
1511
1514
|
}
|
|
1512
|
-
if (status ===
|
|
1515
|
+
if (status === CHECKOUT_STATUS.FINALIZING) {
|
|
1513
1516
|
return "Finalizing order";
|
|
1514
1517
|
}
|
|
1515
|
-
if (status ===
|
|
1518
|
+
if (status === CHECKOUT_STATUS.SUCCESS) {
|
|
1516
1519
|
return "Payment complete";
|
|
1517
1520
|
}
|
|
1518
1521
|
return "Payment failed";
|
|
@@ -1521,6 +1524,9 @@ function CimplifyCheckout({
|
|
|
1521
1524
|
client,
|
|
1522
1525
|
businessId,
|
|
1523
1526
|
cartId,
|
|
1527
|
+
intentId,
|
|
1528
|
+
hostedSessionId,
|
|
1529
|
+
initialTerms,
|
|
1524
1530
|
locationId,
|
|
1525
1531
|
linkUrl,
|
|
1526
1532
|
orderTypes,
|
|
@@ -1534,14 +1540,14 @@ function CimplifyCheckout({
|
|
|
1534
1540
|
className
|
|
1535
1541
|
}) {
|
|
1536
1542
|
const resolvedOrderTypes = useMemo(
|
|
1537
|
-
() => orderTypes && orderTypes.length > 0 ? orderTypes : [
|
|
1543
|
+
() => orderTypes && orderTypes.length > 0 ? orderTypes : [ORDER_TYPE.PICKUP, ORDER_TYPE.DELIVERY],
|
|
1538
1544
|
[orderTypes]
|
|
1539
1545
|
);
|
|
1540
1546
|
const resolvedDefaultOrderType = useMemo(() => {
|
|
1541
1547
|
if (defaultOrderType && resolvedOrderTypes.includes(defaultOrderType)) {
|
|
1542
1548
|
return defaultOrderType;
|
|
1543
1549
|
}
|
|
1544
|
-
return resolvedOrderTypes[0] ||
|
|
1550
|
+
return resolvedOrderTypes[0] || ORDER_TYPE.PICKUP;
|
|
1545
1551
|
}, [defaultOrderType, resolvedOrderTypes]);
|
|
1546
1552
|
const [orderType, setOrderType] = useState(resolvedDefaultOrderType);
|
|
1547
1553
|
const [status, setStatus] = useState(null);
|
|
@@ -1567,7 +1573,12 @@ function CimplifyCheckout({
|
|
|
1567
1573
|
displayCurrency: cimplifyCtx.displayCurrency,
|
|
1568
1574
|
convertPrice: cimplifyCtx.convertPrice
|
|
1569
1575
|
};
|
|
1570
|
-
}, [
|
|
1576
|
+
}, [
|
|
1577
|
+
cimplifyCtx?.fxRate,
|
|
1578
|
+
cimplifyCtx?.displayCurrency,
|
|
1579
|
+
cimplifyCtx?.baseCurrency,
|
|
1580
|
+
cimplifyCtx?.convertPrice
|
|
1581
|
+
]);
|
|
1571
1582
|
const fxOptionsRef = useRef(fxOptions);
|
|
1572
1583
|
fxOptionsRef.current = fxOptions;
|
|
1573
1584
|
const resolvedCartRef = useRef(resolvedCart);
|
|
@@ -1580,11 +1591,9 @@ function CimplifyCheckout({
|
|
|
1580
1591
|
onStatusChange?.(nextStatus, context);
|
|
1581
1592
|
}
|
|
1582
1593
|
);
|
|
1583
|
-
const fireError = React14.useEffectEvent(
|
|
1584
|
-
(error)
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
);
|
|
1594
|
+
const fireError = React14.useEffectEvent((error) => {
|
|
1595
|
+
onError?.(error);
|
|
1596
|
+
});
|
|
1588
1597
|
useEffect(() => {
|
|
1589
1598
|
if (!resolvedOrderTypes.includes(orderType)) {
|
|
1590
1599
|
setOrderType(resolvedDefaultOrderType);
|
|
@@ -1602,20 +1611,23 @@ function CimplifyCheckout({
|
|
|
1602
1611
|
let cancelled = false;
|
|
1603
1612
|
async function bootstrap() {
|
|
1604
1613
|
const needsBusinessResolve = !businessId;
|
|
1605
|
-
const needsCartResolve = !cartId;
|
|
1614
|
+
const needsCartResolve = !cartId && !intentId;
|
|
1606
1615
|
if (!needsBusinessResolve && !needsCartResolve) {
|
|
1607
1616
|
if (!cancelled) {
|
|
1608
1617
|
setResolvedBusinessId(businessId || null);
|
|
1609
|
-
setResolvedCartId(cartId || null);
|
|
1618
|
+
setResolvedCartId(intentId ? null : cartId || null);
|
|
1619
|
+
if (intentId) setResolvedCart(null);
|
|
1610
1620
|
setIsInitializing(false);
|
|
1611
1621
|
setErrorMessage(null);
|
|
1612
1622
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1623
|
+
if (!intentId) {
|
|
1624
|
+
client.cart.get().then((cartResult) => {
|
|
1625
|
+
if (!cancelled && cartResult.ok && cartResult.value) {
|
|
1626
|
+
setResolvedCart(cartResult.value);
|
|
1627
|
+
}
|
|
1628
|
+
}).catch(() => {
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1619
1631
|
return;
|
|
1620
1632
|
}
|
|
1621
1633
|
if (!cancelled) {
|
|
@@ -1633,13 +1645,13 @@ function CimplifyCheckout({
|
|
|
1633
1645
|
setResolvedCartId(null);
|
|
1634
1646
|
setErrorMessage(message);
|
|
1635
1647
|
setIsInitializing(false);
|
|
1636
|
-
fireError({ code:
|
|
1648
|
+
fireError({ code: ErrorCode.BUSINESS_ID_REQUIRED, message });
|
|
1637
1649
|
}
|
|
1638
1650
|
return;
|
|
1639
1651
|
}
|
|
1640
1652
|
}
|
|
1641
|
-
let nextCartId = cartId ?? null;
|
|
1642
|
-
if (!nextCartId) {
|
|
1653
|
+
let nextCartId = intentId ? null : cartId ?? null;
|
|
1654
|
+
if (!intentId && !nextCartId) {
|
|
1643
1655
|
const cartResult = await client.cart.get();
|
|
1644
1656
|
if (!cartResult.ok || !cartResult.value?.id || cartResult.value.items.length === 0) {
|
|
1645
1657
|
if (!cancelled) {
|
|
@@ -1648,7 +1660,7 @@ function CimplifyCheckout({
|
|
|
1648
1660
|
setResolvedCartId(null);
|
|
1649
1661
|
setErrorMessage(message);
|
|
1650
1662
|
setIsInitializing(false);
|
|
1651
|
-
fireError({ code:
|
|
1663
|
+
fireError({ code: ErrorCode.CART_EMPTY, message });
|
|
1652
1664
|
}
|
|
1653
1665
|
return;
|
|
1654
1666
|
}
|
|
@@ -1668,7 +1680,7 @@ function CimplifyCheckout({
|
|
|
1668
1680
|
return () => {
|
|
1669
1681
|
cancelled = true;
|
|
1670
1682
|
};
|
|
1671
|
-
}, [businessId, cartId, client]);
|
|
1683
|
+
}, [businessId, cartId, client, intentId]);
|
|
1672
1684
|
useEffect(() => {
|
|
1673
1685
|
return () => {
|
|
1674
1686
|
isMountedRef.current = false;
|
|
@@ -1677,31 +1689,36 @@ function CimplifyCheckout({
|
|
|
1677
1689
|
};
|
|
1678
1690
|
}, []);
|
|
1679
1691
|
const handleSubmit = React14.useEffectEvent(async () => {
|
|
1680
|
-
if (isSubmitting || isInitializing || !resolvedCartId) {
|
|
1681
|
-
if (!resolvedCartId && !isInitializing) {
|
|
1682
|
-
const message = "
|
|
1692
|
+
if (isSubmitting || isInitializing || !resolvedCartId && !intentId) {
|
|
1693
|
+
if (!resolvedCartId && !intentId && !isInitializing) {
|
|
1694
|
+
const message = "A cart or purchase intent is required before checkout.";
|
|
1683
1695
|
setErrorMessage(message);
|
|
1684
|
-
fireError({ code:
|
|
1696
|
+
fireError({ code: ErrorCode.CHECKOUT_AUTHORITY_REQUIRED, message });
|
|
1685
1697
|
}
|
|
1686
1698
|
return;
|
|
1687
1699
|
}
|
|
1688
1700
|
setErrorMessage(null);
|
|
1689
1701
|
setIsSubmitting(true);
|
|
1690
|
-
emitStatus(
|
|
1702
|
+
emitStatus(CHECKOUT_STATUS.PREPARING, {
|
|
1703
|
+
display_text: statusToLabel(CHECKOUT_STATUS.PREPARING)
|
|
1704
|
+
});
|
|
1691
1705
|
if (!elementsRef.current) {
|
|
1692
1706
|
const message = "Checkout is still initializing. Please try again.";
|
|
1693
1707
|
setErrorMessage(message);
|
|
1694
|
-
fireError({ code:
|
|
1708
|
+
fireError({ code: ErrorCode.CHECKOUT_NOT_READY, message });
|
|
1695
1709
|
setIsSubmitting(false);
|
|
1696
1710
|
return;
|
|
1697
1711
|
}
|
|
1698
1712
|
const checkout = elementsRef.current.processCheckout({
|
|
1699
|
-
cart_id: resolvedCartId,
|
|
1713
|
+
cart_id: intentId ? void 0 : resolvedCartId ?? void 0,
|
|
1714
|
+
intent_id: intentId,
|
|
1715
|
+
hosted_session_id: hostedSessionId,
|
|
1716
|
+
initial_terms: initialTerms,
|
|
1700
1717
|
location_id: locationId ?? client.getLocationId() ?? void 0,
|
|
1701
1718
|
order_type: orderType,
|
|
1702
1719
|
enroll_in_link: enrollInLink,
|
|
1703
1720
|
on_status_change: emitStatus,
|
|
1704
|
-
pay_currency: fxOptions?.displayCurrency
|
|
1721
|
+
pay_currency: intentId ? void 0 : fxOptions?.displayCurrency
|
|
1705
1722
|
});
|
|
1706
1723
|
activeCheckoutRef.current = checkout;
|
|
1707
1724
|
try {
|
|
@@ -1710,7 +1727,7 @@ function CimplifyCheckout({
|
|
|
1710
1727
|
onComplete(result);
|
|
1711
1728
|
return;
|
|
1712
1729
|
}
|
|
1713
|
-
const code = result.error?.code ||
|
|
1730
|
+
const code = result.error?.code || ErrorCode.CHECKOUT_FAILED;
|
|
1714
1731
|
const message = result.error?.message || "Payment failed.";
|
|
1715
1732
|
setErrorMessage(message);
|
|
1716
1733
|
fireError({ code, message });
|
|
@@ -1731,27 +1748,30 @@ function CimplifyCheckout({
|
|
|
1731
1748
|
linkUrl
|
|
1732
1749
|
});
|
|
1733
1750
|
elementsRef.current = elements;
|
|
1734
|
-
const checkout = elements.create(
|
|
1751
|
+
const checkout = elements.create(ELEMENT_TYPES.CHECKOUT, {
|
|
1735
1752
|
orderTypes: resolvedOrderTypes,
|
|
1736
1753
|
defaultOrderType: resolvedDefaultOrderType,
|
|
1737
|
-
submitLabel
|
|
1754
|
+
submitLabel,
|
|
1755
|
+
intentId,
|
|
1756
|
+
hostedSessionId,
|
|
1757
|
+
initialTerms
|
|
1738
1758
|
});
|
|
1739
1759
|
if (checkoutMountRef.current) {
|
|
1740
1760
|
checkout.mount(checkoutMountRef.current);
|
|
1741
1761
|
}
|
|
1742
|
-
checkout.on(
|
|
1762
|
+
checkout.on(EVENT_TYPES.READY, () => {
|
|
1743
1763
|
const cart = resolvedCartRef.current;
|
|
1744
1764
|
if (cart) {
|
|
1745
1765
|
checkout.setCart(transformToCheckoutCart(cart, fxOptionsRef.current));
|
|
1746
1766
|
}
|
|
1747
1767
|
});
|
|
1748
|
-
checkout.on(
|
|
1768
|
+
checkout.on(EVENT_TYPES.ORDER_TYPE_CHANGED, (data) => {
|
|
1749
1769
|
const typed = data;
|
|
1750
1770
|
if (typed.orderType) {
|
|
1751
1771
|
setOrderType(typed.orderType);
|
|
1752
1772
|
}
|
|
1753
1773
|
});
|
|
1754
|
-
checkout.on(
|
|
1774
|
+
checkout.on(EVENT_TYPES.REQUEST_SUBMIT, () => {
|
|
1755
1775
|
void handleSubmit();
|
|
1756
1776
|
});
|
|
1757
1777
|
return () => {
|
|
@@ -1765,11 +1785,14 @@ function CimplifyCheckout({
|
|
|
1765
1785
|
resolvedBusinessId,
|
|
1766
1786
|
resolvedOrderTypes,
|
|
1767
1787
|
resolvedDefaultOrderType,
|
|
1768
|
-
submitLabel
|
|
1788
|
+
submitLabel,
|
|
1789
|
+
intentId,
|
|
1790
|
+
hostedSessionId,
|
|
1791
|
+
initialTerms
|
|
1769
1792
|
]);
|
|
1770
1793
|
useEffect(() => {
|
|
1771
1794
|
if (!resolvedCart || !elementsRef.current) return;
|
|
1772
|
-
const checkoutElement = elementsRef.current.getElement(
|
|
1795
|
+
const checkoutElement = elementsRef.current.getElement(ELEMENT_TYPES.CHECKOUT);
|
|
1773
1796
|
if (checkoutElement) {
|
|
1774
1797
|
checkoutElement.setCart(transformToCheckoutCart(resolvedCart, fxOptions));
|
|
1775
1798
|
}
|
|
@@ -1778,7 +1801,7 @@ function CimplifyCheckout({
|
|
|
1778
1801
|
if (isInitializing) {
|
|
1779
1802
|
return /* @__PURE__ */ jsx("div", { className, "data-cimplify-checkout": "", children: /* @__PURE__ */ jsx("p", { "data-cimplify-status": "", style: { fontSize: 13, color: colors.textSecondary }, children: "Preparing checkout..." }) });
|
|
1780
1803
|
}
|
|
1781
|
-
if (!resolvedBusinessId || !resolvedCartId) {
|
|
1804
|
+
if (!resolvedBusinessId || !resolvedCartId && !intentId) {
|
|
1782
1805
|
return /* @__PURE__ */ jsx("div", { className, "data-cimplify-checkout": "", children: /* @__PURE__ */ jsx("p", { "data-cimplify-error": "", style: { fontSize: 13, color: colors.error }, children: errorMessage || "Unable to initialize checkout. Please refresh and try again." }) });
|
|
1783
1806
|
}
|
|
1784
1807
|
return /* @__PURE__ */ jsxs("div", { className, "data-cimplify-checkout": "", children: [
|
|
@@ -1796,7 +1819,14 @@ function CimplifyCheckout({
|
|
|
1796
1819
|
}
|
|
1797
1820
|
),
|
|
1798
1821
|
/* @__PURE__ */ jsx("div", { "data-cimplify-section": "checkout", children: /* @__PURE__ */ jsx("div", { ref: checkoutMountRef }) }),
|
|
1799
|
-
status && /* @__PURE__ */ jsx(
|
|
1822
|
+
status && /* @__PURE__ */ jsx(
|
|
1823
|
+
"p",
|
|
1824
|
+
{
|
|
1825
|
+
"data-cimplify-status": "",
|
|
1826
|
+
style: { marginTop: 8, fontSize: 13, color: colors.textSecondary },
|
|
1827
|
+
children: statusText || statusToLabel(status)
|
|
1828
|
+
}
|
|
1829
|
+
),
|
|
1800
1830
|
errorMessage && /* @__PURE__ */ jsx("p", { "data-cimplify-error": "", style: { marginTop: 8, fontSize: 13, color: colors.error }, children: errorMessage })
|
|
1801
1831
|
] });
|
|
1802
1832
|
}
|
|
@@ -3288,8 +3318,7 @@ var STATUS_TONE2 = {
|
|
|
3288
3318
|
picked_up: "positive",
|
|
3289
3319
|
served: "positive",
|
|
3290
3320
|
completed: "positive",
|
|
3291
|
-
cancelled: "muted"
|
|
3292
|
-
refunded: "muted"
|
|
3321
|
+
cancelled: "muted"
|
|
3293
3322
|
};
|
|
3294
3323
|
var PAYMENT_TONE = {
|
|
3295
3324
|
paid: "positive",
|
|
@@ -4589,9 +4618,12 @@ function useCategories(options = {}) {
|
|
|
4589
4618
|
const { data, isLoading, error, refetch } = categoriesQuery(options);
|
|
4590
4619
|
return { categories: data ?? [], isLoading, error, refetch };
|
|
4591
4620
|
}
|
|
4592
|
-
var TERMINAL_STATUSES =
|
|
4621
|
+
var TERMINAL_STATUSES = {
|
|
4622
|
+
completed: true,
|
|
4623
|
+
cancelled: true
|
|
4624
|
+
};
|
|
4593
4625
|
function isTerminalOrderStatus(status) {
|
|
4594
|
-
return
|
|
4626
|
+
return Object.prototype.hasOwnProperty.call(TERMINAL_STATUSES, status);
|
|
4595
4627
|
}
|
|
4596
4628
|
var orderCache = /* @__PURE__ */ new Map();
|
|
4597
4629
|
var orderInflight = /* @__PURE__ */ new Map();
|
|
@@ -4684,7 +4716,7 @@ function useOrder(orderId, options = {}) {
|
|
|
4684
4716
|
useEffect(() => {
|
|
4685
4717
|
void load(false);
|
|
4686
4718
|
}, [load]);
|
|
4687
|
-
const isTerminal = order ?
|
|
4719
|
+
const isTerminal = order ? isTerminalOrderStatus(order.status) : false;
|
|
4688
4720
|
useEffect(() => {
|
|
4689
4721
|
if (!poll || !enabled || normalizedOrderId.length === 0 || isTerminal) {
|
|
4690
4722
|
return;
|
|
@@ -13475,8 +13507,7 @@ var STATUS_LABELS = {
|
|
|
13475
13507
|
delivered: "Delivered",
|
|
13476
13508
|
picked_up: "Picked Up",
|
|
13477
13509
|
completed: "Completed",
|
|
13478
|
-
cancelled: "Cancelled"
|
|
13479
|
-
refunded: "Refunded"
|
|
13510
|
+
cancelled: "Cancelled"
|
|
13480
13511
|
};
|
|
13481
13512
|
var PAYMENT_STATE_LABELS = {
|
|
13482
13513
|
not_paid: "Not Paid",
|
|
@@ -13688,8 +13719,7 @@ var STATUS_LABELS2 = {
|
|
|
13688
13719
|
delivered: "Delivered",
|
|
13689
13720
|
picked_up: "Picked Up",
|
|
13690
13721
|
completed: "Completed",
|
|
13691
|
-
cancelled: "Cancelled"
|
|
13692
|
-
refunded: "Refunded"
|
|
13722
|
+
cancelled: "Cancelled"
|
|
13693
13723
|
};
|
|
13694
13724
|
function OrderHistory({
|
|
13695
13725
|
orders: ordersProp,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { dH as ProductInputField, e3 as PurchaseIntentView, cx as MintPurchaseIntentRequest, bc as ConfirmPurchaseIntentResponse, el as SubmitAuthorizationInput, ab as CHECKOUT_NEXT_ACTION, i as ConfirmPurchaseIntentRequest, em as SubmitPurchaseIntentActionRequest } from './checkout-BqK9XUz5.mjs';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -71,6 +71,7 @@ interface Session {
|
|
|
71
71
|
id: string;
|
|
72
72
|
token: string;
|
|
73
73
|
business_id: string;
|
|
74
|
+
account_id?: string;
|
|
74
75
|
customer_id?: string;
|
|
75
76
|
customer_name?: string;
|
|
76
77
|
customer_email?: string;
|
|
@@ -296,6 +297,17 @@ interface MockOrder {
|
|
|
296
297
|
created_at: string;
|
|
297
298
|
updated_at: string;
|
|
298
299
|
}
|
|
300
|
+
interface MockPurchaseIntent extends PurchaseIntentView {
|
|
301
|
+
intent_owner: {
|
|
302
|
+
kind: "account";
|
|
303
|
+
id: string;
|
|
304
|
+
} | {
|
|
305
|
+
kind: "storefront_session";
|
|
306
|
+
id: string;
|
|
307
|
+
};
|
|
308
|
+
mint_request: MintPurchaseIntentRequest;
|
|
309
|
+
last_confirmation?: ConfirmPurchaseIntentResponse;
|
|
310
|
+
}
|
|
299
311
|
interface MockSubscription {
|
|
300
312
|
id: string;
|
|
301
313
|
business_id: string;
|
|
@@ -552,6 +564,7 @@ interface StateRegistry {
|
|
|
552
564
|
collections: Store<MockCollection>;
|
|
553
565
|
carts: Store<MockCart>;
|
|
554
566
|
orders: Store<MockOrder>;
|
|
567
|
+
purchaseIntents: Store<MockPurchaseIntent>;
|
|
555
568
|
subscriptions: Store<MockSubscription>;
|
|
556
569
|
bookings: Store<MockBooking>;
|
|
557
570
|
services: Store<MockService>;
|
|
@@ -730,67 +743,27 @@ interface CartService {
|
|
|
730
743
|
resolveCart(session: Session): MockCart;
|
|
731
744
|
}
|
|
732
745
|
|
|
733
|
-
interface
|
|
734
|
-
process(session: Session, body: CheckoutBody): CheckoutResult;
|
|
735
|
-
authorize(body: SubmitAuthorizationInput): CheckoutResult;
|
|
736
|
-
}
|
|
737
|
-
interface CheckoutBody {
|
|
738
|
-
cart_id: string;
|
|
739
|
-
location_id?: string;
|
|
740
|
-
customer: {
|
|
741
|
-
name: string;
|
|
742
|
-
email: string;
|
|
743
|
-
phone: string;
|
|
744
|
-
notes?: string;
|
|
745
|
-
save_details?: boolean;
|
|
746
|
-
};
|
|
747
|
-
order_type: string;
|
|
748
|
-
address_info?: Record<string, unknown>;
|
|
749
|
-
payment_method: string;
|
|
750
|
-
mobile_money_details?: {
|
|
751
|
-
phone_number: string;
|
|
752
|
-
provider: string;
|
|
753
|
-
};
|
|
754
|
-
special_instructions?: string;
|
|
755
|
-
metadata?: Record<string, unknown>;
|
|
756
|
-
pay_currency?: string;
|
|
757
|
-
fx_quote_id?: string;
|
|
758
|
-
}
|
|
759
|
-
interface CheckoutResult {
|
|
746
|
+
interface MockPaymentResult {
|
|
760
747
|
order_id: string;
|
|
761
748
|
order_number: string;
|
|
762
|
-
payment_id
|
|
763
|
-
payment_status: string;
|
|
749
|
+
payment_id: string;
|
|
764
750
|
payment_reference?: string;
|
|
751
|
+
payment_status: string;
|
|
765
752
|
requires_authorization: boolean;
|
|
766
|
-
authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
|
|
767
753
|
next_action: {
|
|
768
|
-
type:
|
|
769
|
-
} | {
|
|
770
|
-
type: "card_popup";
|
|
771
|
-
provider: string;
|
|
772
|
-
client_secret: string;
|
|
773
|
-
public_key: string;
|
|
774
|
-
provider_account_id?: string;
|
|
775
|
-
} | {
|
|
776
|
-
type: "redirect";
|
|
777
|
-
authorization_url: string;
|
|
778
|
-
} | {
|
|
779
|
-
type: "authorization";
|
|
780
|
-
authorization_type: string;
|
|
781
|
-
display_text?: string;
|
|
782
|
-
} | {
|
|
783
|
-
type: "poll";
|
|
754
|
+
type: typeof CHECKOUT_NEXT_ACTION.NONE;
|
|
784
755
|
};
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
756
|
+
}
|
|
757
|
+
interface PaymentService {
|
|
758
|
+
authorize(body: SubmitAuthorizationInput): MockPaymentResult;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
interface PurchaseIntentMockService {
|
|
762
|
+
mint(session: Session, request: MintPurchaseIntentRequest): PurchaseIntentView;
|
|
763
|
+
get(session: Session, intentId: string): PurchaseIntentView;
|
|
764
|
+
refresh(session: Session, intentId: string, expectedRevision: number): PurchaseIntentView;
|
|
765
|
+
confirm(session: Session, intentId: string, request: ConfirmPurchaseIntentRequest): ConfirmPurchaseIntentResponse;
|
|
766
|
+
submitAction(session: Session, intentId: string, attemptId: string, request: SubmitPurchaseIntentActionRequest): ConfirmPurchaseIntentResponse;
|
|
794
767
|
}
|
|
795
768
|
|
|
796
769
|
interface OrderService {
|
|
@@ -1248,7 +1221,8 @@ interface Deps {
|
|
|
1248
1221
|
business: BusinessService;
|
|
1249
1222
|
catalogue: CatalogueService;
|
|
1250
1223
|
cart: CartService;
|
|
1251
|
-
|
|
1224
|
+
payments: PaymentService;
|
|
1225
|
+
purchaseIntents: PurchaseIntentMockService;
|
|
1252
1226
|
orders: OrderService;
|
|
1253
1227
|
subscriptions: SubscriptionService;
|
|
1254
1228
|
scheduling: SchedulingService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import {
|
|
2
|
+
import { dH as ProductInputField, e3 as PurchaseIntentView, cx as MintPurchaseIntentRequest, bc as ConfirmPurchaseIntentResponse, el as SubmitAuthorizationInput, ab as CHECKOUT_NEXT_ACTION, i as ConfirmPurchaseIntentRequest, em as SubmitPurchaseIntentActionRequest } from './checkout-BqK9XUz5.js';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -71,6 +71,7 @@ interface Session {
|
|
|
71
71
|
id: string;
|
|
72
72
|
token: string;
|
|
73
73
|
business_id: string;
|
|
74
|
+
account_id?: string;
|
|
74
75
|
customer_id?: string;
|
|
75
76
|
customer_name?: string;
|
|
76
77
|
customer_email?: string;
|
|
@@ -296,6 +297,17 @@ interface MockOrder {
|
|
|
296
297
|
created_at: string;
|
|
297
298
|
updated_at: string;
|
|
298
299
|
}
|
|
300
|
+
interface MockPurchaseIntent extends PurchaseIntentView {
|
|
301
|
+
intent_owner: {
|
|
302
|
+
kind: "account";
|
|
303
|
+
id: string;
|
|
304
|
+
} | {
|
|
305
|
+
kind: "storefront_session";
|
|
306
|
+
id: string;
|
|
307
|
+
};
|
|
308
|
+
mint_request: MintPurchaseIntentRequest;
|
|
309
|
+
last_confirmation?: ConfirmPurchaseIntentResponse;
|
|
310
|
+
}
|
|
299
311
|
interface MockSubscription {
|
|
300
312
|
id: string;
|
|
301
313
|
business_id: string;
|
|
@@ -552,6 +564,7 @@ interface StateRegistry {
|
|
|
552
564
|
collections: Store<MockCollection>;
|
|
553
565
|
carts: Store<MockCart>;
|
|
554
566
|
orders: Store<MockOrder>;
|
|
567
|
+
purchaseIntents: Store<MockPurchaseIntent>;
|
|
555
568
|
subscriptions: Store<MockSubscription>;
|
|
556
569
|
bookings: Store<MockBooking>;
|
|
557
570
|
services: Store<MockService>;
|
|
@@ -730,67 +743,27 @@ interface CartService {
|
|
|
730
743
|
resolveCart(session: Session): MockCart;
|
|
731
744
|
}
|
|
732
745
|
|
|
733
|
-
interface
|
|
734
|
-
process(session: Session, body: CheckoutBody): CheckoutResult;
|
|
735
|
-
authorize(body: SubmitAuthorizationInput): CheckoutResult;
|
|
736
|
-
}
|
|
737
|
-
interface CheckoutBody {
|
|
738
|
-
cart_id: string;
|
|
739
|
-
location_id?: string;
|
|
740
|
-
customer: {
|
|
741
|
-
name: string;
|
|
742
|
-
email: string;
|
|
743
|
-
phone: string;
|
|
744
|
-
notes?: string;
|
|
745
|
-
save_details?: boolean;
|
|
746
|
-
};
|
|
747
|
-
order_type: string;
|
|
748
|
-
address_info?: Record<string, unknown>;
|
|
749
|
-
payment_method: string;
|
|
750
|
-
mobile_money_details?: {
|
|
751
|
-
phone_number: string;
|
|
752
|
-
provider: string;
|
|
753
|
-
};
|
|
754
|
-
special_instructions?: string;
|
|
755
|
-
metadata?: Record<string, unknown>;
|
|
756
|
-
pay_currency?: string;
|
|
757
|
-
fx_quote_id?: string;
|
|
758
|
-
}
|
|
759
|
-
interface CheckoutResult {
|
|
746
|
+
interface MockPaymentResult {
|
|
760
747
|
order_id: string;
|
|
761
748
|
order_number: string;
|
|
762
|
-
payment_id
|
|
763
|
-
payment_status: string;
|
|
749
|
+
payment_id: string;
|
|
764
750
|
payment_reference?: string;
|
|
751
|
+
payment_status: string;
|
|
765
752
|
requires_authorization: boolean;
|
|
766
|
-
authorization_type?: "otp" | "pin" | "phone" | "birthday" | "address";
|
|
767
753
|
next_action: {
|
|
768
|
-
type:
|
|
769
|
-
} | {
|
|
770
|
-
type: "card_popup";
|
|
771
|
-
provider: string;
|
|
772
|
-
client_secret: string;
|
|
773
|
-
public_key: string;
|
|
774
|
-
provider_account_id?: string;
|
|
775
|
-
} | {
|
|
776
|
-
type: "redirect";
|
|
777
|
-
authorization_url: string;
|
|
778
|
-
} | {
|
|
779
|
-
type: "authorization";
|
|
780
|
-
authorization_type: string;
|
|
781
|
-
display_text?: string;
|
|
782
|
-
} | {
|
|
783
|
-
type: "poll";
|
|
754
|
+
type: typeof CHECKOUT_NEXT_ACTION.NONE;
|
|
784
755
|
};
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
756
|
+
}
|
|
757
|
+
interface PaymentService {
|
|
758
|
+
authorize(body: SubmitAuthorizationInput): MockPaymentResult;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
interface PurchaseIntentMockService {
|
|
762
|
+
mint(session: Session, request: MintPurchaseIntentRequest): PurchaseIntentView;
|
|
763
|
+
get(session: Session, intentId: string): PurchaseIntentView;
|
|
764
|
+
refresh(session: Session, intentId: string, expectedRevision: number): PurchaseIntentView;
|
|
765
|
+
confirm(session: Session, intentId: string, request: ConfirmPurchaseIntentRequest): ConfirmPurchaseIntentResponse;
|
|
766
|
+
submitAction(session: Session, intentId: string, attemptId: string, request: SubmitPurchaseIntentActionRequest): ConfirmPurchaseIntentResponse;
|
|
794
767
|
}
|
|
795
768
|
|
|
796
769
|
interface OrderService {
|
|
@@ -1248,7 +1221,8 @@ interface Deps {
|
|
|
1248
1221
|
business: BusinessService;
|
|
1249
1222
|
catalogue: CatalogueService;
|
|
1250
1223
|
cart: CartService;
|
|
1251
|
-
|
|
1224
|
+
payments: PaymentService;
|
|
1225
|
+
purchaseIntents: PurchaseIntentMockService;
|
|
1252
1226
|
orders: OrderService;
|
|
1253
1227
|
subscriptions: SubscriptionService;
|
|
1254
1228
|
scheduling: SchedulingService;
|
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
import { C as CimplifyClient } from './catalogue-BlQ85Uma.mjs';
|
|
2
|
+
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-BlQ85Uma.mjs';
|
|
3
|
+
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-BqK9XUz5.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './link-D9iSVxt5.mjs';
|
|
6
5
|
|
|
7
6
|
interface ServerClientOptions {
|
|
8
7
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
import { C as CimplifyClient } from './catalogue-C8TqOj9K.js';
|
|
2
|
+
export { a as CacheOptions, R as ReadRequestOptions, b as Result } from './catalogue-C8TqOj9K.js';
|
|
3
|
+
export { b as Category, c as CimplifyError, d as Collection, P as Product, e as ProductWithDetails } from './checkout-BqK9XUz5.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './link-D9iSVxt5.js';
|
|
6
5
|
|
|
7
6
|
interface ServerClientOptions {
|
|
8
7
|
/**
|