@blocklet/payment-react 1.17.4 → 1.17.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/es/components/over-due-invoice-payment.js +1 -1
- package/es/contexts/payment.d.ts +1 -1
- package/es/contexts/payment.js +2 -2
- package/es/history/payment/list.js +1 -1
- package/es/libs/util.js +8 -1
- package/es/payment/form/index.js +1 -1
- package/lib/components/over-due-invoice-payment.js +1 -1
- package/lib/contexts/payment.d.ts +1 -1
- package/lib/contexts/payment.js +2 -2
- package/lib/history/payment/list.js +1 -1
- package/lib/libs/util.js +8 -1
- package/lib/payment/form/index.js +1 -1
- package/package.json +8 -8
- package/src/components/over-due-invoice-payment.tsx +1 -1
- package/src/contexts/payment.tsx +3 -3
- package/src/history/payment/list.tsx +3 -1
- package/src/libs/util.ts +8 -1
- package/src/payment/form/index.tsx +1 -1
|
@@ -75,7 +75,7 @@ function OverdueInvoicePayment({
|
|
|
75
75
|
}
|
|
76
76
|
setSelectCurrencyId(currency.id);
|
|
77
77
|
setPayLoading(true);
|
|
78
|
-
if (
|
|
78
|
+
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
79
79
|
connect.open({
|
|
80
80
|
containerEl: void 0,
|
|
81
81
|
saveConnect: false,
|
package/es/contexts/payment.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type PaymentContextType = {
|
|
|
12
12
|
connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
|
|
13
13
|
prefix: string;
|
|
14
14
|
settings: Settings;
|
|
15
|
-
refresh: () => void;
|
|
15
|
+
refresh: (forceRefresh?: boolean) => void;
|
|
16
16
|
getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
|
|
17
17
|
getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
|
|
18
18
|
setLivemode: (livemode: boolean) => void;
|
package/es/contexts/payment.js
CHANGED
|
@@ -7,11 +7,11 @@ import { getPrefix } from "../libs/util.js";
|
|
|
7
7
|
const PaymentContext = createContext({ api });
|
|
8
8
|
const { Provider, Consumer } = PaymentContext;
|
|
9
9
|
let settingsPromise = null;
|
|
10
|
-
const getSettings = () => {
|
|
10
|
+
const getSettings = (forceRefresh = false) => {
|
|
11
11
|
const livemode = localStorage.getItem("livemode") !== "false";
|
|
12
12
|
const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
|
|
13
13
|
const cachedData = sessionStorage.getItem(cacheKey);
|
|
14
|
-
if (cachedData) {
|
|
14
|
+
if (cachedData && !forceRefresh) {
|
|
15
15
|
return JSON.parse(cachedData);
|
|
16
16
|
}
|
|
17
17
|
if (!settingsPromise) {
|
|
@@ -70,7 +70,7 @@ export default function CustomerPaymentList({ customer_id }) {
|
|
|
70
70
|
] }) }),
|
|
71
71
|
/* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Status, { label: item.status, color: getPaymentIntentStatusColor(item.status) }) }),
|
|
72
72
|
/* @__PURE__ */ jsx(Box, { flex: 3, children: /* @__PURE__ */ jsx(Typography, { children: item.description || "-" }) }),
|
|
73
|
-
/* @__PURE__ */ jsx(Box, { flex: 3, sx: { minWidth: "220px" }, children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash) && /* @__PURE__ */ jsx(TxLink, { details: item.payment_details, method: item.paymentMethod, mode: "customer" }) })
|
|
73
|
+
/* @__PURE__ */ jsx(Box, { flex: 3, sx: { minWidth: "220px" }, children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash || item.payment_details?.base?.tx_hash) && /* @__PURE__ */ jsx(TxLink, { details: item.payment_details, method: item.paymentMethod, mode: "customer" }) })
|
|
74
74
|
]
|
|
75
75
|
},
|
|
76
76
|
item.id
|
package/es/libs/util.js
CHANGED
|
@@ -702,6 +702,13 @@ export const getTxLink = (method, details) => {
|
|
|
702
702
|
gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString()
|
|
703
703
|
};
|
|
704
704
|
}
|
|
705
|
+
if (method.type === "base" && details.base?.tx_hash) {
|
|
706
|
+
return {
|
|
707
|
+
link: joinURL(method.settings.base?.explorer_host, "/tx", details.base?.tx_hash),
|
|
708
|
+
text: (details.base?.tx_hash).toUpperCase(),
|
|
709
|
+
gas: ""
|
|
710
|
+
};
|
|
711
|
+
}
|
|
705
712
|
if (method.type === "stripe") {
|
|
706
713
|
const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
|
|
707
714
|
return {
|
|
@@ -855,7 +862,7 @@ export function getCustomerAvatar(did, updated_at, imageSize = 48) {
|
|
|
855
862
|
return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || dayjs().unix()}`;
|
|
856
863
|
}
|
|
857
864
|
export function hasDelegateTxHash(details, paymentMethod) {
|
|
858
|
-
return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) && // @ts-ignore
|
|
865
|
+
return paymentMethod?.type && ["arcblock", "ethereum", "base"].includes(paymentMethod?.type) && // @ts-ignore
|
|
859
866
|
details?.[paymentMethod?.type]?.tx_hash;
|
|
860
867
|
}
|
|
861
868
|
export function getInvoiceDescriptionAndReason(invoice, locale = "en") {
|
package/es/payment/form/index.js
CHANGED
|
@@ -226,7 +226,7 @@ export default function PaymentForm({
|
|
|
226
226
|
submitting: false,
|
|
227
227
|
customerLimited: false
|
|
228
228
|
});
|
|
229
|
-
if (["arcblock", "ethereum"].includes(method.type)) {
|
|
229
|
+
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
230
230
|
setState({ paying: true });
|
|
231
231
|
if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
|
|
232
232
|
await handleConnected();
|
|
@@ -93,7 +93,7 @@ function OverdueInvoicePayment({
|
|
|
93
93
|
}
|
|
94
94
|
setSelectCurrencyId(currency.id);
|
|
95
95
|
setPayLoading(true);
|
|
96
|
-
if (
|
|
96
|
+
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
97
97
|
connect.open({
|
|
98
98
|
containerEl: void 0,
|
|
99
99
|
saveConnect: false,
|
|
@@ -12,7 +12,7 @@ export type PaymentContextType = {
|
|
|
12
12
|
connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
|
|
13
13
|
prefix: string;
|
|
14
14
|
settings: Settings;
|
|
15
|
-
refresh: () => void;
|
|
15
|
+
refresh: (forceRefresh?: boolean) => void;
|
|
16
16
|
getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
|
|
17
17
|
getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
|
|
18
18
|
setLivemode: (livemode: boolean) => void;
|
package/lib/contexts/payment.js
CHANGED
|
@@ -23,11 +23,11 @@ const {
|
|
|
23
23
|
} = PaymentContext;
|
|
24
24
|
exports.SettingsConsumer = Consumer;
|
|
25
25
|
let settingsPromise = null;
|
|
26
|
-
const getSettings = () => {
|
|
26
|
+
const getSettings = (forceRefresh = false) => {
|
|
27
27
|
const livemode = localStorage.getItem("livemode") !== "false";
|
|
28
28
|
const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
|
|
29
29
|
const cachedData = sessionStorage.getItem(cacheKey);
|
|
30
|
-
if (cachedData) {
|
|
30
|
+
if (cachedData && !forceRefresh) {
|
|
31
31
|
return JSON.parse(cachedData);
|
|
32
32
|
}
|
|
33
33
|
if (!settingsPromise) {
|
|
@@ -120,7 +120,7 @@ function CustomerPaymentList({
|
|
|
120
120
|
sx: {
|
|
121
121
|
minWidth: "220px"
|
|
122
122
|
},
|
|
123
|
-
children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
|
|
123
|
+
children: (item.payment_details?.arcblock?.tx_hash || item.payment_details?.ethereum?.tx_hash || item.payment_details?.base?.tx_hash) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
|
|
124
124
|
details: item.payment_details,
|
|
125
125
|
method: item.paymentMethod,
|
|
126
126
|
mode: "customer"
|
package/lib/libs/util.js
CHANGED
|
@@ -870,6 +870,13 @@ const getTxLink = (method, details) => {
|
|
|
870
870
|
gas: new _util.BN(details.ethereum.gas_price).mul(new _util.BN(details.ethereum.gas_used)).toString()
|
|
871
871
|
};
|
|
872
872
|
}
|
|
873
|
+
if (method.type === "base" && details.base?.tx_hash) {
|
|
874
|
+
return {
|
|
875
|
+
link: (0, _ufo.joinURL)(method.settings.base?.explorer_host, "/tx", details.base?.tx_hash),
|
|
876
|
+
text: (details.base?.tx_hash).toUpperCase(),
|
|
877
|
+
gas: ""
|
|
878
|
+
};
|
|
879
|
+
}
|
|
873
880
|
if (method.type === "stripe") {
|
|
874
881
|
const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
|
|
875
882
|
return {
|
|
@@ -1038,7 +1045,7 @@ function getCustomerAvatar(did, updated_at, imageSize = 48) {
|
|
|
1038
1045
|
return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || (0, _dayjs.default)().unix()}`;
|
|
1039
1046
|
}
|
|
1040
1047
|
function hasDelegateTxHash(details, paymentMethod) {
|
|
1041
|
-
return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) &&
|
|
1048
|
+
return paymentMethod?.type && ["arcblock", "ethereum", "base"].includes(paymentMethod?.type) &&
|
|
1042
1049
|
// @ts-ignore
|
|
1043
1050
|
details?.[paymentMethod?.type]?.tx_hash;
|
|
1044
1051
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.6",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@arcblock/did-connect": "^2.11.
|
|
57
|
-
"@arcblock/ux": "^2.11.
|
|
58
|
-
"@arcblock/ws": "^1.19.
|
|
59
|
-
"@blocklet/ui-react": "^2.11.
|
|
56
|
+
"@arcblock/did-connect": "^2.11.27",
|
|
57
|
+
"@arcblock/ux": "^2.11.27",
|
|
58
|
+
"@arcblock/ws": "^1.19.3",
|
|
59
|
+
"@blocklet/ui-react": "^2.11.27",
|
|
60
60
|
"@mui/icons-material": "^5.16.6",
|
|
61
61
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
62
62
|
"@mui/material": "^5.16.6",
|
|
63
63
|
"@mui/system": "^5.16.6",
|
|
64
|
-
"@ocap/util": "^1.19.
|
|
64
|
+
"@ocap/util": "^1.19.3",
|
|
65
65
|
"@stripe/react-stripe-js": "^2.7.3",
|
|
66
66
|
"@stripe/stripe-js": "^2.4.0",
|
|
67
67
|
"@vitejs/plugin-legacy": "^5.4.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@babel/core": "^7.25.2",
|
|
93
93
|
"@babel/preset-env": "^7.25.2",
|
|
94
94
|
"@babel/preset-react": "^7.24.7",
|
|
95
|
-
"@blocklet/payment-types": "1.17.
|
|
95
|
+
"@blocklet/payment-types": "1.17.6",
|
|
96
96
|
"@storybook/addon-essentials": "^7.6.20",
|
|
97
97
|
"@storybook/addon-interactions": "^7.6.20",
|
|
98
98
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"vite-plugin-babel": "^1.2.0",
|
|
124
124
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "50e93ab4340be53c9d9bd18718c6db26048578c5"
|
|
127
127
|
}
|
|
@@ -114,7 +114,7 @@ function OverdueInvoicePayment({
|
|
|
114
114
|
}
|
|
115
115
|
setSelectCurrencyId(currency.id);
|
|
116
116
|
setPayLoading(true);
|
|
117
|
-
if (
|
|
117
|
+
if (['arcblock', 'ethereum', 'base'].includes(method.type)) {
|
|
118
118
|
connect.open({
|
|
119
119
|
containerEl: undefined as unknown as Element,
|
|
120
120
|
saveConnect: false,
|
package/src/contexts/payment.tsx
CHANGED
|
@@ -18,7 +18,7 @@ export type PaymentContextType = {
|
|
|
18
18
|
connect: import('@arcblock/did-connect/lib/types').SessionContext['connectApi'];
|
|
19
19
|
prefix: string;
|
|
20
20
|
settings: Settings;
|
|
21
|
-
refresh: () => void;
|
|
21
|
+
refresh: (forceRefresh?: boolean) => void;
|
|
22
22
|
getCurrency: (currencyId: string) => TPaymentCurrency | undefined;
|
|
23
23
|
getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
|
|
24
24
|
setLivemode: (livemode: boolean) => void;
|
|
@@ -40,11 +40,11 @@ const PaymentContext = createContext<PaymentContextType>({ api });
|
|
|
40
40
|
const { Provider, Consumer } = PaymentContext;
|
|
41
41
|
|
|
42
42
|
let settingsPromise: Promise<any> | null = null;
|
|
43
|
-
const getSettings = () => {
|
|
43
|
+
const getSettings = (forceRefresh = false) => {
|
|
44
44
|
const livemode = localStorage.getItem('livemode') !== 'false';
|
|
45
45
|
const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
|
|
46
46
|
const cachedData = sessionStorage.getItem(cacheKey);
|
|
47
|
-
if (cachedData) {
|
|
47
|
+
if (cachedData && !forceRefresh) {
|
|
48
48
|
return JSON.parse(cachedData);
|
|
49
49
|
}
|
|
50
50
|
if (!settingsPromise) {
|
|
@@ -95,7 +95,9 @@ export default function CustomerPaymentList({ customer_id }: Props) {
|
|
|
95
95
|
<Typography>{item.description || '-'}</Typography>
|
|
96
96
|
</Box>
|
|
97
97
|
<Box flex={3} sx={{ minWidth: '220px' }}>
|
|
98
|
-
{(item.payment_details?.arcblock?.tx_hash ||
|
|
98
|
+
{(item.payment_details?.arcblock?.tx_hash ||
|
|
99
|
+
item.payment_details?.ethereum?.tx_hash ||
|
|
100
|
+
item.payment_details?.base?.tx_hash) && (
|
|
99
101
|
<TxLink details={item.payment_details} method={item.paymentMethod} mode="customer" />
|
|
100
102
|
)}
|
|
101
103
|
</Box>
|
package/src/libs/util.ts
CHANGED
|
@@ -923,6 +923,13 @@ export const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
|
|
|
923
923
|
gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString(),
|
|
924
924
|
};
|
|
925
925
|
}
|
|
926
|
+
if (method.type === 'base' && details.base?.tx_hash) {
|
|
927
|
+
return {
|
|
928
|
+
link: joinURL(method.settings.base?.explorer_host as string, '/tx', details.base?.tx_hash as string),
|
|
929
|
+
text: (details.base?.tx_hash as string).toUpperCase(),
|
|
930
|
+
gas: '',
|
|
931
|
+
};
|
|
932
|
+
}
|
|
926
933
|
if (method.type === 'stripe') {
|
|
927
934
|
const dashboard = method.livemode ? 'https://dashboard.stripe.com' : 'https://dashboard.stripe.com/test';
|
|
928
935
|
return {
|
|
@@ -1109,7 +1116,7 @@ export function getCustomerAvatar(
|
|
|
1109
1116
|
export function hasDelegateTxHash(details: PaymentDetails, paymentMethod: TPaymentMethod) {
|
|
1110
1117
|
return (
|
|
1111
1118
|
paymentMethod?.type &&
|
|
1112
|
-
['arcblock', 'ethereum'].includes(paymentMethod?.type) &&
|
|
1119
|
+
['arcblock', 'ethereum', 'base'].includes(paymentMethod?.type) &&
|
|
1113
1120
|
// @ts-ignore
|
|
1114
1121
|
details?.[paymentMethod?.type]?.tx_hash
|
|
1115
1122
|
);
|
|
@@ -300,7 +300,7 @@ export default function PaymentForm({
|
|
|
300
300
|
customerLimited: false,
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
if (['arcblock', 'ethereum'].includes(method.type)) {
|
|
303
|
+
if (['arcblock', 'ethereum', 'base'].includes(method.type)) {
|
|
304
304
|
setState({ paying: true });
|
|
305
305
|
if (result.data.balance?.sufficient || result.data.delegation?.sufficient) {
|
|
306
306
|
await handleConnected();
|