@superlogic/spree-pay 0.1.11 → 0.1.13

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/build/index.cjs CHANGED
@@ -187,14 +187,13 @@ var formatUSD = (amount, currency = "USD") => {
187
187
  }).format(amount);
188
188
  return formattedAmount;
189
189
  };
190
- var pointsConverionRate = 100;
191
- var formatPoints = (amount) => {
190
+ var formatPoints = (amount, pointsTitle = "Pts") => {
192
191
  const formattedAmount = new Intl.NumberFormat("en-US", {
193
192
  style: "decimal",
194
193
  maximumFractionDigits: 5,
195
194
  minimumFractionDigits: 0
196
195
  }).format(amount);
197
- return `${formattedAmount} Pts`;
196
+ return `${formattedAmount} ${pointsTitle}`;
198
197
  };
199
198
  var formatCoin = (amount, currency = "USDC") => {
200
199
  const formattedAmount = new Intl.NumberFormat("en-US", {
@@ -562,13 +561,8 @@ var SlapiPaymentService = {
562
561
  };
563
562
 
564
563
  // src/services/cardPayment.ts
565
- var cardPayment = async ({
566
- card,
567
- hash,
568
- redirect3dsURI,
569
- metadata,
570
- capture
571
- }) => {
564
+ var cardPayment = async (params) => {
565
+ const { card, redirect3dsURI, hash, capture, metadata } = params;
572
566
  let cardId = card.id;
573
567
  if ("token" in card) {
574
568
  const { data: cardResData } = await SlapiPaymentService.addCard({ hash, source: card.token });
@@ -586,6 +580,7 @@ var cardPayment = async ({
586
580
  if (paymentIntent) {
587
581
  const { data: validateData } = await SlapiPaymentService.validate3DS({ paymentId: paymentResData.id });
588
582
  return {
583
+ paymentType: "CREDIT_CARD" /* CREDIT_CARD */,
589
584
  status: validateData.status,
590
585
  paymentId: paymentResData.id,
591
586
  txId: paymentResData.txId,
@@ -594,6 +589,7 @@ var cardPayment = async ({
594
589
  }
595
590
  }
596
591
  return {
592
+ paymentType: "CREDIT_CARD" /* CREDIT_CARD */,
597
593
  status: paymentResData.status,
598
594
  paymentId: paymentResData.id,
599
595
  txId: paymentResData.txId,
@@ -648,7 +644,7 @@ function Switch({ className, ...props }) {
648
644
  // src/components/common/PointsSwitch.tsx
649
645
  var import_jsx_runtime9 = require("react/jsx-runtime");
650
646
  var PointsSwitch = (props) => {
651
- const { disabled = false, value, onChange } = props;
647
+ const { pointsConversionRatio, disabled = false, value, onChange, pointsTitle } = props;
652
648
  const { balance } = useSlapiBalance();
653
649
  const id = (0, import_react4.useId)();
654
650
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
@@ -660,9 +656,9 @@ var PointsSwitch = (props) => {
660
656
  ] })
661
657
  ] }),
662
658
  balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "text-sm font-medium text-black", children: [
663
- formatPoints(balance.availablePoints),
659
+ formatPoints(balance.availablePoints, pointsTitle),
664
660
  " ",
665
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConverionRate) })
661
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
666
662
  ] }) : null
667
663
  ] });
668
664
  };
@@ -998,7 +994,7 @@ var PointsSelector = ({ isSelected, onSelect, children }) => {
998
994
  )
999
995
  );
1000
996
  };
1001
- var CreditCardTab = () => {
997
+ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
1002
998
  const [usePoints, setUsePoints] = (0, import_react7.useState)(false);
1003
999
  const [selectedPointsType, setSelectedPointsType] = (0, import_react7.useState)(null);
1004
1000
  const { balance, isBalanceLoading } = useSlapiBalance();
@@ -1032,15 +1028,24 @@ var CreditCardTab = () => {
1032
1028
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
1033
1029
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "border-b-1 border-black/7 px-7 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CreditCard, {}) }),
1034
1030
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-6 px-7 py-6", children: [
1035
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PointsSwitch, { disabled: true, value: usePoints, onChange: setUsePoints }),
1031
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1032
+ PointsSwitch,
1033
+ {
1034
+ disabled: true,
1035
+ value: usePoints,
1036
+ onChange: setUsePoints,
1037
+ pointsTitle,
1038
+ pointsConversionRatio
1039
+ }
1040
+ ),
1036
1041
  usePoints && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-1", children: [
