payment-kit 1.13.259 → 1.13.261

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/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.13.259
17
+ version: 1.13.261
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.259",
3
+ "version": "1.13.261",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -43,28 +43,28 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@abtnode/cron": "1.16.26",
46
- "@arcblock/did": "^1.18.117",
46
+ "@arcblock/did": "^1.18.120",
47
47
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
48
- "@arcblock/did-connect": "^2.9.79",
49
- "@arcblock/did-util": "^1.18.117",
50
- "@arcblock/jwt": "^1.18.117",
51
- "@arcblock/ux": "^2.9.79",
52
- "@arcblock/validator": "^1.18.117",
48
+ "@arcblock/did-connect": "^2.9.80",
49
+ "@arcblock/did-util": "^1.18.120",
50
+ "@arcblock/jwt": "^1.18.120",
51
+ "@arcblock/ux": "^2.9.80",
52
+ "@arcblock/validator": "^1.18.120",
53
53
  "@blocklet/logger": "1.16.26",
54
- "@blocklet/payment-react": "1.13.259",
54
+ "@blocklet/payment-react": "1.13.261",
55
55
  "@blocklet/sdk": "1.16.26",
56
- "@blocklet/ui-react": "^2.9.79",
56
+ "@blocklet/ui-react": "^2.9.80",
57
57
  "@blocklet/uploader": "^0.1.6",
58
- "@mui/icons-material": "^5.15.17",
58
+ "@mui/icons-material": "^5.15.18",
59
59
  "@mui/lab": "^5.0.0-alpha.170",
60
- "@mui/material": "^5.15.17",
61
- "@mui/styles": "^5.15.17",
60
+ "@mui/material": "^5.15.18",
61
+ "@mui/styles": "^5.15.18",
62
62
  "@mui/system": "^5.15.15",
63
- "@ocap/asset": "^1.18.117",
64
- "@ocap/client": "^1.18.117",
65
- "@ocap/mcrypto": "^1.18.117",
66
- "@ocap/util": "^1.18.117",
67
- "@ocap/wallet": "^1.18.117",
63
+ "@ocap/asset": "^1.18.120",
64
+ "@ocap/client": "^1.18.120",
65
+ "@ocap/mcrypto": "^1.18.120",
66
+ "@ocap/util": "^1.18.120",
67
+ "@ocap/wallet": "^1.18.120",
68
68
  "@react-pdf/renderer": "^3.4.4",
69
69
  "@stripe/react-stripe-js": "^2.7.1",
70
70
  "@stripe/stripe-js": "^2.4.0",
@@ -116,7 +116,7 @@
116
116
  "devDependencies": {
117
117
  "@abtnode/types": "1.16.26",
118
118
  "@arcblock/eslint-config-ts": "^0.3.0",
119
- "@blocklet/payment-types": "1.13.259",
119
+ "@blocklet/payment-types": "1.13.261",
120
120
  "@types/cookie-parser": "^1.4.7",
121
121
  "@types/cors": "^2.8.17",
122
122
  "@types/dotenv-flow": "^3.3.3",
@@ -155,5 +155,5 @@
155
155
  "parser": "typescript"
156
156
  }
157
157
  },
158
- "gitHead": "54eed6876c292c39219f953625d88cf314347105"
158
+ "gitHead": "30f66652a71168cbd4050639527dc7dbf15b12bb"
159
159
  }
@@ -1,5 +1,5 @@
1
1
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
2
- import { formatAmount, formatToDate } from '@blocklet/payment-react';
2
+ import { formatAmount, formatToDate, getPriceUintAmountByCurrency } from '@blocklet/payment-react';
3
3
  import type { TInvoiceExpanded, TInvoiceItem } from '@blocklet/payment-types';
4
4
  import { InfoOutlined } from '@mui/icons-material';
5
5
  import { Box, Stack, Table, TableBody, TableCell, TableHead, TableRow, Tooltip, Typography } from '@mui/material';
