@superlogic/spree-pay 0.1.31 → 0.1.34

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
@@ -44,7 +44,7 @@ var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
44
44
  var import_swr5 = require("swr");
45
45
 
46
46
  // package.json
47
- var version = "0.1.31";
47
+ var version = "0.1.34";
48
48
 
49
49
  // src/context/SpreePayActionsContext.tsx
50
50
  var import_react = require("react");
@@ -96,7 +96,8 @@ var SpreePayProvider = ({ children, env }) => {
96
96
  }
97
97
  }, []);
98
98
  const value = {
99
- env,
99
+ // Set default to true for web3 points to backward compatibility
100
+ env: { ...env, useWeb3Points: env.useWeb3Points ?? true },
100
101
  enabled: Boolean(selectedPaymentMethod.method),
101
102
  isInternalProcessing,
102
103
  process,
@@ -150,6 +151,11 @@ var CONFIG = {
150
151
  slapiUrl: "https://slapi.dev.air.shop",
151
152
  keycloakUrl: "https://login.dev.air.shop",
152
153
  keycloakClientId: "oneof-next"
154
+ },
155
+ qiibee: {
156
+ slapiUrl: "https://slapi.dev.superlogic.com",
157
+ keycloakUrl: "https://sso.dev.tickets.qiibeefoundation.org",
158
+ keycloakClientId: "oneof-next"
153
159
  }
154
160
  },
155
161
  stg: {
@@ -162,6 +168,11 @@ var CONFIG = {
162
168
  slapiUrl: "https://slapi.stg.air.shop",
163
169
  keycloakUrl: "https://login.stg.air.shop",
164
170
  keycloakClientId: "oneof-next"
171
+ },
172
+ qiibee: {
173
+ slapiUrl: "https://slapi.stg.tickets.qiibeefoundation.org",
174
+ keycloakUrl: "https://sso.stg.tickets.qiibeefoundation.org",
175
+ keycloakClientId: "oneof-next"
165
176
  }
166
177
  },
167
178
  prod: {
@@ -174,6 +185,11 @@ var CONFIG = {
174
185
  slapiUrl: "https://slapi.air.shop",
175
186
  keycloakUrl: "https://login.air.shop",
176
187
  keycloakClientId: "oneof-next"
188
+ },
189
+ qiibee: {
190
+ slapiUrl: "https://slapi.tickets.qiibeefoundation.org",
191
+ keycloakUrl: "https://sso.tickets.qiibeefoundation.org",
192
+ keycloakClientId: "oneof-next"
177
193
  }
178
194
  }
179
195
  };
