@superlogic/spree-pay 0.1.15 → 0.1.16
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 +19 -15
- package/build/index.js +19 -15
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -263,10 +263,21 @@ var SpreeLegal = () => {
|
|
|
263
263
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
264
264
|
var import_react7 = require("react");
|
|
265
265
|
|
|
266
|
-
// src/hooks/
|
|
266
|
+
// src/hooks/useCards.ts
|
|
267
267
|
var import_swr = __toESM(require("swr"), 1);
|
|
268
|
+
var useCards = () => {
|
|
269
|
+
const { data, isLoading, mutate } = (0, import_swr.default)(`/v1/payments/cards`);
|
|
270
|
+
return {
|
|
271
|
+
cards: data?.data.filter((c) => c.active) || [],
|
|
272
|
+
cardsIsLoading: isLoading,
|
|
273
|
+
mutateCards: mutate
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/hooks/useSlapiBalance.ts
|
|
278
|
+
var import_swr2 = __toESM(require("swr"), 1);
|
|
268
279
|
var useSlapiBalance = () => {
|
|
269
|
-
const { data, isLoading, mutate } = (0,
|
|
280
|
+
const { data, isLoading, mutate } = (0, import_swr2.default)(`/v1/loyalty/accounts`);
|
|
270
281
|
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
271
282
|
};
|
|
272
283
|
|
|
@@ -672,17 +683,6 @@ var import_react6 = require("react");
|
|
|
672
683
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
673
684
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
674
685
|
|
|
675
|
-
// src/hooks/useCards.ts
|
|
676
|
-
var import_swr2 = __toESM(require("swr"), 1);
|
|
677
|
-
var useCards = () => {
|
|
678
|
-
const { data, isLoading, mutate } = (0, import_swr2.default)(`/v1/payments/cards`);
|
|
679
|
-
return {
|
|
680
|
-
cards: data?.data.filter((c) => c.active) || [],
|
|
681
|
-
cardsIsLoading: isLoading,
|
|
682
|
-
mutateCards: mutate
|
|
683
|
-
};
|
|
684
|
-
};
|
|
685
|
-
|
|
686
686
|
// src/hooks/useConfig.ts
|
|
687
687
|
var import_swr3 = __toESM(require("swr"), 1);
|
|
688
688
|
var useConfig = () => {
|
|
@@ -1016,8 +1016,9 @@ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
|
|
|
1016
1016
|
const [usePoints, setUsePoints] = (0, import_react7.useState)(false);
|
|
1017
1017
|
const [selectedPointsType, setSelectedPointsType] = (0, import_react7.useState)(null);
|
|
1018
1018
|
const { balance, isBalanceLoading } = useSlapiBalance();
|
|
1019
|
-
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
1019
|
+
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
1020
1020
|
const { register } = useSpreePayRegister();
|
|
1021
|
+
const { mutateCards } = useCards();
|
|
1021
1022
|
const { env } = useSpreePayEnv();
|
|
1022
1023
|
const handlePay = (0, import_react7.useCallback)(
|
|
1023
1024
|
async (data) => {
|
|
@@ -1036,9 +1037,12 @@ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
|
|
|
1036
1037
|
return Promise.reject(new PaymentError("Unsupported payment method", "FAILED" /* FAILED */));
|
|
1037
1038
|
} catch (_) {
|
|
1038
1039
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
1040
|
+
} finally {
|
|
1041
|
+
setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
1042
|
+
mutateCards();
|
|
1039
1043
|
}
|
|
1040
1044
|
},
|
|
1041
|
-
[env.redirect3dsURI, selectedPaymentMethod]
|
|
1045
|
+
[setSelectedPaymentMethod, mutateCards, env.redirect3dsURI, selectedPaymentMethod]
|
|
1042
1046
|
);
|
|
1043
1047
|
(0, import_react7.useEffect)(() => {
|
|
1044
1048
|
register(handlePay);
|
package/build/index.js
CHANGED
|
@@ -224,10 +224,21 @@ var SpreeLegal = () => {
|
|
|
224
224
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
225
225
|
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState4 } from "react";
|
|
226
226
|
|
|
227
|
-
// src/hooks/
|
|
227
|
+
// src/hooks/useCards.ts
|
|
228
228
|
import useSWR from "swr";
|
|
229
|
+
var useCards = () => {
|
|
230
|
+
const { data, isLoading, mutate } = useSWR(`/v1/payments/cards`);
|
|
231
|
+
return {
|
|
232
|
+
cards: data?.data.filter((c) => c.active) || [],
|
|
233
|
+
cardsIsLoading: isLoading,
|
|
234
|
+
mutateCards: mutate
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/hooks/useSlapiBalance.ts
|
|
239
|
+
import useSWR2 from "swr";
|
|
229
240
|
var useSlapiBalance = () => {
|
|
230
|
-
const { data, isLoading, mutate } =
|
|
241
|
+
const { data, isLoading, mutate } = useSWR2(`/v1/loyalty/accounts`);
|
|
231
242
|
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
232
243
|
};
|
|
233
244
|
|
|
@@ -633,17 +644,6 @@ import { useMemo, useState as useState3 } from "react";
|
|
|
633
644
|
import { Elements } from "@stripe/react-stripe-js";
|
|
634
645
|
import { loadStripe } from "@stripe/stripe-js";
|
|
635
646
|
|
|
636
|
-
// src/hooks/useCards.ts
|
|
637
|
-
import useSWR2 from "swr";
|
|
638
|
-
var useCards = () => {
|
|
639
|
-
const { data, isLoading, mutate } = useSWR2(`/v1/payments/cards`);
|
|
640
|
-
return {
|
|
641
|
-
cards: data?.data.filter((c) => c.active) || [],
|
|
642
|
-
cardsIsLoading: isLoading,
|
|
643
|
-
mutateCards: mutate
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
|
|
647
647
|
// src/hooks/useConfig.ts
|
|
648
648
|
import useSWR3 from "swr";
|
|
649
649
|
var useConfig = () => {
|
|
@@ -977,8 +977,9 @@ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
|
|
|
977
977
|
const [usePoints, setUsePoints] = useState4(false);
|
|
978
978
|
const [selectedPointsType, setSelectedPointsType] = useState4(null);
|
|
979
979
|
const { balance, isBalanceLoading } = useSlapiBalance();
|
|
980
|
-
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
980
|
+
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
981
981
|
const { register } = useSpreePayRegister();
|
|
982
|
+
const { mutateCards } = useCards();
|
|
982
983
|
const { env } = useSpreePayEnv();
|
|
983
984
|
const handlePay = useCallback2(
|
|
984
985
|
async (data) => {
|
|
@@ -997,9 +998,12 @@ var CreditCardTab = ({ pointsTitle, pointsConversionRatio }) => {
|
|
|
997
998
|
return Promise.reject(new PaymentError("Unsupported payment method", "FAILED" /* FAILED */));
|
|
998
999
|
} catch (_) {
|
|
999
1000
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
1001
|
+
} finally {
|
|
1002
|
+
setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
1003
|
+
mutateCards();
|
|
1000
1004
|
}
|
|
1001
1005
|
},
|
|
1002
|
-
[env.redirect3dsURI, selectedPaymentMethod]
|
|
1006
|
+
[setSelectedPaymentMethod, mutateCards, env.redirect3dsURI, selectedPaymentMethod]
|
|
1003
1007
|
);
|
|
1004
1008
|
useEffect2(() => {
|
|
1005
1009
|
register(handlePay);
|