@@ -53,19 +53,23 @@ export function getAppliedBalance(invoice: TInvoiceExpanded) {
53
53
  }
54
54
 
55
55
  export function getInvoiceRows(invoice: TInvoiceExpanded) {
56
- const detail: InvoiceDetailItem[] = invoice.lines.map((line) => ({
57
- id: line.id,
58
- product: `${line.description} ${
59
- line.price.product.unit_label ? ` (per ${line.price.product.unit_label})` : ''
60
- }`.trim(),
61
- quantity: line.quantity,
62
- rawQuantity: line.metadata?.quantity || 0,
63
- price: !line.proration
64
- ? formatAmount(toBN(line.amount).div(toBN(line.quantity)).toString(), invoice.paymentCurrency.decimal) // prettier-ignore
65
- : '',
66
- amount: formatAmount(line.amount, invoice.paymentCurrency.decimal),
67
- raw: line,
68
- }));
56
+ const detail: InvoiceDetailItem[] = invoice.lines.map((line) => {
57
+ const price = line.quantity
58
+ ? toBN(line.amount).div(toBN(line.quantity)).toString()
59
+ : getPriceUintAmountByCurrency(line.price, invoice.paymentCurrency) || line.amount;
60
+
61
+ return {
62
+ id: line.id,
63
+ product: `${line.description} ${
64
+ line.price.product.unit_label ? ` (per ${line.price.product.unit_label})` : ''
65
+ }`.trim(),
66
+ quantity: line.quantity,
67
+ rawQuantity: line.metadata?.quantity || 0,
68
+ price: !line.proration ? formatAmount(price, invoice.paymentCurrency.decimal) : '',
69
+ amount: formatAmount(line.amount, invoice.paymentCurrency.decimal),
70
+ raw: line,
71
+ };
72
+ });
69
73
 
70
74
  const summary: InvoiceSummaryItem[] = [
71
75
  {
@@ -15,7 +15,7 @@ import { ArrowBackOutlined } from '@mui/icons-material';
15
15
  import { LoadingButton } from '@mui/lab';
16
16
  import { Alert, CircularProgress, Divider, Stack, Typography } from '@mui/material';
17
17
  import { useRequest, useSetState } from 'ahooks';
18
- import { useNavigate, useParams } from 'react-router-dom';
18
+ import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
19
19
 
20
20
  import InfoCard from '../../../components/info-card';
21
21
  import SectionHeader from '../../../components/section/header';
@@ -53,6 +53,8 @@ export default function CustomerSubscriptionChangePlan() {
53
53
  const { id } = useParams() as { id: string };
54
54
  const { t, locale } = useLocaleContext();
55
55
  const { connect } = usePaymentContext();
56
+ const [searchParams] = useSearchParams();
57
+ const redirectUrl = searchParams.get('redirectUrl');
56
58
 
57
59
  const { loading, error, data } = useRequest(() => fetchData(id));
58
60
  const [state, setState] = useSetState({
@@ -70,7 +72,7 @@ export default function CustomerSubscriptionChangePlan() {
70
72
  });
71
73
 
72
74
  if (error) {
73
- return <Alert severity="error">{error.message}</Alert>;
75
+ return <Alert severity="error">{formatError(error)}</Alert>;
74
76
  }
75
77
 
76
78
  if (loading || !data) {
@@ -120,7 +122,11 @@ export default function CustomerSubscriptionChangePlan() {
120
122
  };
121
123
 
122
124
  const handleBack = () => {
123
- navigate(`/customer/subscription/${data.subscription.id}`);
125
+ if (redirectUrl) {
126
+ window.location.href = redirectUrl;
127
+ } else {
128
+ navigate(`/customer/subscription/${data.subscription.id}`);
129
+ }
124
130
  };
125
131
 
126
132
  const handleConfirm = async () => {