@superlogic/spree-pay 0.1.30 → 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 +120 -79
- package/build/index.css +18 -3
- package/build/index.d.cts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +120 -79
- package/package.json +1 -1
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.
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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:
|
|
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
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
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:
|
|
984
|
+
status: cardStatus,
|
|
945
985
|
paymentId: paymentResData.id,
|
|
946
986
|
txId: paymentResData.txId,
|
|
947
|
-
txHash:
|
|
987
|
+
txHash: null
|
|
948
988
|
};
|
|
949
989
|
};
|
|
950
990
|
return { splitPayment };
|
|
@@ -961,6 +1001,13 @@ var useCards = () => {
|
|
|
961
1001
|
};
|
|
962
1002
|
};
|
|
963
1003
|
|
|
1004
|
+
// src/hooks/useSlapiBalance.ts
|
|
1005
|
+
var import_swr3 = __toESM(require("swr"), 1);
|
|
1006
|
+
var useSlapiBalance = () => {
|
|
1007
|
+
const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/loyalty/accounts`);
|
|
1008
|
+
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
1009
|
+
};
|
|
1010
|
+
|
|
964
1011
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
965
1012
|
var import_react6 = require("react");
|
|
966
1013
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
@@ -977,7 +1024,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
977
1024
|
e.stopPropagation();
|
|
978
1025
|
if (isSelected || isRemoveDisabled) return;
|
|
979
1026
|
};
|
|
980
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-
|
|
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: [
|
|
981
1028
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
982
1029
|
"div",
|
|
983
1030
|
{
|
|
@@ -990,12 +1037,9 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
990
1037
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
991
1038
|
"div",
|
|
992
1039
|
{
|
|
993
|
-
className: cn(
|
|
994
|
-
"
|
|
995
|
-
|
|
996
|
-
"border-primary": isSelected
|
|
997
|
-
}
|
|
998
|
-
),
|
|
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
|
+
}),
|
|
999
1043
|
children: [
|
|
1000
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 }) }),
|
|
1001
1045
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
@@ -1034,8 +1078,8 @@ var CardsList = ({ selectedCard, setCard }) => {
|
|
|
1034
1078
|
const { cards, cardsIsLoading } = useCards();
|
|
1035
1079
|
if (cardsIsLoading) {
|
|
1036
1080
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
1037
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
1038
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
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" })
|
|
1039
1083
|
] });
|
|
1040
1084
|
}
|
|
1041
1085
|
if (cards.length === 0) return null;
|
|
@@ -1280,13 +1324,6 @@ var import_react12 = require("react");
|
|
|
1280
1324
|
// src/components/common/PointsSwitch.tsx
|
|
1281
1325
|
var import_react7 = require("react");
|
|
1282
1326
|
|
|
1283
|
-
// src/hooks/useSlapiBalance.ts
|
|
1284
|
-
var import_swr3 = __toESM(require("swr"), 1);
|
|
1285
|
-
var useSlapiBalance = () => {
|
|
1286
|
-
const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/loyalty/accounts`);
|
|
1287
|
-
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
1327
|
// src/ui/switch.tsx
|
|
1291
1328
|
var SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
|
|
1292
1329
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
@@ -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
|
-
...
|
|
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
|
-
"
|
|
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-
|
|
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: "
|
|
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-
|
|
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
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
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,13 +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();
|
|
2579
|
+
const { mutateBalance } = useSlapiBalance();
|
|
2580
|
+
const isWeb3Enabled = Boolean(env.useWeb3Points);
|
|
2544
2581
|
const { cardPayment } = useCardPayment();
|
|
2545
|
-
const { splitPayment } = useSplitCardPayments();
|
|
2546
|
-
const { pointsPayment } = usePointsPayment();
|
|
2582
|
+
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
2583
|
+
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
2547
2584
|
const handlePay = (0, import_react13.useCallback)(
|
|
2548
2585
|
async (data) => {
|
|
2549
2586
|
try {
|
|
@@ -2564,8 +2601,11 @@ var CreditCardTab = () => {
|
|
|
2564
2601
|
} catch (_) {
|
|
2565
2602
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2566
2603
|
} finally {
|
|
2567
|
-
|
|
2604
|
+
if ("token" in (selectedPaymentMethod.method || {})) {
|
|
2605
|
+
setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
2606
|
+
}
|
|
2568
2607
|
mutateCards();
|
|
2608
|
+
mutateBalance();
|
|
2569
2609
|
}
|
|
2570
2610
|
},
|
|
2571
2611
|
[
|
|
@@ -2576,7 +2616,8 @@ var CreditCardTab = () => {
|
|
|
2576
2616
|
setSelectedPaymentMethod,
|
|
2577
2617
|
cardPayment,
|
|
2578
2618
|
splitPayment,
|
|
2579
|
-
spreePayConfig
|
|
2619
|
+
spreePayConfig,
|
|
2620
|
+
mutateBalance
|
|
2580
2621
|
]
|
|
2581
2622
|
);
|
|
2582
2623
|
(0, import_react13.useEffect)(() => {
|
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
package/build/index.d.ts
CHANGED
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.
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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:
|
|
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
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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:
|
|
944
|
+
status: cardStatus,
|
|
905
945
|
paymentId: paymentResData.id,
|
|
906
946
|
txId: paymentResData.txId,
|
|
907
|
-
txHash:
|
|
947
|
+
txHash: null
|
|
908
948
|
};
|
|
909
949
|
};
|
|
910
950
|
return { splitPayment };
|
|
@@ -921,6 +961,13 @@ var useCards = () => {
|
|
|
921
961
|
};
|
|
922
962
|
};
|
|
923
963
|
|
|
964
|
+
// src/hooks/useSlapiBalance.ts
|
|
965
|
+
import useSWR3 from "swr";
|
|
966
|
+
var useSlapiBalance = () => {
|
|
967
|
+
const { data, isLoading, mutate } = useSWR3(`/v1/loyalty/accounts`);
|
|
968
|
+
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
969
|
+
};
|
|
970
|
+
|
|
924
971
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
925
972
|
import { useMemo as useMemo2, useState as useState4 } from "react";
|
|
926
973
|
import { Elements } from "@stripe/react-stripe-js";
|
|
@@ -937,7 +984,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
937
984
|
e.stopPropagation();
|
|
938
985
|
if (isSelected || isRemoveDisabled) return;
|
|
939
986
|
};
|
|
940
|
-
return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-
|
|
987
|
+
return /* @__PURE__ */ jsxs6("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-sm", children: [
|
|
941
988
|
/* @__PURE__ */ jsx8(
|
|
942
989
|
"div",
|
|
943
990
|
{
|
|
@@ -950,12 +997,9 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
950
997
|
/* @__PURE__ */ jsxs6(
|
|
951
998
|
"div",
|
|
952
999
|
{
|
|
953
|
-
className: cn(
|
|
954
|
-
"
|
|
955
|
-
|
|
956
|
-
"border-primary": isSelected
|
|
957
|
-
}
|
|
958
|
-
),
|
|
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
|
+
}),
|
|
959
1003
|
children: [
|
|
960
1004
|
/* @__PURE__ */ jsx8("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx8("p", { className: "text-sm font-medium text-black", children: card.schema }) }),
|
|
961
1005
|
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
@@ -994,8 +1038,8 @@ var CardsList = ({ selectedCard, setCard }) => {
|
|
|
994
1038
|
const { cards, cardsIsLoading } = useCards();
|
|
995
1039
|
if (cardsIsLoading) {
|
|
996
1040
|
return /* @__PURE__ */ jsxs6("div", { className: "flex w-full flex-col gap-1", children: [
|
|
997
|
-
/* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
998
|
-
/* @__PURE__ */ jsx8("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
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" })
|
|
999
1043
|
] });
|
|
1000
1044
|
}
|
|
1001
1045
|
if (cards.length === 0) return null;
|
|
@@ -1240,13 +1284,6 @@ import { useState as useState10 } from "react";
|
|
|
1240
1284
|
// src/components/common/PointsSwitch.tsx
|
|
1241
1285
|
import { useId as useId2 } from "react";
|
|
1242
1286
|
|
|
1243
|
-
// src/hooks/useSlapiBalance.ts
|
|
1244
|
-
import useSWR3 from "swr";
|
|
1245
|
-
var useSlapiBalance = () => {
|
|
1246
|
-
const { data, isLoading, mutate } = useSWR3(`/v1/loyalty/accounts`);
|
|
1247
|
-
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
1287
|
// src/ui/switch.tsx
|
|
1251
1288
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
1252
1289
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
@@ -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
|
-
...
|
|
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
|
-
"
|
|
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-
|
|
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: "
|
|
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-
|
|
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
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
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,13 +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();
|
|
2539
|
+
const { mutateBalance } = useSlapiBalance();
|
|
2540
|
+
const isWeb3Enabled = Boolean(env.useWeb3Points);
|
|
2504
2541
|
const { cardPayment } = useCardPayment();
|
|
2505
|
-
const { splitPayment } = useSplitCardPayments();
|
|
2506
|
-
const { pointsPayment } = usePointsPayment();
|
|
2542
|
+
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
2543
|
+
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
2507
2544
|
const handlePay = useCallback5(
|
|
2508
2545
|
async (data) => {
|
|
2509
2546
|
try {
|
|
@@ -2524,8 +2561,11 @@ var CreditCardTab = () => {
|
|
|
2524
2561
|
} catch (_) {
|
|
2525
2562
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2526
2563
|
} finally {
|
|
2527
|
-
|
|
2564
|
+
if ("token" in (selectedPaymentMethod.method || {})) {
|
|
2565
|
+
setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
2566
|
+
}
|
|
2528
2567
|
mutateCards();
|
|
2568
|
+
mutateBalance();
|
|
2529
2569
|
}
|
|
2530
2570
|
},
|
|
2531
2571
|
[
|
|
@@ -2536,7 +2576,8 @@ var CreditCardTab = () => {
|
|
|
2536
2576
|
setSelectedPaymentMethod,
|
|
2537
2577
|
cardPayment,
|
|
2538
2578
|
splitPayment,
|
|
2539
|
-
spreePayConfig
|
|
2579
|
+
spreePayConfig,
|
|
2580
|
+
mutateBalance
|
|
2540
2581
|
]
|
|
2541
2582
|
);
|
|
2542
2583
|
useEffect7(() => {
|