@blocklet/payment-react 1.13.227 → 1.13.229

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.
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { PaymentDetails, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
3
+ declare function TxGas(props: {
4
+ details: PaymentDetails;
5
+ currency: TPaymentCurrency;
6
+ method: TPaymentMethod;
7
+ }): import("react").JSX.Element;
8
+ declare namespace TxGas {
9
+ var defaultProps: {};
10
+ }
11
+ export default TxGas;
@@ -0,0 +1,21 @@
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 { getTxLink } from "../../util.js";
6
+ TxGas.defaultProps = {};
7
+ export default function TxGas(props) {
8
+ const { t } = useLocaleContext();
9
+ const { gas } = getTxLink(props.method, props.details);
10
+ if (gas) {
11
+ return /* @__PURE__ */ jsxs(Typography, { component: "span", children: [
12
+ fromUnitToToken(gas, props.currency.decimal),
13
+ " ",
14
+ props.currency.symbol,
15
+ " (",
16
+ props.method.name,
17
+ ")"
18
+ ] });
19
+ }
20
+ return /* @__PURE__ */ jsx(Typography, { component: "small", color: "text.secondary", children: t("common.none") });
21
+ }
@@ -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__ */ jsx(Typography, { component: "span", color: "primary", children: text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join("...") : text }),
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: {
@@ -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
@@ -65,4 +65,5 @@ export declare const flattenPaymentMethods: (methods?: TPaymentMethodExpanded[])
65
65
  export declare const getTxLink: (method: TPaymentMethod, details: PaymentDetails) => {
66
66
  link: string;
67
67
  text: string;
68
+ gas: any;
68
69
  };
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,11 @@
1
+ /// <reference types="react" />
2
+ import type { PaymentDetails, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
3
+ declare function TxGas(props: {
4
+ details: PaymentDetails;
5
+ currency: TPaymentCurrency;
6
+ method: TPaymentMethod;
7
+ }): import("react").JSX.Element;
8
+ declare namespace TxGas {
9
+ var defaultProps: {};
10
+ }
11
+ export default TxGas;
@@ -0,0 +1,31 @@
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 _util2 = require("../../util");
12
+ TxGas.defaultProps = {};
13
+ function TxGas(props) {
14
+ const {
15
+ t
16
+ } = (0, _context.useLocaleContext)();
17
+ const {
18
+ gas
19
+ } = (0, _util2.getTxLink)(props.method, props.details);
20
+ if (gas) {
21
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
22
+ component: "span",
23
+ children: [(0, _util.fromUnitToToken)(gas, props.currency.decimal), " ", props.currency.symbol, " (", props.method.name, ")"]
24
+ });
25
+ }
26
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
27
+ component: "small",
28
+ color: "text.secondary",
29
+ children: t("common.none")
30
+ });
31
+ }
@@ -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.jsx)(_material.Typography, {
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: {
@@ -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
@@ -65,4 +65,5 @@ export declare const flattenPaymentMethods: (methods?: TPaymentMethodExpanded[])
65
65
  export declare const getTxLink: (method: TPaymentMethod, details: PaymentDetails) => {
66
66
  link: string;
67
67
  text: string;
68
+ gas: any;
68
69
  };
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.227",
3
+ "version": "1.13.229",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -52,29 +52,29 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@arcblock/did-connect": "^2.9.66",
56
- "@arcblock/ux": "^2.9.66",
57
- "@mui/icons-material": "^5.15.14",
58
- "@mui/lab": "^5.0.0-alpha.169",
59
- "@mui/material": "^5.15.14",
60
- "@mui/styles": "^5.15.14",
61
- "@mui/system": "^5.15.14",
55
+ "@arcblock/did-connect": "^2.9.68",
56
+ "@arcblock/ux": "^2.9.68",
57
+ "@mui/icons-material": "^5.15.15",
58
+ "@mui/lab": "^5.0.0-alpha.170",
59
+ "@mui/material": "^5.15.15",
60
+ "@mui/styles": "^5.15.15",
61
+ "@mui/system": "^5.15.15",
62
62
  "@ocap/util": "^1.18.115",
63
- "@stripe/react-stripe-js": "^2.4.0",
63
+ "@stripe/react-stripe-js": "^2.7.0",
64
64
  "@stripe/stripe-js": "^2.4.0",
65
65
  "@vitejs/plugin-legacy": "^5.3.2",
66
- "ahooks": "^3.7.10",
66
+ "ahooks": "^3.7.11",
67
67
  "axios": "^0.27.2",
68
68
  "dayjs": "^1.11.10",
69
69
  "flat": "^5.0.2",
70
70
  "google-libphonenumber": "^3.2.34",
71
71
  "lodash": "^4.17.21",
72
- "numbro": "^2.4.0",
72
+ "numbro": "^2.5.0",
73
73
  "p-wait-for": "3",
74
- "react-error-boundary": "^4.0.12",
75
- "react-hook-form": "^7.50.1",
74
+ "react-error-boundary": "^4.0.13",
75
+ "react-hook-form": "^7.51.3",
76
76
  "react-international-phone": "^3.1.2",
77
- "ufo": "^1.4.0",
77
+ "ufo": "^1.5.3",
78
78
  "use-bus": "^2.5.2",
79
79
  "validator": "^13.11.0"
80
80
  },
@@ -86,24 +86,24 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "@arcblock/eslint-config-ts": "^0.3.0",
89
- "@babel/cli": "^7.23.9",
90
- "@babel/core": "^7.23.9",
91
- "@babel/preset-env": "^7.23.9",
92
- "@babel/preset-react": "^7.23.3",
93
- "@blocklet/payment-types": "1.13.227",
94
- "@storybook/addon-essentials": "^7.6.13",
95
- "@storybook/addon-interactions": "^7.6.13",
96
- "@storybook/addon-links": "^7.6.13",
89
+ "@babel/cli": "^7.24.1",
90
+ "@babel/core": "^7.24.4",
91
+ "@babel/preset-env": "^7.24.4",
92
+ "@babel/preset-react": "^7.24.1",
93
+ "@blocklet/payment-types": "1.13.229",
94
+ "@storybook/addon-essentials": "^7.6.17",
95
+ "@storybook/addon-interactions": "^7.6.17",
96
+ "@storybook/addon-links": "^7.6.17",
97
97
  "@storybook/addon-onboarding": "^1.0.11",
98
- "@storybook/blocks": "^7.6.13",
99
- "@storybook/react": "^7.6.13",
100
- "@storybook/react-vite": "^7",
101
- "@storybook/test": "^7.6.13",
102
- "@types/react": "^18.2.55",
103
- "@types/react-dom": "^18.2.18",
98
+ "@storybook/blocks": "^7.6.17",
99
+ "@storybook/react": "^7.6.17",
100
+ "@storybook/react-vite": "^7.6.17",
101
+ "@storybook/test": "^7.6.17",
102
+ "@types/react": "^18.2.79",
103
+ "@types/react-dom": "^18.2.25",
104
104
  "@vitejs/plugin-legacy": "^5.3.2",
105
- "eslint": "^8.56.0",
106
- "glob": "^10.3.10",
105
+ "eslint": "^8.57.0",
106
+ "glob": "^10.3.12",
107
107
  "import-sort-style-module": "^6.0.0",
108
108
  "jest": "^29.7.0",
109
109
  "prettier": "^2.8.8",
@@ -111,13 +111,13 @@
111
111
  "react": "^18.2.0",
112
112
  "react-dom": "^18.2.0",
113
113
  "rollup-plugin-node-builtins": "^2.1.2",
114
- "storybook": "^7.6.13",
114
+ "storybook": "^7.6.17",
115
115
  "ts-jest": "^29.1.2",
116
- "type-fest": "^4.10.2",
116
+ "type-fest": "^4.15.0",
117
117
  "typescript": "^4.9.5",
118
118
  "unbuild": "^2.0.0",
119
119
  "vite-plugin-babel": "^1.2.0",
120
120
  "vite-plugin-node-polyfills": "^0.21.0"
121
121
  },
122
- "gitHead": "3e95c9ec26b62050424aca405a6f4199de9877d8"
122
+ "gitHead": "7def3178288871dff00ba89e16c5adcec6d4dfc9"
123
123
  }
@@ -0,0 +1,28 @@
1
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
+ import type { PaymentDetails, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
3
+ import { Typography } from '@mui/material';
4
+ import { fromUnitToToken } from '@ocap/util';
5
+
6
+ import { getTxLink } from '../../util';
7
+
8
+ TxGas.defaultProps = {};
9
+
10
+ export default function TxGas(props: { details: PaymentDetails; currency: TPaymentCurrency; method: TPaymentMethod }) {
11
+ const { t } = useLocaleContext();
12
+
13
+ const { gas } = getTxLink(props.method, props.details);
14
+
15
+ if (gas) {
16
+ return (
17
+ <Typography component="span">
18
+ {fromUnitToToken(gas, props.currency.decimal)} {props.currency.symbol} ({props.method.name})
19
+ </Typography>
20
+ );
21
+ }
22
+
23
+ return (
24
+ <Typography component="small" color="text.secondary">
25
+ {t('common.none')}
26
+ </Typography>
27
+ );
28
+ }
@@ -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
  };
@@ -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',
@@ -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: '支付历史',
@@ -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
  };