@@ -827,7 +843,11 @@ async function longPollCardStatus(paymentId) {
827
843
  if (detail.status === "FAILED" /* FAILED */) {
828
844
  throw new Error(`Something went wrong with the ${detail.validationType} payment`);
829
845
  }
830
- if (detail.validationType === "POINTS") {
846
+ if (
847
+ // Process to points payment
848
+ detail.validationType === "POINTS" || // early card payment completion
849
+ ["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)
850
+ ) {
831
851
  return detail.status;
832
852
  }
833
853
  if (!shown3ds && detail.card?.redirectUrl) {
@@ -844,7 +864,7 @@ async function longPollCardStatus(paymentId) {
844
864
  }
845
865
 
846
866
  // src/hooks/payments/usePointsPayment.ts
847
- var usePointsPayment = () => {
867
+ var usePointsPayment = (mode = "web2") => {
848
868
  const { selectedPaymentMethod } = useSpreePaymentMethod();
849
869
  const { spreePayConfig } = useSpreePayConfig();
850
870
  const pointsPayment = async (params) => {
@@ -854,31 +874,42 @@ var usePointsPayment = () => {
854
874
  const { hash, capture, metadata } = params;
855
875
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
856
876
  hash,
857
- capture,
877
+ // capture should be always true for web2 points payments
878
+ capture: mode === "web2" ? true : capture,
858
879
  metadata,
859
880
  type: "POINTS" /* POINTS */
860
881
  });
861
- const wallet = peekAirWallet();
862
- if (!wallet || !spreePayConfig?.pointsChain) {
863
- throw new Error("AirWallet not found");
864
- }
865
- const transaction = await handleSendErc20({
866
- amount: params.points,
867
- token: spreePayConfig.pointsChain.pointsCoin,
868
- recipient: spreePayConfig.pointsChain.recipientAddress
869
- });
870
- if (!transaction) {
871
- throw new Error("Points transaction failed");
882
+ if (mode === "web3") {
883
+ const wallet = peekAirWallet();
884
+ if (!wallet || !spreePayConfig?.pointsChain) {
885
+ throw new Error("AirWallet not found");
886
+ }
887
+ const transaction = await handleSendErc20({
888
+ amount: params.points,
889
+ token: spreePayConfig.pointsChain.pointsCoin,
890
+ recipient: spreePayConfig.pointsChain.recipientAddress
891
+ });
892
+ if (!transaction) {
893
+ throw new Error("Points transaction failed");
894
+ }
895
+ await SlapiPaymentService.validatePoints({
896
+ paymentId: paymentResData.id,
897
+ txHash: transaction.txHash
898
+ });
899
+ const pointsStatus2 = await longPollPoints(paymentResData.id);
900
+ return {
901
+ status: pointsStatus2,
902
+ txId: paymentResData.txId,
903
+ txHash: transaction.txHash,
904
+ paymentId: paymentResData.id,
905
+ paymentType: "POINTS" /* POINTS */
906
+ };
872
907
  }
873
- await SlapiPaymentService.validatePoints({
874
- paymentId: paymentResData.id,
875
- txHash: transaction.txHash
876
- });
877
908
  const pointsStatus = await longPollPoints(paymentResData.id);
878
909
  return {
879
910
  status: pointsStatus,
880
911
  txId: paymentResData.txId,
881
- txHash: transaction.txHash,
912
+ txHash: null,
882
913
  paymentId: paymentResData.id,
883
914
  paymentType: "POINTS" /* POINTS */
884
915
  };
@@ -887,7 +918,7 @@ var usePointsPayment = () => {
887
918
  };
888
919
 
889
920
  // src/hooks/payments/useSplitCardPayments.ts
890
- var useSplitCardPayments = () => {
921
+ var useSplitCardPayments = (mode = "web2") => {
891
922
  const { selectedPaymentMethod } = useSpreePaymentMethod();
892
923
  const { env } = useSpreePayEnv();
893
924
  const { appProps } = useStaticConfig();
@@ -921,30 +952,39 @@ var useSplitCardPayments = () => {
921
952
  amount: points
922
953
  }
923
954
  });
924
- await longPollCardStatus(paymentResData.id);
925
- const wallet = peekAirWallet();
926
- if (!wallet || !spreePayConfig?.pointsChain) {
927
- throw new Error("AirWallet not found");
928
- }
929
- const transaction = await handleSendErc20({
930
- amount: params.points,
931
- token: spreePayConfig.pointsChain.pointsCoin,
932
- recipient: spreePayConfig.pointsChain.recipientAddress
933
- });
934
- if (!transaction) {
935
- throw new Error("Points transaction failed");
955
+ const cardStatus = await longPollCardStatus(paymentResData.id);
956
+ if (mode === "web3") {
957
+ const wallet = peekAirWallet();
958
+ if (!wallet || !spreePayConfig?.pointsChain) {
959
+ throw new Error("AirWallet not found");
960
+ }
961
+ const transaction = await handleSendErc20({
962
+ amount: params.points,
963
+ token: spreePayConfig.pointsChain.pointsCoin,
964
+ recipient: spreePayConfig.pointsChain.recipientAddress
965
+ });
966
+ if (!transaction) {
967
+ throw new Error("Points transaction failed");
968
+ }
969
+ await SlapiPaymentService.validatePoints({
970
+ paymentId: paymentResData.id,
971
+ txHash: transaction.txHash
972
+ });
973
+ const pointsStatus = await longPollPoints(paymentResData.id);
974
+ return {
975
+ paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
976
+ status: pointsStatus,
977
+ paymentId: paymentResData.id,
978
+ txId: paymentResData.txId,
979
+ txHash: transaction.txHash
980
+ };
936
981
  }
937
- await SlapiPaymentService.validatePoints({
938
- paymentId: paymentResData.id,
939
- txHash: transaction.txHash
940
- });
941
- const pointsStatus = await longPollPoints(paymentResData.id);
942
982
  return {
943
983
  paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
944
- status: pointsStatus,
984
+ status: cardStatus,
945
985
  paymentId: paymentResData.id,
946
986
  txId: paymentResData.txId,
947
- txHash: transaction.txHash
987
+ txHash: null
948
988
  };
949
989
  };
950
990
  return { splitPayment };
@@ -984,7 +1024,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
984
1024
  e.stopPropagation();
985
1025
  if (isSelected || isRemoveDisabled) return;
986
1026
  };
987
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
1027
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-sm", children: [
988
1028
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
989
1029
  "div",
990
1030
  {
@@ -997,12 +1037,9 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
997
1037
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
998
1038
  "div",
999
1039
  {
1000
- className: cn(
1001
- "flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-3",
1002
- {
1003
- "border-primary": isSelected
1004
- }
1005
- ),
1040
+ className: cn("flex h-full w-full items-center justify-between border-1 !border-l-0 border-transparent px-3", {
1041
+ "border-primary": isSelected
1042
+ }),
1006
1043
  children: [
1007
1044
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm font-medium text-black", children: card.schema }) }),
1008
1045
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
@@ -1041,8 +1078,8 @@ var CardsList = ({ selectedCard, setCard }) => {
1041
1078
  const { cards, cardsIsLoading } = useCards();
1042
1079
  if (cardsIsLoading) {
1043
1080
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
1044
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" }),
1045
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" })
1081
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" }),
1082
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" })
1046
1083
  ] });
1047
1084
  }
1048
1085
  if (cards.length === 0) return null;
@@ -2305,14 +2342,8 @@ function cn2(...inputs) {
2305
2342
 
2306
2343
  // src/ui/slider.tsx
2307
2344
  var import_jsx_runtime23 = require("react/jsx-runtime");
2308
- function Slider2({
2309
- className,
2310
- defaultValue,
2311
- value,
2312
- min = 0,
2313
- max = 100,
2314
- ...props
2315
- }) {
2345
+ function Slider2(props) {
2346
+ const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
2316
2347
  const _values = React12.useMemo(
2317
2348
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
2318
2349
  [value, defaultValue, min, max]
@@ -2329,20 +2360,20 @@ function Slider2({
2329
2360
  "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
2330
2361
  className
2331
2362
  ),
2332
- ...props,
2363
+ ...rest,
2333
2364
  children: [
2334
2365
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2335
2366
  Track,
2336
2367
  {
2337
2368
  "data-slot": "slider-track",
2338
2369
  className: cn2(
2339
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2370
+ "relative grow overflow-hidden rounded-full bg-black/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2340
2371
  ),
2341
2372
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2342
2373
  Range,
2343
2374
  {
2344
2375
  "data-slot": "slider-range",
2345
- className: cn2("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2376
+ className: cn2("absolute bg-black data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2346
2377
  }
2347
2378
  )
2348
2379
  }
@@ -2351,7 +2382,7 @@ function Slider2({
2351
2382
  Thumb2,
2352
2383
  {
2353
2384
  "data-slot": "slider-thumb",
2354
- className: "border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2385
+ className: "ring-ring/50 block size-5 shrink-0 rounded-full border-1 border-white bg-black shadow-sm shadow-[#00000033] transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2355
2386
  },
2356
2387
  index
2357
2388
  ))
@@ -2385,7 +2416,7 @@ var PointsSelector = (props) => {
2385
2416
  {
2386
2417
  disabled: isDisabled,
2387
2418
  onClick: onSelect,
2388
- className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-md border-1 border-transparent", {
2419
+ className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-sm border-1 border-transparent", {
2389
2420
  "border-primary": isSelected,
2390
2421
  "cursor-not-allowed opacity-50": isDisabled
2391
2422
  }),
@@ -2480,11 +2511,14 @@ var SplitBlock = (props) => {
2480
2511
  [onToggle, env.environment]
2481
2512
  );
2482
2513
  (0, import_react11.useEffect)(() => {
2483
- setAddress(null);
2484
- setWalletReady(false);
2485
- initWallet(spreePayConfig?.pointsChain);
2486
- }, [spreePayConfig?.pointsChain, initWallet]);
2487
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(PointsSelector, { isDisabled: !walletReady, onSelect: () => onSelect("air"), isSelected, children: [
2514
+ if (env.useWeb3Points) {
2515
+ setAddress(null);
2516
+ setWalletReady(false);
2517
+ initWallet(spreePayConfig?.pointsChain);
2518
+ }
2519
+ }, [spreePayConfig?.pointsChain, initWallet, env.useWeb3Points]);
2520
+ const isPointsSelectorDisabled = env.useWeb3Points ? !walletReady : false;
2521
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
2488
2522
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-left text-xs font-medium text-black sm:text-sm", children: [
2489
2523
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: "Available" }),
2490
2524
  " ",
@@ -2537,14 +2571,16 @@ var Points = () => {
2537
2571
  var import_jsx_runtime27 = require("react/jsx-runtime");
2538
2572
  var CreditCardTab = () => {
2539
2573
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
2574
+ const { env } = useSpreePayEnv();
2540
2575
  const { appProps } = useStaticConfig();
2541
2576
  const { spreePayConfig } = useSpreePayConfig();
2542
2577
  const { register } = useSpreePayRegister();
2543
2578
  const { mutateCards } = useCards();
2544
2579
  const { mutateBalance } = useSlapiBalance();
2580
+ const isWeb3Enabled = Boolean(env.useWeb3Points);
2545
2581
  const { cardPayment } = useCardPayment();
2546
- const { splitPayment } = useSplitCardPayments();
2547
- const { pointsPayment } = usePointsPayment();
2582
+ const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
2583
+ const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
2548
2584
  const handlePay = (0, import_react13.useCallback)(
2549
2585
  async (data) => {
2550
2586
  try {
@@ -2565,7 +2601,9 @@ var CreditCardTab = () => {
2565
2601
  } catch (_) {
2566
2602
  return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
2567
2603
  } finally {
2568
- setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2604
+ if ("token" in (selectedPaymentMethod.method || {})) {
2605
+ setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2606
+ }
2569
2607
  mutateCards();
2570
2608
  mutateBalance();
2571
2609
  }
package/build/index.css CHANGED
@@ -640,6 +640,9 @@
640
640
  .sl-spreepay .border-transparent {
641
641
  border-color: transparent;
642
642
  }
643
+ .sl-spreepay .border-white {
644
+ border-color: var(--color-white);
645
+ }
643
646
  .sl-spreepay .bg-\[\#006FD50D\] {
644
647
  background-color: #006FD50D;
645
648
  }
@@ -649,6 +652,9 @@
649
652
  .sl-spreepay .bg-background {
650
653
  background-color: var(--background);
651
654
  }
655
+ .sl-spreepay .bg-black {
656
+ background-color: var(--color-black);
657
+ }
652
658
  .sl-spreepay .bg-black\/4 {
653
659
  background-color: color-mix(in srgb, #000 4%, transparent);
654
660
  @supports (color: color-mix(in lab, red, red)) {
@@ -661,6 +667,12 @@
661
667
  background-color: color-mix(in oklab, var(--color-black) 10%, transparent);
662
668
  }
663
669
  }
670
+ .sl-spreepay .bg-black\/15 {
671
+ background-color: color-mix(in srgb, #000 15%, transparent);
672
+ @supports (color: color-mix(in lab, red, red)) {
673
+ background-color: color-mix(in oklab, var(--color-black) 15%, transparent);
674
+ }
675
+ }
664
676
  .sl-spreepay .bg-black\/50 {
665
677
  background-color: color-mix(in srgb, #000 50%, transparent);
666
678
  @supports (color: color-mix(in lab, red, red)) {
@@ -679,9 +691,6 @@
679
691
  .sl-spreepay .bg-gray-400 {
680
692
  background-color: var(--color-gray-400);
681
693
  }
682
- .sl-spreepay .bg-muted {
683
- background-color: var(--muted);
684
- }
685
694
  .sl-spreepay .bg-primary {
686
695
  background-color: var(--primary);
687
696
  }
@@ -945,6 +954,12 @@
945
954
  var(--tw-ring-shadow),
946
955
  var(--tw-shadow);
947
956
  }
957
+ .sl-spreepay .shadow-\[\#00000033\] {
958
+ --tw-shadow-color: #00000033;
959
+ @supports (color: color-mix(in lab, red, red)) {
960
+ --tw-shadow-color: color-mix(in oklab, #00000033 var(--tw-shadow-alpha), transparent);
961
+ }
962
+ }
948
963
  .sl-spreepay .ring-ring\/50 {
949
964
  --tw-ring-color: var(--ring);
950
965
  @supports (color: color-mix(in lab, red, red)) {
package/build/index.d.cts CHANGED
@@ -20,6 +20,7 @@ type ENV = {
20
20
  tenantId: string;
21
21
  redirect3dsURI: string;
22
22
  accessToken?: string;
23
+ useWeb3Points?: boolean;
23
24
  };
24
25
 
25
26
  declare enum BASE_SYMBOLS {
package/build/index.d.ts CHANGED
@@ -20,6 +20,7 @@ type ENV = {
20
20
  tenantId: string;
21
21
  redirect3dsURI: string;
22
22
  accessToken?: string;
23
+ useWeb3Points?: boolean;
23
24
  };
24
25
 
25
26
  declare enum BASE_SYMBOLS {
package/build/index.js CHANGED
@@ -4,7 +4,7 @@ import NiceModal7 from "@ebay/nice-modal-react";
4
4
  import { SWRConfig } from "swr";
5
5
 
6
6
  // package.json
7
- var version = "0.1.31";
7
+ var version = "0.1.34";
8
8
 
9
9
  // src/context/SpreePayActionsContext.tsx
10
10
  import { createContext, useCallback, useContext, useRef, useState } from "react";
@@ -56,7 +56,8 @@ var SpreePayProvider = ({ children, env }) => {
56
56
  }
57
57
  }, []);
58
58
  const value = {
59
- env,
59
+ // Set default to true for web3 points to backward compatibility
60
+ env: { ...env, useWeb3Points: env.useWeb3Points ?? true },
60
61
  enabled: Boolean(selectedPaymentMethod.method),
61
62
  isInternalProcessing,
62
63
  process,
@@ -110,6 +111,11 @@ var CONFIG = {
110
111
  slapiUrl: "https://slapi.dev.air.shop",
111
112
  keycloakUrl: "https://login.dev.air.shop",
112
113
  keycloakClientId: "oneof-next"
114
+ },
115
+ qiibee: {
116
+ slapiUrl: "https://slapi.dev.superlogic.com",
117
+ keycloakUrl: "https://sso.dev.tickets.qiibeefoundation.org",
118
+ keycloakClientId: "oneof-next"
113
119
  }
114
120
  },
115
121
  stg: {
@@ -122,6 +128,11 @@ var CONFIG = {
122
128
  slapiUrl: "https://slapi.stg.air.shop",
123
129
  keycloakUrl: "https://login.stg.air.shop",
124
130
  keycloakClientId: "oneof-next"
131
+ },
132
+ qiibee: {
133
+ slapiUrl: "https://slapi.stg.tickets.qiibeefoundation.org",
134
+ keycloakUrl: "https://sso.stg.tickets.qiibeefoundation.org",
135
+ keycloakClientId: "oneof-next"
125
136
  }
126
137
  },
127
138
  prod: {
@@ -134,6 +145,11 @@ var CONFIG = {
134
145
  slapiUrl: "https://slapi.air.shop",
135
146
  keycloakUrl: "https://login.air.shop",
136
147
  keycloakClientId: "oneof-next"
148
+ },
149
+ qiibee: {
150
+ slapiUrl: "https://slapi.tickets.qiibeefoundation.org",
151
+ keycloakUrl: "https://sso.tickets.qiibeefoundation.org",
152
+ keycloakClientId: "oneof-next"
137
153
  }
138
154
  }
139
155
  };
@@ -787,7 +803,11 @@ async function longPollCardStatus(paymentId) {
787
803
  if (detail.status === "FAILED" /* FAILED */) {
788
804
  throw new Error(`Something went wrong with the ${detail.validationType} payment`);
789
805
  }
790
- if (detail.validationType === "POINTS") {
806
+ if (
807
+ // Process to points payment
808
+ detail.validationType === "POINTS" || // early card payment completion
809
+ ["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)
810
+ ) {
791
811
  return detail.status;
792
812
  }
793
813
  if (!shown3ds && detail.card?.redirectUrl) {
@@ -804,7 +824,7 @@ async function longPollCardStatus(paymentId) {
804
824
  }
805
825
 
806
826
  // src/hooks/payments/usePointsPayment.ts
807
- var usePointsPayment = () => {
827
+ var usePointsPayment = (mode = "web2") => {
808
828
  const { selectedPaymentMethod } = useSpreePaymentMethod();
809
829
  const { spreePayConfig } = useSpreePayConfig();
810
830
  const pointsPayment = async (params) => {
@@ -814,31 +834,42 @@ var usePointsPayment = () => {
814
834
  const { hash, capture, metadata } = params;
815
835
  const { data: paymentResData } = await SlapiPaymentService.createPayment({
816
836
  hash,
817
- capture,
837
+ // capture should be always true for web2 points payments
838
+ capture: mode === "web2" ? true : capture,
818
839
  metadata,
819
840
  type: "POINTS" /* POINTS */
820
841
  });
821
- const wallet = peekAirWallet();
822
- if (!wallet || !spreePayConfig?.pointsChain) {
823
- throw new Error("AirWallet not found");
824
- }
825
- const transaction = await handleSendErc20({
826
- amount: params.points,
827
- token: spreePayConfig.pointsChain.pointsCoin,
828
- recipient: spreePayConfig.pointsChain.recipientAddress
829
- });
830
- if (!transaction) {
831
- throw new Error("Points transaction failed");
842
+ if (mode === "web3") {
843
+ const wallet = peekAirWallet();
844
+ if (!wallet || !spreePayConfig?.pointsChain) {
845
+ throw new Error("AirWallet not found");
846
+ }
847
+ const transaction = await handleSendErc20({
848
+ amount: params.points,
849
+ token: spreePayConfig.pointsChain.pointsCoin,
850
+ recipient: spreePayConfig.pointsChain.recipientAddress
851
+ });
852
+ if (!transaction) {
853
+ throw new Error("Points transaction failed");
854
+ }
855
+ await SlapiPaymentService.validatePoints({
856
+ paymentId: paymentResData.id,
857
+ txHash: transaction.txHash
858
+ });
859
+ const pointsStatus2 = await longPollPoints(paymentResData.id);
860
+ return {
861
+ status: pointsStatus2,
862
+ txId: paymentResData.txId,
863
+ txHash: transaction.txHash,
864
+ paymentId: paymentResData.id,
865
+ paymentType: "POINTS" /* POINTS */
866
+ };
832
867
  }
833
- await SlapiPaymentService.validatePoints({
834
- paymentId: paymentResData.id,
835
- txHash: transaction.txHash
836
- });
837
868
  const pointsStatus = await longPollPoints(paymentResData.id);
838
869
  return {
839
870
  status: pointsStatus,
840
871
  txId: paymentResData.txId,
841
- txHash: transaction.txHash,
872
+ txHash: null,
842
873
  paymentId: paymentResData.id,
843
874
  paymentType: "POINTS" /* POINTS */
844
875
  };
@@ -847,7 +878,7 @@ var usePointsPayment = () => {
847
878
  };
848
879
 
849
880
  // src/hooks/payments/useSplitCardPayments.ts
850
- var useSplitCardPayments = () => {
881
+ var useSplitCardPayments = (mode = "web2") => {
851
882
  const { selectedPaymentMethod } = useSpreePaymentMethod();
852
883
  const { env } = useSpreePayEnv();
853
884
  const { appProps } = useStaticConfig();
@@ -881,30 +912,39 @@ var useSplitCardPayments = () => {
881
912
  amount: points
882
913
  }
883
914
  });
884
- await longPollCardStatus(paymentResData.id);
885
- const wallet = peekAirWallet();
886
- if (!wallet || !spreePayConfig?.pointsChain) {
887
- throw new Error("AirWallet not found");
888
- }
889
- const transaction = await handleSendErc20({
890
- amount: params.points,
891
- token: spreePayConfig.pointsChain.pointsCoin,
892
- recipient: spreePayConfig.pointsChain.recipientAddress
893
- });
894
- if (!transaction) {
895
- throw new Error("Points transaction failed");
915
+ const cardStatus = await longPollCardStatus(paymentResData.id);
916
+ if (mode === "web3") {
917
+ const wallet = peekAirWallet();
918
+ if (!wallet || !spreePayConfig?.pointsChain) {
919
+ throw new Error("AirWallet not found");
920
+ }
921
+ const transaction = await handleSendErc20({
922
+ amount: params.points,
923
+ token: spreePayConfig.pointsChain.pointsCoin,
924
+ recipient: spreePayConfig.pointsChain.recipientAddress
925
+ });
926
+ if (!transaction) {
927
+ throw new Error("Points transaction failed");
928
+ }
929
+ await SlapiPaymentService.validatePoints({
930
+ paymentId: paymentResData.id,
931
+ txHash: transaction.txHash
932
+ });
933
+ const pointsStatus = await longPollPoints(paymentResData.id);
934
+ return {
935
+ paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
936
+ status: pointsStatus,
937
+ paymentId: paymentResData.id,
938
+ txId: paymentResData.txId,
939
+ txHash: transaction.txHash
940
+ };
896
941
  }
897
- await SlapiPaymentService.validatePoints({
898
- paymentId: paymentResData.id,
899
- txHash: transaction.txHash
900
- });
901
- const pointsStatus = await longPollPoints(paymentResData.id);
902
942
  return {
903
943
  paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
904
- status: pointsStatus,
944
+ status: cardStatus,
905
945
  paymentId: paymentResData.id,
906
946
  txId: paymentResData.txId,
907
- txHash: transaction.txHash
947
+ txHash: null
908
948
  };
909
949
  };
910
950
  return { splitPayment };
@@ -944,7 +984,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
944
984
  e.stopPropagation();
945
985
  if (isSelected || isRemoveDisabled) return;
946
986
  };
947
- return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
987
+ return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-sm", children: [
948
988
  /* @__PURE__ */ jsx8(
949
989
  "div",
950
990
  {
@@ -957,12 +997,9 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
957
997
  /* @__PURE__ */ jsxs6(
958
998
  "div",
959
999
  {
960
- className: cn(
961
- "flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-3",
962
- {
963
- "border-primary": isSelected
964
- }
965
- ),
1000
+ className: cn("flex h-full w-full items-center justify-between border-1 !border-l-0 border-transparent px-3", {
1001
+ "border-primary": isSelected
1002
+ }),
966
1003
  children: [
967
1004
  /* @__PURE__ */ jsx8("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx8("p", { className: "text-sm font-medium text-black", children: card.schema }) }),
968
1005
  /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
@@ -1001,8 +1038,8 @@ var CardsList = ({ selectedCard, setCard }) => {
1001
1038
  const { cards, cardsIsLoading } = useCards();
1002
1039
  if (cardsIsLoading) {
1003
1040
  return /* @__PURE__ */ jsxs6("div", { className: "flex w-full flex-col gap-1", children: [
1004
- /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" }),
1005
- /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-md" })
1041
+ /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" }),
1042
+ /* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" })
1006
1043
  ] });
1007
1044
  }
1008
1045
  if (cards.length === 0) return null;
@@ -2265,14 +2302,8 @@ function cn2(...inputs) {
2265
2302
 
2266
2303
  // src/ui/slider.tsx
2267
2304
  import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
2268
- function Slider2({
2269
- className,
2270
- defaultValue,
2271
- value,
2272
- min = 0,
2273
- max = 100,
2274
- ...props
2275
- }) {
2305
+ function Slider2(props) {
2306
+ const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
2276
2307
  const _values = React12.useMemo(
2277
2308
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
2278
2309
  [value, defaultValue, min, max]
@@ -2289,20 +2320,20 @@ function Slider2({
2289
2320
  "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
2290
2321
  className
2291
2322
  ),
2292
- ...props,
2323
+ ...rest,
2293
2324
  children: [
2294
2325
  /* @__PURE__ */ jsx23(
2295
2326
  Track,
2296
2327
  {
2297
2328
  "data-slot": "slider-track",
2298
2329
  className: cn2(
2299
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2330
+ "relative grow overflow-hidden rounded-full bg-black/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
2300
2331
  ),
2301
2332
  children: /* @__PURE__ */ jsx23(
2302
2333
  Range,
2303
2334
  {
2304
2335
  "data-slot": "slider-range",
2305
- className: cn2("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2336
+ className: cn2("absolute bg-black data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
2306
2337
  }
2307
2338
  )
2308
2339
  }
@@ -2311,7 +2342,7 @@ function Slider2({
2311
2342
  Thumb2,
2312
2343
  {
2313
2344
  "data-slot": "slider-thumb",
2314
- className: "border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2345
+ className: "ring-ring/50 block size-5 shrink-0 rounded-full border-1 border-white bg-black shadow-sm shadow-[#00000033] transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
2315
2346
  },
2316
2347
  index
2317
2348
  ))
@@ -2345,7 +2376,7 @@ var PointsSelector = (props) => {
2345
2376
  {
2346
2377
  disabled: isDisabled,
2347
2378
  onClick: onSelect,
2348
- className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-md border-1 border-transparent", {
2379
+ className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-sm border-1 border-transparent", {
2349
2380
  "border-primary": isSelected,
2350
2381
  "cursor-not-allowed opacity-50": isDisabled
2351
2382
  }),
@@ -2440,11 +2471,14 @@ var SplitBlock = (props) => {
2440
2471
  [onToggle, env.environment]
2441
2472
  );
2442
2473
  useEffect6(() => {
2443
- setAddress(null);
2444
- setWalletReady(false);
2445
- initWallet(spreePayConfig?.pointsChain);
2446
- }, [spreePayConfig?.pointsChain, initWallet]);
2447
- return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs13(PointsSelector, { isDisabled: !walletReady, onSelect: () => onSelect("air"), isSelected, children: [
2474
+ if (env.useWeb3Points) {
2475
+ setAddress(null);
2476
+ setWalletReady(false);
2477
+ initWallet(spreePayConfig?.pointsChain);
2478
+ }
2479
+ }, [spreePayConfig?.pointsChain, initWallet, env.useWeb3Points]);
2480
+ const isPointsSelectorDisabled = env.useWeb3Points ? !walletReady : false;
2481
+ return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs13(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
2448
2482
  /* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ jsxs13("p", { className: "text-left text-xs font-medium text-black sm:text-sm", children: [
2449
2483
  /* @__PURE__ */ jsx25("span", { className: "text-black/50", children: "Available" }),
2450
2484
  " ",
@@ -2497,14 +2531,16 @@ var Points = () => {
2497
2531
  import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
2498
2532
  var CreditCardTab = () => {
2499
2533
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
2534
+ const { env } = useSpreePayEnv();
2500
2535
  const { appProps } = useStaticConfig();
2501
2536
  const { spreePayConfig } = useSpreePayConfig();
2502
2537
  const { register } = useSpreePayRegister();
2503
2538
  const { mutateCards } = useCards();
2504
2539
  const { mutateBalance } = useSlapiBalance();
2540
+ const isWeb3Enabled = Boolean(env.useWeb3Points);
2505
2541
  const { cardPayment } = useCardPayment();
2506
- const { splitPayment } = useSplitCardPayments();
2507
- const { pointsPayment } = usePointsPayment();
2542
+ const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
2543
+ const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
2508
2544
  const handlePay = useCallback5(
2509
2545
  async (data) => {
2510
2546
  try {
@@ -2525,7 +2561,9 @@ var CreditCardTab = () => {
2525
2561
  } catch (_) {
2526
2562
  return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
2527
2563
  } finally {
2528
- setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2564
+ if ("token" in (selectedPaymentMethod.method || {})) {
2565
+ setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
2566
+ }
2529
2567
  mutateCards();
2530
2568
  mutateBalance();
2531
2569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superlogic/spree-pay",
3
- "version": "0.1.31",
3
+ "version": "0.1.34",
4
4
  "description": "Spree-pay React component and utilities",
5
5
  "private": false,
6
6
  "type": "module",