1037
1042
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(PointsSelector, { onSelect: () => setSelectedPointsType("slapi"), isSelected: selectedPointsType === "slapi", children: [
1038
1043
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium text-black", children: "from [Brand] Balance" }) }),
1039
1044
  isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "h-4 w-6 animate-pulse bg-gray-200" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium text-black", children: "No points available" }),
1040
1045
  balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "text-sm font-medium text-black", children: [
1041
- formatPoints(balance.availablePoints),
1046
+ formatPoints(balance.availablePoints, pointsTitle),
1042
1047
  " ",
1043
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConverionRate) })
1048
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
1044
1049
  ] }) : null
1045
1050
  ] }),
1046
1051
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
@@ -1226,7 +1231,8 @@ var useCryptoPayment = () => {
1226
1231
  txHash,
1227
1232
  paymentId: paymentRes.data.id,
1228
1233
  txId: paymentRes.data.txId,
1229
- status: res.verified ? "AUTHORIZED" /* AUTHORIZED */ : "FAILED" /* FAILED */
1234
+ status: res.verified ? "CAPTURED" /* CAPTURED */ : "FAILED" /* FAILED */,
1235
+ paymentType: "CRYPTO" /* CRYPTO */
1230
1236
  };
1231
1237
  };
1232
1238
  return { cryptoPayment };
@@ -1662,10 +1668,11 @@ var CryptoWrapper = () => {
1662
1668
 
1663
1669
  // src/components/CryptoTab/CryptoTab.tsx
1664
1670
  var import_jsx_runtime24 = require("react/jsx-runtime");
1665
- var CryptoTab = () => {
1671
+ var CryptoTab = (props) => {
1672
+ const { pointsTitle, pointsConversionRatio } = props;
1666
1673
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
1667
1674
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "border-b-1 border-black/7 px-7 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CryptoWrapper, {}) }),
1668
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "px-7 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PointsSwitch, { disabled: true }) })
1675
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "px-7 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PointsSwitch, { disabled: true, pointsTitle, pointsConversionRatio }) })
1669
1676
  ] });
1670
1677
  };
1671
1678
 
@@ -1728,24 +1735,25 @@ var TabButtons = (props) => {
1728
1735
 
1729
1736
  // src/components/Tabs.tsx
1730
1737
  var import_jsx_runtime26 = require("react/jsx-runtime");
1731
- var Tabs = () => {
1738
+ var Tabs = ({ config: config2 }) => {
1732
1739
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
1740
+ const { pointsConversionRatio, pointsTitle } = config2;
1733
1741
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "mb-4 rounded-3xl border border-black/25 bg-white", children: [
1734
1742
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
1735
1743
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
1736
1744
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
1737
1745
  ] }),
1738
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CreditCardTab, {}),
1739
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CryptoTab, {})
1746
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CreditCardTab, { pointsTitle, pointsConversionRatio }),
1747
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CryptoTab, { pointsTitle, pointsConversionRatio })
1740
1748
  ] });
1741
1749
  };
1742
1750
 
1743
1751
  // src/SpreePayContent.tsx
1744
1752
  var import_jsx_runtime27 = require("react/jsx-runtime");
1745
1753
  var SpreePayContent = (props) => {
1746
- const { amount, onProcess, isProcessing } = props;
1754
+ const { config: config2, amount, onProcess, isProcessing } = props;
1747
1755
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "w-full", children: [
1748
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Tabs, {}),
1756
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Tabs, { config: config2 }),
1749
1757
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CheckoutButton, { isProcessing, onCheckout: onProcess, amount }),
1750
1758
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SpreeLegal, {})
1751
1759
  ] });
