@blocklet/payment-react 1.13.228 → 1.13.230
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/blockchain/gas.d.ts +10 -0
- package/es/components/blockchain/gas.js +25 -0
- package/es/components/blockchain/tx.js +5 -2
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -0
- package/es/locales/en.js +5 -0
- package/es/locales/zh.js +5 -0
- package/es/payment/index.js +10 -0
- package/es/util.d.ts +1 -0
- package/es/util.js +9 -5
- package/lib/components/blockchain/gas.d.ts +10 -0
- package/lib/components/blockchain/gas.js +37 -0
- package/lib/components/blockchain/tx.js +4 -3
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +5 -0
- package/lib/locales/zh.js +5 -0
- package/lib/payment/index.js +7 -0
- package/lib/util.d.ts +1 -0
- package/lib/util.js +10 -5
- package/package.json +3 -3
- package/src/components/blockchain/gas.tsx +32 -0
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +5 -0
- package/src/locales/zh.tsx +5 -0
- package/src/payment/index.tsx +10 -0
- package/src/util.ts +6 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
|
+
declare function TxGas(props: {
|
|
4
|
+
details: PaymentDetails;
|
|
5
|
+
method: TPaymentMethod;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
declare namespace TxGas {
|
|
8
|
+
var defaultProps: {};
|
|
9
|
+
}
|
|
10
|
+
export default TxGas;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
import { fromUnitToToken } from "@ocap/util";
|
|
5
|
+
import { usePaymentContext } from "../../contexts/payment.js";
|
|
6
|
+
import { getTxLink } from "../../util.js";
|
|
7
|
+
TxGas.defaultProps = {};
|
|
8
|
+
export default function TxGas(props) {
|
|
9
|
+
const { t } = useLocaleContext();
|
|
10
|
+
const { settings } = usePaymentContext();
|
|
11
|
+
const { gas } = getTxLink(props.method, props.details);
|
|
12
|
+
const method = settings.paymentMethods.find((x) => x.id === props.method.id);
|
|
13
|
+
if (gas && method) {
|
|
14
|
+
const currency = method.payment_currencies.find((x) => x.id === method.default_currency_id);
|
|
15
|
+
return /* @__PURE__ */ jsxs(Typography, { component: "span", children: [
|
|
16
|
+
fromUnitToToken(gas, currency.decimal),
|
|
17
|
+
" ",
|
|
18
|
+
currency.symbol,
|
|
19
|
+
" (",
|
|
20
|
+
method.name,
|
|
21
|
+
")"
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: t("common.none") });
|
|
25
|
+
}
|
|
@@ -12,7 +12,7 @@ export default function TxLink(props) {
|
|
|
12
12
|
if (!props.details || props.mode === "customer" && props.method.type === "stripe") {
|
|
13
13
|
return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: t("common.none") });
|
|
14
14
|
}
|
|
15
|
-
const { text, link } = getTxLink(props.method, props.details);
|
|
15
|
+
const { text, link, gas } = getTxLink(props.method, props.details);
|
|
16
16
|
if (link) {
|
|
17
17
|
return /* @__PURE__ */ jsx(Link, { href: link, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs(
|
|
18
18
|
Stack,
|
|
@@ -23,7 +23,10 @@ export default function TxLink(props) {
|
|
|
23
23
|
justifyContent: props.align === "left" ? "flex-start" : "flex-end",
|
|
24
24
|
spacing: 1,
|
|
25
25
|
children: [
|
|
26
|
-
/* @__PURE__ */
|
|
26
|
+
/* @__PURE__ */ jsxs(Typography, { component: "span", color: "primary", children: [
|
|
27
|
+
text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text,
|
|
28
|
+
gas
|
|
29
|
+
] }),
|
|
27
30
|
/* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
|
|
28
31
|
]
|
|
29
32
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import api from './api';
|
|
|
2
2
|
import CheckoutDonate from './checkout/donate';
|
|
3
3
|
import CheckoutForm from './checkout/form';
|
|
4
4
|
import CheckoutTable from './checkout/table';
|
|
5
|
+
import TxGas from './components/blockchain/gas';
|
|
5
6
|
import TxLink from './components/blockchain/tx';
|
|
6
7
|
import ConfirmDialog from './components/confirm';
|
|
7
8
|
import FormInput from './components/input';
|
|
@@ -25,4 +26,4 @@ import PaymentSummary from './payment/summary';
|
|
|
25
26
|
export * from './util';
|
|
26
27
|
export * from './contexts/payment';
|
|
27
28
|
export { translations, createTranslator } from './locales';
|
|
28
|
-
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, SafeGuard, };
|
|
29
|
+
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, TxGas, SafeGuard, };
|
package/es/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import api from "./api.js";
|
|
|
2
2
|
import CheckoutDonate from "./checkout/donate.js";
|
|
3
3
|
import CheckoutForm from "./checkout/form.js";
|
|
4
4
|
import CheckoutTable from "./checkout/table.js";
|
|
5
|
+
import TxGas from "./components/blockchain/gas.js";
|
|
5
6
|
import TxLink from "./components/blockchain/tx.js";
|
|
6
7
|
import ConfirmDialog from "./components/confirm.js";
|
|
7
8
|
import FormInput from "./components/input.js";
|
|
@@ -49,5 +50,6 @@ export {
|
|
|
49
50
|
CustomerPaymentList,
|
|
50
51
|
MiniInvoiceList,
|
|
51
52
|
TxLink,
|
|
53
|
+
TxGas,
|
|
52
54
|
SafeGuard
|
|
53
55
|
};
|
package/es/locales/en.js
CHANGED
|
@@ -39,6 +39,7 @@ export default flat({
|
|
|
39
39
|
email: "Email",
|
|
40
40
|
did: "DID",
|
|
41
41
|
txHash: "Transaction",
|
|
42
|
+
txGas: "Transaction Gas",
|
|
42
43
|
delegateTxHash: "Delegate Transaction",
|
|
43
44
|
stakeTxHash: "Stake Transaction",
|
|
44
45
|
slashTxHash: "Slash Transaction",
|
|
@@ -163,6 +164,10 @@ export default flat({
|
|
|
163
164
|
complete: {
|
|
164
165
|
title: "Checkout Completed",
|
|
165
166
|
description: "This checkout session has completed. This means that your payment has already been successfully processed."
|
|
167
|
+
},
|
|
168
|
+
emptyItems: {
|
|
169
|
+
title: "Nothing to show here",
|
|
170
|
+
description: "Seems this checkoutSession is not configured properly"
|
|
166
171
|
}
|
|
167
172
|
},
|
|
168
173
|
customer: {
|
package/es/locales/zh.js
CHANGED
|
@@ -39,6 +39,7 @@ export default flat({
|
|
|
39
39
|
email: "\u90AE\u7BB1",
|
|
40
40
|
did: "DID",
|
|
41
41
|
txHash: "\u4EA4\u6613\u54C8\u5E0C",
|
|
42
|
+
txGas: "\u4EA4\u6613\u8D39\u7528",
|
|
42
43
|
delegateTxHash: "\u6388\u6743\u4EA4\u6613",
|
|
43
44
|
stakeTxHash: "\u8D28\u62BC\u4EA4\u6613",
|
|
44
45
|
slashTxHash: "\u7F5A\u6CA1\u4EA4\u6613",
|
|
@@ -163,6 +164,10 @@ export default flat({
|
|
|
163
164
|
cross_sell: {
|
|
164
165
|
add: "\u6DFB\u52A0\u5230\u8BA2\u5355",
|
|
165
166
|
remove: "\u4ECE\u8BA2\u5355\u79FB\u9664"
|
|
167
|
+
},
|
|
168
|
+
emptyItems: {
|
|
169
|
+
title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
|
|
170
|
+
description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
|
|
166
171
|
}
|
|
167
172
|
},
|
|
168
173
|
customer: {
|
package/es/payment/index.js
CHANGED
|
@@ -86,6 +86,16 @@ export default function Payment({
|
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
+
if (!checkoutSession.line_items.length) {
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
PaymentError,
|
|
92
|
+
{
|
|
93
|
+
mode,
|
|
94
|
+
title: t("payment.checkout.emptyItems.title"),
|
|
95
|
+
description: t("payment.checkout.emptyItems.description")
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
89
99
|
return /* @__PURE__ */ jsx(
|
|
90
100
|
PaymentInner,
|
|
91
101
|
{
|
package/es/util.d.ts
CHANGED
package/es/util.js
CHANGED
|
@@ -560,19 +560,22 @@ export const getTxLink = (method, details) => {
|
|
|
560
560
|
if (method.type === "arcblock" && details.arcblock?.tx_hash) {
|
|
561
561
|
return {
|
|
562
562
|
link: joinURL(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
|
|
563
|
-
text: details.arcblock?.tx_hash
|
|
563
|
+
text: details.arcblock?.tx_hash,
|
|
564
|
+
gas: ""
|
|
564
565
|
};
|
|
565
566
|
}
|
|
566
567
|
if (method.type === "bitcoin" && details.bitcoin?.tx_hash) {
|
|
567
568
|
return {
|
|
568
569
|
link: joinURL(method.settings.bitcoin?.explorer_host, "/tx", details.bitcoin?.tx_hash),
|
|
569
|
-
text: details.bitcoin?.tx_hash
|
|
570
|
+
text: details.bitcoin?.tx_hash,
|
|
571
|
+
gas: ""
|
|
570
572
|
};
|
|
571
573
|
}
|
|
572
574
|
if (method.type === "ethereum" && details.ethereum?.tx_hash) {
|
|
573
575
|
return {
|
|
574
576
|
link: joinURL(method.settings.ethereum?.explorer_host, "/tx", details.ethereum?.tx_hash),
|
|
575
|
-
text: details.ethereum?.tx_hash
|
|
577
|
+
text: (details.ethereum?.tx_hash).toUpperCase(),
|
|
578
|
+
gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString()
|
|
576
579
|
};
|
|
577
580
|
}
|
|
578
581
|
if (method.type === "stripe") {
|
|
@@ -583,8 +586,9 @@ export const getTxLink = (method, details) => {
|
|
|
583
586
|
"payments",
|
|
584
587
|
details.stripe?.payment_intent_id
|
|
585
588
|
),
|
|
586
|
-
text: details.stripe?.payment_intent_id
|
|
589
|
+
text: details.stripe?.payment_intent_id,
|
|
590
|
+
gas: ""
|
|
587
591
|
};
|
|
588
592
|
}
|
|
589
|
-
return { text: "N/A", link: "" };
|
|
593
|
+
return { text: "N/A", link: "", gas: "" };
|
|
590
594
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
|
+
declare function TxGas(props: {
|
|
4
|
+
details: PaymentDetails;
|
|
5
|
+
method: TPaymentMethod;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
declare namespace TxGas {
|
|
8
|
+
var defaultProps: {};
|
|
9
|
+
}
|
|
10
|
+
export default TxGas;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = TxGas;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _util = require("@ocap/util");
|
|
11
|
+
var _payment = require("../../contexts/payment");
|
|
12
|
+
var _util2 = require("../../util");
|
|
13
|
+
TxGas.defaultProps = {};
|
|
14
|
+
function TxGas(props) {
|
|
15
|
+
const {
|
|
16
|
+
t
|
|
17
|
+
} = (0, _context.useLocaleContext)();
|
|
18
|
+
const {
|
|
19
|
+
settings
|
|
20
|
+
} = (0, _payment.usePaymentContext)();
|
|
21
|
+
const {
|
|
22
|
+
gas
|
|
23
|
+
} = (0, _util2.getTxLink)(props.method, props.details);
|
|
24
|
+
const method = settings.paymentMethods.find(x => x.id === props.method.id);
|
|
25
|
+
if (gas && method) {
|
|
26
|
+
const currency = method.payment_currencies.find(x => x.id === method.default_currency_id);
|
|
27
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
28
|
+
component: "span",
|
|
29
|
+
children: [(0, _util.fromUnitToToken)(gas, currency.decimal), " ", currency.symbol, " (", method.name, ")"]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
33
|
+
component: "small",
|
|
34
|
+
color: "text.secondary",
|
|
35
|
+
children: t("common.none")
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -26,7 +26,8 @@ function TxLink(props) {
|
|
|
26
26
|
}
|
|
27
27
|
const {
|
|
28
28
|
text,
|
|
29
|
-
link
|
|
29
|
+
link,
|
|
30
|
+
gas
|
|
30
31
|
} = (0, _util.getTxLink)(props.method, props.details);
|
|
31
32
|
if (link) {
|
|
32
33
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
@@ -39,10 +40,10 @@ function TxLink(props) {
|
|
|
39
40
|
alignItems: "center",
|
|
40
41
|
justifyContent: props.align === "left" ? "flex-start" : "flex-end",
|
|
41
42
|
spacing: 1,
|
|
42
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.
|
|
43
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
43
44
|
component: "span",
|
|
44
45
|
color: "primary",
|
|
45
|
-
children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text
|
|
46
|
+
children: [text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text, gas]
|
|
46
47
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.OpenInNewOutlined, {
|
|
47
48
|
fontSize: "small"
|
|
48
49
|
})]
|
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import api from './api';
|
|
|
2
2
|
import CheckoutDonate from './checkout/donate';
|
|
3
3
|
import CheckoutForm from './checkout/form';
|
|
4
4
|
import CheckoutTable from './checkout/table';
|
|
5
|
+
import TxGas from './components/blockchain/gas';
|
|
5
6
|
import TxLink from './components/blockchain/tx';
|
|
6
7
|
import ConfirmDialog from './components/confirm';
|
|
7
8
|
import FormInput from './components/input';
|
|
@@ -25,4 +26,4 @@ import PaymentSummary from './payment/summary';
|
|
|
25
26
|
export * from './util';
|
|
26
27
|
export * from './contexts/payment';
|
|
27
28
|
export { translations, createTranslator } from './locales';
|
|
28
|
-
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, SafeGuard, };
|
|
29
|
+
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, TxGas, SafeGuard, };
|
package/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var _exportNames = {
|
|
|
8
8
|
CheckoutDonate: true,
|
|
9
9
|
CheckoutForm: true,
|
|
10
10
|
CheckoutTable: true,
|
|
11
|
+
TxGas: true,
|
|
11
12
|
TxLink: true,
|
|
12
13
|
ConfirmDialog: true,
|
|
13
14
|
FormInput: true,
|
|
@@ -157,6 +158,12 @@ Object.defineProperty(exports, "Switch", {
|
|
|
157
158
|
return _switchButton.default;
|
|
158
159
|
}
|
|
159
160
|
});
|
|
161
|
+
Object.defineProperty(exports, "TxGas", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function () {
|
|
164
|
+
return _gas.default;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
160
167
|
Object.defineProperty(exports, "TxLink", {
|
|
161
168
|
enumerable: true,
|
|
162
169
|
get: function () {
|
|
@@ -191,6 +198,7 @@ var _api = _interopRequireDefault(require("./api"));
|
|
|
191
198
|
var _donate = _interopRequireDefault(require("./checkout/donate"));
|
|
192
199
|
var _form = _interopRequireDefault(require("./checkout/form"));
|
|
193
200
|
var _table = _interopRequireDefault(require("./checkout/table"));
|
|
201
|
+
var _gas = _interopRequireDefault(require("./components/blockchain/gas"));
|
|
194
202
|
var _tx = _interopRequireDefault(require("./components/blockchain/tx"));
|
|
195
203
|
var _confirm = _interopRequireDefault(require("./components/confirm"));
|
|
196
204
|
var _input = _interopRequireDefault(require("./components/input"));
|
package/lib/locales/en.js
CHANGED
|
@@ -46,6 +46,7 @@ module.exports = (0, _flat.default)({
|
|
|
46
46
|
email: "Email",
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "Transaction",
|
|
49
|
+
txGas: "Transaction Gas",
|
|
49
50
|
delegateTxHash: "Delegate Transaction",
|
|
50
51
|
stakeTxHash: "Stake Transaction",
|
|
51
52
|
slashTxHash: "Slash Transaction",
|
|
@@ -170,6 +171,10 @@ module.exports = (0, _flat.default)({
|
|
|
170
171
|
complete: {
|
|
171
172
|
title: "Checkout Completed",
|
|
172
173
|
description: "This checkout session has completed. This means that your payment has already been successfully processed."
|
|
174
|
+
},
|
|
175
|
+
emptyItems: {
|
|
176
|
+
title: "Nothing to show here",
|
|
177
|
+
description: "Seems this checkoutSession is not configured properly"
|
|
173
178
|
}
|
|
174
179
|
},
|
|
175
180
|
customer: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -46,6 +46,7 @@ module.exports = (0, _flat.default)({
|
|
|
46
46
|
email: "\u90AE\u7BB1",
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "\u4EA4\u6613\u54C8\u5E0C",
|
|
49
|
+
txGas: "\u4EA4\u6613\u8D39\u7528",
|
|
49
50
|
delegateTxHash: "\u6388\u6743\u4EA4\u6613",
|
|
50
51
|
stakeTxHash: "\u8D28\u62BC\u4EA4\u6613",
|
|
51
52
|
slashTxHash: "\u7F5A\u6CA1\u4EA4\u6613",
|
|
@@ -170,6 +171,10 @@ module.exports = (0, _flat.default)({
|
|
|
170
171
|
cross_sell: {
|
|
171
172
|
add: "\u6DFB\u52A0\u5230\u8BA2\u5355",
|
|
172
173
|
remove: "\u4ECE\u8BA2\u5355\u79FB\u9664"
|
|
174
|
+
},
|
|
175
|
+
emptyItems: {
|
|
176
|
+
title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
|
|
177
|
+
description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
|
|
173
178
|
}
|
|
174
179
|
},
|
|
175
180
|
customer: {
|
package/lib/payment/index.js
CHANGED
|
@@ -114,6 +114,13 @@ function Payment({
|
|
|
114
114
|
description: t("payment.checkout.complete.description")
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
+
if (!checkoutSession.line_items.length) {
|
|
118
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_error.default, {
|
|
119
|
+
mode,
|
|
120
|
+
title: t("payment.checkout.emptyItems.title"),
|
|
121
|
+
description: t("payment.checkout.emptyItems.description")
|
|
122
|
+
});
|
|
123
|
+
}
|
|
117
124
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(PaymentInner, {
|
|
118
125
|
checkoutSession,
|
|
119
126
|
paymentMethods,
|
package/lib/util.d.ts
CHANGED
package/lib/util.js
CHANGED
|
@@ -675,31 +675,36 @@ const getTxLink = (method, details) => {
|
|
|
675
675
|
if (method.type === "arcblock" && details.arcblock?.tx_hash) {
|
|
676
676
|
return {
|
|
677
677
|
link: (0, _ufo.joinURL)(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
|
|
678
|
-
text: details.arcblock?.tx_hash
|
|
678
|
+
text: details.arcblock?.tx_hash,
|
|
679
|
+
gas: ""
|
|
679
680
|
};
|
|
680
681
|
}
|
|
681
682
|
if (method.type === "bitcoin" && details.bitcoin?.tx_hash) {
|
|
682
683
|
return {
|
|
683
684
|
link: (0, _ufo.joinURL)(method.settings.bitcoin?.explorer_host, "/tx", details.bitcoin?.tx_hash),
|
|
684
|
-
text: details.bitcoin?.tx_hash
|
|
685
|
+
text: details.bitcoin?.tx_hash,
|
|
686
|
+
gas: ""
|
|
685
687
|
};
|
|
686
688
|
}
|
|
687
689
|
if (method.type === "ethereum" && details.ethereum?.tx_hash) {
|
|
688
690
|
return {
|
|
689
691
|
link: (0, _ufo.joinURL)(method.settings.ethereum?.explorer_host, "/tx", details.ethereum?.tx_hash),
|
|
690
|
-
text: details.ethereum?.tx_hash
|
|
692
|
+
text: (details.ethereum?.tx_hash).toUpperCase(),
|
|
693
|
+
gas: new _util.BN(details.ethereum.gas_price).mul(new _util.BN(details.ethereum.gas_used)).toString()
|
|
691
694
|
};
|
|
692
695
|
}
|
|
693
696
|
if (method.type === "stripe") {
|
|
694
697
|
const dashboard = method.livemode ? "https://dashboard.stripe.com" : "https://dashboard.stripe.com/test";
|
|
695
698
|
return {
|
|
696
699
|
link: (0, _ufo.joinURL)(method.settings.stripe?.dashboard || dashboard, "payments", details.stripe?.payment_intent_id),
|
|
697
|
-
text: details.stripe?.payment_intent_id
|
|
700
|
+
text: details.stripe?.payment_intent_id,
|
|
701
|
+
gas: ""
|
|
698
702
|
};
|
|
699
703
|
}
|
|
700
704
|
return {
|
|
701
705
|
text: "N/A",
|
|
702
|
-
link: ""
|
|
706
|
+
link: "",
|
|
707
|
+
gas: ""
|
|
703
708
|
};
|
|
704
709
|
};
|
|
705
710
|
exports.getTxLink = getTxLink;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.230",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.24.4",
|
|
91
91
|
"@babel/preset-env": "^7.24.4",
|
|
92
92
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.230",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.17",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.17",
|
|
96
96
|
"@storybook/addon-links": "^7.6.17",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "c7209ae95049960f39b4e9eb65714626fb56ceab"
|
|
123
123
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
|
+
import { Typography } from '@mui/material';
|
|
4
|
+
import { fromUnitToToken } from '@ocap/util';
|
|
5
|
+
|
|
6
|
+
import { usePaymentContext } from '../../contexts/payment';
|
|
7
|
+
import { getTxLink } from '../../util';
|
|
8
|
+
|
|
9
|
+
TxGas.defaultProps = {};
|
|
10
|
+
|
|
11
|
+
export default function TxGas(props: { details: PaymentDetails; method: TPaymentMethod }) {
|
|
12
|
+
const { t } = useLocaleContext();
|
|
13
|
+
const { settings } = usePaymentContext();
|
|
14
|
+
|
|
15
|
+
const { gas } = getTxLink(props.method, props.details);
|
|
16
|
+
|
|
17
|
+
const method = settings.paymentMethods.find((x) => x.id === props.method.id);
|
|
18
|
+
if (gas && method) {
|
|
19
|
+
const currency = method.payment_currencies.find((x) => x.id === method.default_currency_id);
|
|
20
|
+
return (
|
|
21
|
+
<Typography component="span">
|
|
22
|
+
{fromUnitToToken(gas, currency!.decimal)} {currency!.symbol} ({method.name})
|
|
23
|
+
</Typography>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Typography component="small" color="text.secondary">
|
|
29
|
+
{t('common.none')}
|
|
30
|
+
</Typography>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -26,7 +26,7 @@ export default function TxLink(props: {
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const { text, link } = getTxLink(props.method, props.details);
|
|
29
|
+
const { text, link, gas } = getTxLink(props.method, props.details);
|
|
30
30
|
|
|
31
31
|
if (link) {
|
|
32
32
|
return (
|
|
@@ -39,6 +39,7 @@ export default function TxLink(props: {
|
|
|
39
39
|
spacing={1}>
|
|
40
40
|
<Typography component="span" color="primary">
|
|
41
41
|
{text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join('...') : text}
|
|
42
|
+
{gas}
|
|
42
43
|
</Typography>
|
|
43
44
|
<OpenInNewOutlined fontSize="small" />
|
|
44
45
|
</Stack>
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import api from './api';
|
|
|
2
2
|
import CheckoutDonate from './checkout/donate';
|
|
3
3
|
import CheckoutForm from './checkout/form';
|
|
4
4
|
import CheckoutTable from './checkout/table';
|
|
5
|
+
import TxGas from './components/blockchain/gas';
|
|
5
6
|
import TxLink from './components/blockchain/tx';
|
|
6
7
|
import ConfirmDialog from './components/confirm';
|
|
7
8
|
import FormInput from './components/input';
|
|
@@ -52,5 +53,6 @@ export {
|
|
|
52
53
|
CustomerPaymentList,
|
|
53
54
|
MiniInvoiceList,
|
|
54
55
|
TxLink,
|
|
56
|
+
TxGas,
|
|
55
57
|
SafeGuard,
|
|
56
58
|
};
|
package/src/locales/en.tsx
CHANGED
|
@@ -40,6 +40,7 @@ export default flat({
|
|
|
40
40
|
email: 'Email',
|
|
41
41
|
did: 'DID',
|
|
42
42
|
txHash: 'Transaction',
|
|
43
|
+
txGas: 'Transaction Gas',
|
|
43
44
|
delegateTxHash: 'Delegate Transaction',
|
|
44
45
|
stakeTxHash: 'Stake Transaction',
|
|
45
46
|
slashTxHash: 'Slash Transaction',
|
|
@@ -169,6 +170,10 @@ export default flat({
|
|
|
169
170
|
description:
|
|
170
171
|
'This checkout session has completed. This means that your payment has already been successfully processed.',
|
|
171
172
|
},
|
|
173
|
+
emptyItems: {
|
|
174
|
+
title: 'Nothing to show here',
|
|
175
|
+
description: 'Seems this checkoutSession is not configured properly',
|
|
176
|
+
},
|
|
172
177
|
},
|
|
173
178
|
customer: {
|
|
174
179
|
payments: 'Payment History',
|
package/src/locales/zh.tsx
CHANGED
|
@@ -40,6 +40,7 @@ export default flat({
|
|
|
40
40
|
email: '邮箱',
|
|
41
41
|
did: 'DID',
|
|
42
42
|
txHash: '交易哈希',
|
|
43
|
+
txGas: '交易费用',
|
|
43
44
|
delegateTxHash: '授权交易',
|
|
44
45
|
stakeTxHash: '质押交易',
|
|
45
46
|
slashTxHash: '罚没交易',
|
|
@@ -166,6 +167,10 @@ export default flat({
|
|
|
166
167
|
add: '添加到订单',
|
|
167
168
|
remove: '从订单移除',
|
|
168
169
|
},
|
|
170
|
+
emptyItems: {
|
|
171
|
+
title: '没有任何购买项目',
|
|
172
|
+
description: '可能这个付款链接没有正确配置',
|
|
173
|
+
},
|
|
169
174
|
},
|
|
170
175
|
customer: {
|
|
171
176
|
payments: '支付历史',
|
package/src/payment/index.tsx
CHANGED
|
@@ -116,6 +116,16 @@ export default function Payment({
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
if (!checkoutSession.line_items.length) {
|
|
120
|
+
return (
|
|
121
|
+
<PaymentError
|
|
122
|
+
mode={mode}
|
|
123
|
+
title={t('payment.checkout.emptyItems.title')}
|
|
124
|
+
description={t('payment.checkout.emptyItems.description')}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
119
129
|
return (
|
|
120
130
|
<PaymentInner
|
|
121
131
|
checkoutSession={checkoutSession}
|
package/src/util.ts
CHANGED
|
@@ -742,18 +742,21 @@ export const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
|
|
|
742
742
|
return {
|
|
743
743
|
link: joinURL(method.settings.arcblock?.explorer_host as string, '/txs', details.arcblock?.tx_hash as string),
|
|
744
744
|
text: details.arcblock?.tx_hash as string,
|
|
745
|
+
gas: '',
|
|
745
746
|
};
|
|
746
747
|
}
|
|
747
748
|
if (method.type === 'bitcoin' && details.bitcoin?.tx_hash) {
|
|
748
749
|
return {
|
|
749
750
|
link: joinURL(method.settings.bitcoin?.explorer_host as string, '/tx', details.bitcoin?.tx_hash as string),
|
|
750
751
|
text: details.bitcoin?.tx_hash as string,
|
|
752
|
+
gas: '',
|
|
751
753
|
};
|
|
752
754
|
}
|
|
753
755
|
if (method.type === 'ethereum' && details.ethereum?.tx_hash) {
|
|
754
756
|
return {
|
|
755
757
|
link: joinURL(method.settings.ethereum?.explorer_host as string, '/tx', details.ethereum?.tx_hash as string),
|
|
756
|
-
text: details.ethereum?.tx_hash as string,
|
|
758
|
+
text: (details.ethereum?.tx_hash as string).toUpperCase(),
|
|
759
|
+
gas: new BN(details.ethereum.gas_price).mul(new BN(details.ethereum.gas_used)).toString(),
|
|
757
760
|
};
|
|
758
761
|
}
|
|
759
762
|
if (method.type === 'stripe') {
|
|
@@ -765,8 +768,9 @@ export const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
|
|
|
765
768
|
details.stripe?.payment_intent_id as string
|
|
766
769
|
),
|
|
767
770
|
text: details.stripe?.payment_intent_id as string,
|
|
771
|
+
gas: '',
|
|
768
772
|
};
|
|
769
773
|
}
|
|
770
774
|
|
|
771
|
-
return { text: 'N/A', link: '' };
|
|
775
|
+
return { text: 'N/A', link: '', gas: '' };
|
|
772
776
|
};
|