@coin-voyage/paykit 2.4.0-beta.5 → 2.4.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Pages/CardPayment/index.js +10 -5
- package/dist/components/ui/PoweredByFooter/index.d.ts +1 -1
- package/dist/components/ui/PoweredByFooter/index.js +5 -0
- package/dist/hooks/usePaymentState.d.ts +1 -2
- package/dist/hooks/usePaymentState.js +8 -4
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -67,11 +67,16 @@ function StripeOnrampCheckout({ paymentData }) {
|
|
|
67
67
|
const { data: stripeOnramp, isLoading, error, refetch } = useStripeOnramp(paymentData.stripe_publishable_key);
|
|
68
68
|
const refreshOrderRef = useLatestRef(paymentState.refreshOrder);
|
|
69
69
|
const refreshDebounceRef = useRef(null);
|
|
70
|
+
const lastStatusRef = useRef(null);
|
|
70
71
|
const theme = useMemo(() => {
|
|
71
72
|
return mode === "dark" ? "dark" : "light";
|
|
72
73
|
}, [mode]);
|
|
73
74
|
const handleSessionUpdate = useCallback((status) => {
|
|
74
|
-
if (status ===
|
|
75
|
+
if (status === lastStatusRef.current)
|
|
76
|
+
return;
|
|
77
|
+
lastStatusRef.current = status;
|
|
78
|
+
const shouldRefresh = status === "fulfillment_complete" || status === "rejected";
|
|
79
|
+
if (!shouldRefresh) {
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
77
82
|
if (refreshDebounceRef.current) {
|
|
@@ -128,18 +133,18 @@ function useCardPaymentData() {
|
|
|
128
133
|
const { paymentState } = usePayContext();
|
|
129
134
|
const { payOrder, payWithCard } = paymentState;
|
|
130
135
|
const paymentData = getFiatPaymentData(payOrder?.payment);
|
|
136
|
+
const queryKey = useMemo(() => ["card-payment", payOrder?.id ?? null], [payOrder?.id]);
|
|
131
137
|
const query = useQuery({
|
|
132
|
-
queryKey
|
|
138
|
+
queryKey,
|
|
133
139
|
enabled: Boolean(payOrder?.id) && !paymentData,
|
|
140
|
+
staleTime: 10 * 1000,
|
|
134
141
|
retry: false,
|
|
135
142
|
refetchOnWindowFocus: false,
|
|
143
|
+
refetchOnMount: false,
|
|
136
144
|
queryFn: async () => {
|
|
137
145
|
if (!payOrder) {
|
|
138
146
|
throw new Error("Missing pay order");
|
|
139
147
|
}
|
|
140
|
-
if (paymentData) {
|
|
141
|
-
return paymentData;
|
|
142
|
-
}
|
|
143
148
|
const paymentDetails = await payWithCard();
|
|
144
149
|
const fiatPaymentData = getFiatPaymentData(paymentDetails.data);
|
|
145
150
|
if (!fiatPaymentData) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const PoweredByFooter: () => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
declare const PoweredByFooter: () => import("react/jsx-runtime").JSX.Element | null;
|
|
2
2
|
export default PoweredByFooter;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CoinVoyageIcon } from "../../../assets/coin-voyage";
|
|
3
3
|
import styled from "../../../styles/styled";
|
|
4
|
+
import usePayContext from "../../contexts/pay";
|
|
4
5
|
const PoweredByFooter = () => {
|
|
6
|
+
const { paymentState } = usePayContext();
|
|
7
|
+
if (paymentState.payOrder?.settings?.hide_footer) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
5
10
|
return (_jsx(Container, { children: _jsxs(TextButton, { onClick: () => {
|
|
6
11
|
window.open("https://coinvoyage.io", "_blank");
|
|
7
12
|
}, children: [_jsx(CoinVoyageIcon, { height: 20, width: 20 }), "Powered by Coin Voyage"] }) }));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WalletProps } from "@coin-voyage/crypto/types";
|
|
2
|
-
import { ChainId, ChainType, Currency, CurrencyBase, PaymentMethod, type PayOrder } from "@coin-voyage/shared/types";
|
|
3
|
-
import { PaymentDetails, PayOrderParams } from "@coin-voyage/shared/types";
|
|
2
|
+
import { ChainId, ChainType, Currency, CurrencyBase, PaymentDetails, PaymentMethod, PayOrderParams, type PayOrder } from "@coin-voyage/shared/types";
|
|
4
3
|
import { ROUTE } from "../types/routes";
|
|
5
4
|
import { CurrencyAndQuoteID } from "../types/state";
|
|
6
5
|
import { usePayOrderQuotes } from "./usePayOrderQuotes";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useAccount } from "@coin-voyage/crypto/hooks";
|
|
2
2
|
import { zPayOrder } from "@coin-voyage/shared/schemas";
|
|
3
|
-
import { ChainType, PayOrderMode } from "@coin-voyage/shared/types";
|
|
3
|
+
import { ChainType, PayOrderMode, } from "@coin-voyage/shared/types";
|
|
4
4
|
import { useResolveSuiNSName } from "@mysten/dapp-kit";
|
|
5
|
-
import { useCallback, useState } from "react";
|
|
5
|
+
import { useCallback, useRef, useState } from "react";
|
|
6
6
|
import { mainnet } from "viem/chains";
|
|
7
7
|
import { useEnsName } from "wagmi";
|
|
8
8
|
import { useBackendApi } from "../components/contexts/api";
|
|
@@ -15,6 +15,7 @@ export function usePaymentState({ payOrder, setPayOrder, setRoute, log, }) {
|
|
|
15
15
|
const api = useBackendApi();
|
|
16
16
|
const [connectorChainType, setConnectorChainType] = useState();
|
|
17
17
|
const [selectedWallet, setSelectedWallet] = useState();
|
|
18
|
+
const lastRequestedIdRef = useRef(null);
|
|
18
19
|
const { account: senderAccount } = useAccount({
|
|
19
20
|
selectedWallet,
|
|
20
21
|
chainType: connectorChainType,
|
|
@@ -71,12 +72,15 @@ export function usePaymentState({ payOrder, setPayOrder, setRoute, log, }) {
|
|
|
71
72
|
setPayOrder(order);
|
|
72
73
|
}, [payOrder, fetchPayOrder, setPayOrder]);
|
|
73
74
|
const setPayOrderId = useCallback(async (payOrderId) => {
|
|
74
|
-
if (!payOrderId
|
|
75
|
+
if (!payOrderId)
|
|
75
76
|
return;
|
|
77
|
+
if (lastRequestedIdRef.current === payOrderId)
|
|
78
|
+
return;
|
|
79
|
+
lastRequestedIdRef.current = payOrderId;
|
|
76
80
|
const order = await fetchPayOrder(payOrderId);
|
|
77
81
|
if (order)
|
|
78
82
|
setPayOrder(order);
|
|
79
|
-
}, [
|
|
83
|
+
}, [fetchPayOrder, setPayOrder]);
|
|
80
84
|
const copyDepositPayOrder = useCallback(async () => {
|
|
81
85
|
if (!payOrder?.id) {
|
|
82
86
|
log(`No payOrder to copy`);
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ReactNode } from "react";
|
|
|
5
5
|
import type { Languages as Lang } from "./lib/localizations";
|
|
6
6
|
export type APIEnvironment = APIEnvironmentShared;
|
|
7
7
|
export type WalletConfiguration = WalletConfigurationImport;
|
|
8
|
-
export type { PayOrder, PayOrderMetadata, ParsedPayOrderMetadata, PayOrderEvent } from "@coin-voyage/shared/types";
|
|
8
|
+
export type { PayOrder, PayOrderMetadata, PayOrderSettings, ParsedPayOrderMetadata, ParsedPayOrderSettings, PayOrderEvent, } from "@coin-voyage/shared/types";
|
|
9
9
|
export { PayOrderStatus, WebhookEventType } from "@coin-voyage/shared/types";
|
|
10
10
|
export type PayKitConfig = {
|
|
11
11
|
children?: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coin-voyage/paykit",
|
|
3
3
|
"description": "Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.",
|
|
4
|
-
"version": "2.4.0-beta.
|
|
4
|
+
"version": "2.4.0-beta.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "Lars <lars@coinvoyage.io>",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@stripe/crypto": "0.0.4",
|
|
64
64
|
"styled-components": "^5.3.11",
|
|
65
65
|
"uuid": "13.0.0",
|
|
66
|
-
"@coin-voyage/
|
|
67
|
-
"@coin-voyage/
|
|
66
|
+
"@coin-voyage/crypto": "2.4.0-beta.0",
|
|
67
|
+
"@coin-voyage/shared": "2.4.0-beta.4"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/qrcode": "1.5.5",
|