@@ -1820,41 +1828,53 @@ function useKeycloakSSO(config2) {
1820
1828
 
1821
1829
  // src/SpreePay.tsx
1822
1830
  var import_jsx_runtime28 = require("react/jsx-runtime");
1823
- var envConfig = {
1831
+ var CONFIG = {
1824
1832
  dev: {
1825
1833
  bookit: {
1826
1834
  slapiUrl: "https://slapi.dev.superlogic.com",
1827
1835
  keyklockUrl: "https://auth.dev.join.bookit.com",
1828
- keyklockClientId: "oneof-next"
1836
+ keyklockClientId: "oneof-next",
1837
+ pointsConversionRatio: 100,
1838
+ pointsTitle: "AIR SP"
1829
1839
  },
1830
1840
  moca: {
1831
1841
  slapiUrl: "https://slapi.dev.air.shop",
1832
1842
  keyklockUrl: "https://login.dev.air.shop",
1833
- keyklockClientId: "oneof-next"
1843
+ keyklockClientId: "oneof-next",
1844
+ pointsConversionRatio: 100,
1845
+ pointsTitle: "AIR SP"
1834
1846
  }
1835
1847
  },
1836
1848
  stg: {
1837
1849
  bookit: {
1838
1850
  slapiUrl: "https://slapi.stg.superlogic.com",
1839
1851
  keyklockUrl: "https://auth.stg.join.bookit.com",
1840
- keyklockClientId: "oneof-next"
1852
+ keyklockClientId: "oneof-next",
1853
+ pointsConversionRatio: 100,
1854
+ pointsTitle: "AIR SP"
1841
1855
  },
1842
1856
  moca: {
1843
- slapiUrl: "https://slapi.stg.superlogic.com",
1857
+ slapiUrl: "https://slapi.stg.air.shop",
1844
1858
  keyklockUrl: "https://login.stg.air.shop",
1845
- keyklockClientId: "oneof-next"
1859
+ keyklockClientId: "oneof-next",
1860
+ pointsConversionRatio: 100,
1861
+ pointsTitle: "AIR SP"
1846
1862
  }
1847
1863
  },
1848
1864
  prod: {
1849
1865
  bookit: {
1850
1866
  slapiUrl: "https://slapi.superlogic.com",
1851
1867
  keyklockUrl: "https://auth.join.bookit.com",
1852
- keyklockClientId: "oneof-next"
1868
+ keyklockClientId: "oneof-next",
1869
+ pointsConversionRatio: 100,
1870
+ pointsTitle: "AIR SP"
1853
1871
  },
1854
1872
  moca: {
1855
- slapiUrl: "https://slapi.superlogic.com",
1873
+ slapiUrl: "https://slapi.air.shop",
1856
1874
  keyklockUrl: "https://login.air.shop",
1857
- keyklockClientId: "oneof-next"
1875
+ keyklockClientId: "oneof-next",
1876
+ pointsConversionRatio: 100,
1877
+ pointsTitle: "AIR SP"
1858
1878
  }
1859
1879
  }
1860
1880
  };
@@ -1869,10 +1889,11 @@ var SpreePay = ({ className, ...rest }) => {
1869
1889
  const { env } = useSpreePayEnv();
1870
1890
  const environment = env?.environment || "dev";
1871
1891
  const tenantId = env?.tenantId || "bookit";
1892
+ const config2 = CONFIG[environment]?.[tenantId];
1872
1893
  const { isChecking, accessToken, error } = useKeycloakSSO({
1873
1894
  realm: tenantId,
1874
- url: envConfig[environment][tenantId].keyklockUrl,
1875
- clientId: envConfig[environment][tenantId].keyklockClientId,
1895
+ url: config2.keyklockUrl,
1896
+ clientId: config2.keyklockClientId,
1876
1897
  ssoPageURI: env?.ssoPageURI,
1877
1898
  enabled: !env?.accessToken
1878
1899
  });
@@ -1881,10 +1902,10 @@ var SpreePay = ({ className, ...rest }) => {
1881
1902
  return registerApi({
1882
1903
  accessToken: env.accessToken || accessToken,
1883
1904
  tenantId,
1884
- baseUrl: envConfig[environment][tenantId].slapiUrl
1905
+ baseUrl: config2.slapiUrl
1885
1906
  });
1886
1907
  }
1887
- }, [env.accessToken, environment, tenantId, accessToken]);
1908
+ }, [env.accessToken, config2, tenantId, accessToken]);
1888
1909
  const getContent = () => {
1889
1910
  if (isChecking) {
1890
1911
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "w-full text-center text-sm", children: "Loading..." });
@@ -1904,7 +1925,7 @@ var SpreePay = ({ className, ...rest }) => {
1904
1925
  revalidateIfStale: false,
1905
1926
  revalidateOnReconnect: false
1906
1927
  },
1907
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_nice_modal_react6.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SpreePayContent, { ...rest }) }) })
1928
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_nice_modal_react6.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SpreePayContent, { config: config2, ...rest }) }) })
1908
1929
  }
1909
1930
  );
1910
1931
  };
package/build/index.d.cts CHANGED
@@ -96,6 +96,7 @@ type PaymentMethodResult = {
96
96
  paymentId: string;
97
97
  txHash: string | null;
98
98
  txId: string | null;
99
+ paymentType: PaymentType;
99
100
  };
100
101
  type ProcessFnParams = {
101
102
  hash: string;
package/build/index.d.ts CHANGED
@@ -96,6 +96,7 @@ type PaymentMethodResult = {
96
96
  paymentId: string;
97
97
  txHash: string | null;
98
98
  txId: string | null;
99
+ paymentType: PaymentType;
99
100
  };
100
101
  type ProcessFnParams = {
101
102
  hash: string;
package/build/index.js CHANGED
@@ -148,14 +148,13 @@ var formatUSD = (amount, currency = "USD") => {
148
148
  }).format(amount);
149
149
  return formattedAmount;
150
150
  };
151
- var pointsConverionRate = 100;
152
- var formatPoints = (amount) => {
151
+ var formatPoints = (amount, pointsTitle = "Pts") => {
153
152
  const formattedAmount = new Intl.NumberFormat("en-US", {
154
153
  style: "decimal",
155
154
  maximumFractionDigits: 5,
156
155
  minimumFractionDigits: 0
157
156
  }).format(amount);
158
- return `${formattedAmount} Pts`;
157
+ return `${formattedAmount} ${pointsTitle}`;
159
158
  };
160
159
  var formatCoin = (amount, currency = "USDC") => {
161
160
  const formattedAmount = new Intl.NumberFormat("en-US", {
@@ -523,13 +522,8 @@ var SlapiPaymentService = {
523
522
  };
524
523
 
525
524
  // src/services/cardPayment.ts
526
- var cardPayment = async ({
527
- card,
528
- hash,
529
- redirect3dsURI,
530
- metadata,
531
- capture
532
- }) => {
525
+ var cardPayment = async (params) => {
526
+ const { card, redirect3dsURI, hash, capture, metadata } = params;
533
527
  let cardId = card.id;
534
528
  if ("token" in card) {
535
529
  const { data: cardResData } = await SlapiPaymentService.addCard({ hash, source: card.token });
@@ -547,6 +541,7 @@ var cardPayment = async ({
547
541
  if (paymentIntent) {
548
542
  const { data: validateData } = await SlapiPaymentService.validate3DS({ paymentId: paymentResData.id });
549
543
  return {
544
+ paymentType: "CREDIT_CARD" /* CREDIT_CARD */,
550
545
  status: validateData.status,
551
546
  paymentId: paymentResData.id,
552
547
  txId: paymentResData.txId,
@@ -555,6 +550,7 @@ var cardPayment = async ({
555
550
  }
556
551
  }
557
552
  return {
553
+ paymentType: "CREDIT_CARD" /* CREDIT_CARD */,
558
554
  status: paymentResData.status,
559
555
  paymentId: paymentResData.id,
560
556
  txId: paymentResData.txId,
@@ -609,7 +605,7 @@ function Switch({ className, ...props }) {
609
605
  // src/components/common/PointsSwitch.tsx
610
606
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
611
607
  var PointsSwitch = (props) => {
612
- const { disabled = false, value, onChange } = props;
608
+ const { pointsConversionRatio, disabled = false, value, onChange, pointsTitle } = props;
613
609
  const { balance } = useSlapiBalance();
614
610
  const id = useId();
615
611
  return /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-3", children: [
@@ -621,9 +617,9 @@ var PointsSwitch = (props) => {
621
617
  ] })
622
618
  ] }),
623
619
  balance?.availablePoints ? /* @__PURE__ */ jsxs6("p", { className: "text-sm font-medium text-black", children: [
624
- formatPoints(balance.availablePoints),
620
+ formatPoints(balance.availablePoints, pointsTitle),
625
621
  " ",
626
- /* @__PURE__ */ jsx9("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConverionRate) })
622
+ /* @__PURE__ */ jsx9("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
627
623
  ] }) : null
628
624
  ] });
629
625
  };
@@ -959,7 +955,7 @@ var PointsSelector = ({ isSelected, onSelect, children }) => {
959
955
  )
960
956
  );
961
957
  };
962
- var CreditCardTab = () => {
958
+ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
963
959
  const [usePoints, setUsePoints] = useState4(false);
964
960
  const [selectedPointsType, setSelectedPointsType] = useState4(null);
965
961
  const { balance, isBalanceLoading } = useSlapiBalance();
@@ -993,15 +989,24 @@ var CreditCardTab = () => {
993
989
  return /* @__PURE__ */ jsxs10("div", { children: [
994
990
  /* @__PURE__ */ jsx15("div", { className: "border-b-1 border-black/7 px-7 py-6", children: /* @__PURE__ */ jsx15(CreditCard, {}) }),
995
991
  /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-6 px-7 py-6", children: [
996
- /* @__PURE__ */ jsx15(PointsSwitch, { disabled: true, value: usePoints, onChange: setUsePoints }),
992
+ /* @__PURE__ */ jsx15(
993
+ PointsSwitch,
994
+ {
995
+ disabled: true,
996
+ value: usePoints,
997
+ onChange: setUsePoints,
998
+ pointsTitle,
999
+ pointsConversionRatio
1000
+ }
1001
+ ),
997
1002
  usePoints && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1", children: [
998
1003
  /* @__PURE__ */ jsxs10(PointsSelector, { onSelect: () => setSelectedPointsType("slapi"), isSelected: selectedPointsType === "slapi", children: [
999
1004
  /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx15("p", { className: "text-sm font-medium text-black", children: "from [Brand] Balance" }) }),
1000
1005
  isBalanceLoading ? /* @__PURE__ */ jsx15("div", { className: "h-4 w-6 animate-pulse bg-gray-200" }) : !balance?.availablePoints && /* @__PURE__ */ jsx15("p", { className: "text-sm font-medium text-black", children: "No points available" }),
1001
1006
  balance?.availablePoints ? /* @__PURE__ */ jsxs10("p", { className: "text-sm font-medium text-black", children: [
1002
- formatPoints(balance.availablePoints),
1007
+ formatPoints(balance.availablePoints, pointsTitle),
1003
1008
  " ",
1004
- /* @__PURE__ */ jsx15("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConverionRate) })
1009
+ /* @__PURE__ */ jsx15("span", { className: "text-black/50", children: formatUSD(balance.availablePoints / pointsConversionRatio) })
1005
1010
  ] }) : null
1006
1011
  ] }),
1007
1012
  /* @__PURE__ */ jsxs10(
@@ -1187,7 +1192,8 @@ var useCryptoPayment = () => {
1187
1192
  txHash,
1188
1193
  paymentId: paymentRes.data.id,
1189
1194
  txId: paymentRes.data.txId,
1190
- status: res.verified ? "AUTHORIZED" /* AUTHORIZED */ : "FAILED" /* FAILED */
1195
+ status: res.verified ? "CAPTURED" /* CAPTURED */ : "FAILED" /* FAILED */,
1196
+ paymentType: "CRYPTO" /* CRYPTO */
1191
1197
  };
1192
1198
  };
1193
1199
  return { cryptoPayment };
@@ -1623,10 +1629,11 @@ var CryptoWrapper = () => {
1623
1629
 
1624
1630
  // src/components/CryptoTab/CryptoTab.tsx
1625
1631
  import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
1626
- var CryptoTab = () => {
1632
+ var CryptoTab = (props) => {
1633
+ const { pointsTitle, pointsConversionRatio } = props;
1627
1634
  return /* @__PURE__ */ jsxs18("div", { children: [
1628
1635
  /* @__PURE__ */ jsx24("div", { className: "border-b-1 border-black/7 px-7 py-6", children: /* @__PURE__ */ jsx24(CryptoWrapper, {}) }),
1629
- /* @__PURE__ */ jsx24("div", { className: "px-7 py-6", children: /* @__PURE__ */ jsx24(PointsSwitch, { disabled: true }) })
1636
+ /* @__PURE__ */ jsx24("div", { className: "px-7 py-6", children: /* @__PURE__ */ jsx24(PointsSwitch, { disabled: true, pointsTitle, pointsConversionRatio }) })
1630
1637
  ] });
1631
1638
  };
1632
1639
 
@@ -1689,24 +1696,25 @@ var TabButtons = (props) => {
1689
1696
 
1690
1697
  // src/components/Tabs.tsx
1691
1698
  import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
1692
- var Tabs = () => {
1699
+ var Tabs = ({ config: config2 }) => {
1693
1700
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
1701
+ const { pointsConversionRatio, pointsTitle } = config2;
1694
1702
  return /* @__PURE__ */ jsxs20("div", { className: "mb-4 rounded-3xl border border-black/25 bg-white", children: [
1695
1703
  /* @__PURE__ */ jsxs20("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
1696
1704
  /* @__PURE__ */ jsx26("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
1697
1705
  /* @__PURE__ */ jsx26(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
1698
1706
  ] }),
1699
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx26(CreditCardTab, {}),
1700
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx26(CryptoTab, {})
1707
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ jsx26(CreditCardTab, { pointsTitle, pointsConversionRatio }),
1708
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ jsx26(CryptoTab, { pointsTitle, pointsConversionRatio })
1701
1709
  ] });
1702
1710
  };
1703
1711
 
1704
1712
  // src/SpreePayContent.tsx
1705
1713
  import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
1706
1714
  var SpreePayContent = (props) => {
1707
- const { amount, onProcess, isProcessing } = props;
1715
+ const { config: config2, amount, onProcess, isProcessing } = props;
1708
1716
  return /* @__PURE__ */ jsxs21("div", { className: "w-full", children: [
1709
- /* @__PURE__ */ jsx27(Tabs, {}),
1717
+ /* @__PURE__ */ jsx27(Tabs, { config: config2 }),
1710
1718
  /* @__PURE__ */ jsx27(CheckoutButton, { isProcessing, onCheckout: onProcess, amount }),
1711
1719
  /* @__PURE__ */ jsx27(SpreeLegal, {})
1712
1720
  ] });
@@ -1781,41 +1789,53 @@ function useKeycloakSSO(config2) {
1781
1789
 
1782
1790
  // src/SpreePay.tsx
1783
1791
  import { jsx as jsx28, jsxs as jsxs22 } from "react/jsx-runtime";
1784
- var envConfig = {
1792
+ var CONFIG = {
1785
1793
  dev: {
1786
1794
  bookit: {
1787
1795
  slapiUrl: "https://slapi.dev.superlogic.com",
1788
1796
  keyklockUrl: "https://auth.dev.join.bookit.com",
1789
- keyklockClientId: "oneof-next"
1797
+ keyklockClientId: "oneof-next",
1798
+ pointsConversionRatio: 100,
1799
+ pointsTitle: "AIR SP"
1790
1800
  },
1791
1801
  moca: {
1792
1802
  slapiUrl: "https://slapi.dev.air.shop",
1793
1803
  keyklockUrl: "https://login.dev.air.shop",
1794
- keyklockClientId: "oneof-next"
1804
+ keyklockClientId: "oneof-next",
1805
+ pointsConversionRatio: 100,
1806
+ pointsTitle: "AIR SP"
1795
1807
  }
1796
1808
  },
1797
1809
  stg: {
1798
1810
  bookit: {
1799
1811
  slapiUrl: "https://slapi.stg.superlogic.com",
1800
1812
  keyklockUrl: "https://auth.stg.join.bookit.com",
1801
- keyklockClientId: "oneof-next"
1813
+ keyklockClientId: "oneof-next",
1814
+ pointsConversionRatio: 100,
1815
+ pointsTitle: "AIR SP"
1802
1816
  },
1803
1817
  moca: {
1804
- slapiUrl: "https://slapi.stg.superlogic.com",
1818
+ slapiUrl: "https://slapi.stg.air.shop",
1805
1819
  keyklockUrl: "https://login.stg.air.shop",
1806
- keyklockClientId: "oneof-next"
1820
+ keyklockClientId: "oneof-next",
1821
+ pointsConversionRatio: 100,
1822
+ pointsTitle: "AIR SP"
1807
1823
  }
1808
1824
  },
1809
1825
  prod: {
1810
1826
  bookit: {
1811
1827
  slapiUrl: "https://slapi.superlogic.com",
1812
1828
  keyklockUrl: "https://auth.join.bookit.com",
1813
- keyklockClientId: "oneof-next"
1829
+ keyklockClientId: "oneof-next",
1830
+ pointsConversionRatio: 100,
1831
+ pointsTitle: "AIR SP"
1814
1832
  },
1815
1833
  moca: {
1816
- slapiUrl: "https://slapi.superlogic.com",
1834
+ slapiUrl: "https://slapi.air.shop",
1817
1835
  keyklockUrl: "https://login.air.shop",
1818
- keyklockClientId: "oneof-next"
1836
+ keyklockClientId: "oneof-next",
1837
+ pointsConversionRatio: 100,
1838
+ pointsTitle: "AIR SP"
1819
1839
  }
1820
1840
  }
1821
1841
  };
@@ -1830,10 +1850,11 @@ var SpreePay = ({ className, ...rest }) => {
1830
1850
  const { env } = useSpreePayEnv();
1831
1851
  const environment = env?.environment || "dev";
1832
1852
  const tenantId = env?.tenantId || "bookit";
1853
+ const config2 = CONFIG[environment]?.[tenantId];
1833
1854
  const { isChecking, accessToken, error } = useKeycloakSSO({
1834
1855
  realm: tenantId,
1835
- url: envConfig[environment][tenantId].keyklockUrl,
1836
- clientId: envConfig[environment][tenantId].keyklockClientId,
1856
+ url: config2.keyklockUrl,
1857
+ clientId: config2.keyklockClientId,
1837
1858
  ssoPageURI: env?.ssoPageURI,
1838
1859
  enabled: !env?.accessToken
1839
1860
  });
@@ -1842,10 +1863,10 @@ var SpreePay = ({ className, ...rest }) => {
1842
1863
  return registerApi({
1843
1864
  accessToken: env.accessToken || accessToken,
1844
1865
  tenantId,
1845
- baseUrl: envConfig[environment][tenantId].slapiUrl
1866
+ baseUrl: config2.slapiUrl
1846
1867
  });
1847
1868
  }
1848
- }, [env.accessToken, environment, tenantId, accessToken]);
1869
+ }, [env.accessToken, config2, tenantId, accessToken]);
1849
1870
  const getContent = () => {
1850
1871
  if (isChecking) {
1851
1872
  return /* @__PURE__ */ jsx28("p", { className: "w-full text-center text-sm", children: "Loading..." });
@@ -1865,7 +1886,7 @@ var SpreePay = ({ className, ...rest }) => {
1865
1886
  revalidateIfStale: false,
1866
1887
  revalidateOnReconnect: false
1867
1888
  },
1868
- children: /* @__PURE__ */ jsx28(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx28(NiceModal6.Provider, { children: /* @__PURE__ */ jsx28(SpreePayContent, { ...rest }) }) })
1889
+ children: /* @__PURE__ */ jsx28(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx28(NiceModal6.Provider, { children: /* @__PURE__ */ jsx28(SpreePayContent, { config: config2, ...rest }) }) })
1869
1890
  }
1870
1891
  );
1871
1892
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superlogic/spree-pay",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",