@blocklet/payment-react 1.16.3 → 1.16.5
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/README.md +34 -0
- package/es/checkout/table.js +6 -1
- package/es/components/country-select.d.ts +1 -6
- package/es/components/country-select.js +8 -9
- package/es/components/over-due-invoice-payment.d.ts +38 -0
- package/es/components/over-due-invoice-payment.js +238 -0
- package/es/components/pricing-table.js +3 -5
- package/es/components/table.js +2 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +17 -1
- package/es/locales/zh.js +17 -1
- package/es/payment/summary.js +2 -0
- package/lib/checkout/table.js +4 -1
- package/lib/components/country-select.d.ts +1 -6
- package/lib/components/country-select.js +9 -11
- package/lib/components/over-due-invoice-payment.d.ts +38 -0
- package/lib/components/over-due-invoice-payment.js +285 -0
- package/lib/components/pricing-table.js +3 -5
- package/lib/components/table.js +2 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +17 -1
- package/lib/locales/zh.js +17 -1
- package/lib/payment/summary.js +2 -0
- package/package.json +8 -8
- package/src/checkout/table.tsx +6 -1
- package/src/components/country-select.tsx +10 -12
- package/src/components/over-due-invoice-payment.tsx +306 -0
- package/src/components/pricing-table.tsx +4 -6
- package/src/components/table.tsx +2 -0
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +18 -0
- package/src/locales/zh.tsx +18 -0
- package/src/payment/summary.tsx +2 -0
package/README.md
CHANGED
|
@@ -394,6 +394,40 @@ We recommend using `showCheckoutSummary={false}` instead of `mode=inline-minimal
|
|
|
394
394
|
/>
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
+
### v1.16.4
|
|
398
|
+
|
|
399
|
+
- Add `OverdueInvoicePayment` component
|
|
400
|
+
- display all overdue invoices of a subscription, and support batch payment
|
|
401
|
+
- props:
|
|
402
|
+
- `subscriptionId`: [required] the id of the subscription
|
|
403
|
+
- `onPaid`: [optional] a callback function that will be called when the payment is successful
|
|
404
|
+
- `mode`: [optional] the mode of the component, `default` or `custom`, default is `default`
|
|
405
|
+
- `dialogProps`: [optional] the props of the dialog, default is `{ open: true }`
|
|
406
|
+
- `children`: [optional] a function that will be called with the payment data, if `mode` is `custom`, otherwise, the default dialog will be displayed
|
|
407
|
+
- custom mode:
|
|
408
|
+
- the `children` will receive two parameters:
|
|
409
|
+
- `handlePay`: a function that starts the payment process
|
|
410
|
+
- `data`: the payment data
|
|
411
|
+
- `subscription`: the subscription data
|
|
412
|
+
- `summary`: the summary of the payment, the key is the `currencyId`, the value includes `amount`, `currency`, `method`
|
|
413
|
+
- `invoices`: the list of invoices
|
|
414
|
+
- `subscriptionUrl`: the url of the subscription
|
|
415
|
+
```tsx
|
|
416
|
+
<OverdueInvoicePayment subscriptionId={data.id} onPaid={() => { console.log('paid') }} />
|
|
417
|
+
|
|
418
|
+
// custom mode
|
|
419
|
+
<OverdueInvoicePayment subscriptionId={data.id} onPaid={() => { console.log('paid') }} mode="custom">
|
|
420
|
+
{(handlePay, { subscription, summary, invoices, subscriptionUrl }) => (
|
|
421
|
+
<div>custom content</div>
|
|
422
|
+
<p>Subscription: {subscription.name}</p>
|
|
423
|
+
<p>Current currency Total: {summary[currencyId].amount}</p>
|
|
424
|
+
<p>Invoices: {invoices.length}</p>
|
|
425
|
+
<p>Subscription URL: {subscriptionUrl}</p>
|
|
426
|
+
<button onClick={() => handlePay(summary[currencyId])}>Pay</button>
|
|
427
|
+
)}
|
|
428
|
+
</OverdueInvoicePayment>
|
|
429
|
+
```
|
|
430
|
+
|
|
397
431
|
### Status & Utility Components
|
|
398
432
|
```tsx
|
|
399
433
|
import {
|
package/es/checkout/table.js
CHANGED
|
@@ -40,7 +40,12 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
40
40
|
return /* @__PURE__ */ jsx(Alert, { severity: "warning", children: t("payment.checkout.noPricing") });
|
|
41
41
|
}
|
|
42
42
|
const handleSelect = (priceId, currencyId) => {
|
|
43
|
-
api.post(
|
|
43
|
+
api.post(
|
|
44
|
+
`/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams({
|
|
45
|
+
...extraParams,
|
|
46
|
+
currencyId
|
|
47
|
+
})}`
|
|
48
|
+
).then((res) => {
|
|
44
49
|
if (mode === "standalone") {
|
|
45
50
|
let { url } = res.data;
|
|
46
51
|
url = url.indexOf("?") > -1 ? `${url}¤cyId=${currencyId}` : `${url}?currencyId=${currencyId}`;
|
|
@@ -7,10 +7,5 @@ export type CountrySelectProps = {
|
|
|
7
7
|
name: string;
|
|
8
8
|
sx?: SxProps;
|
|
9
9
|
};
|
|
10
|
-
declare
|
|
11
|
-
declare namespace CountrySelect {
|
|
12
|
-
var defaultProps: {
|
|
13
|
-
sx: {};
|
|
14
|
-
};
|
|
15
|
-
}
|
|
10
|
+
declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
11
|
export default CountrySelect;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
2
|
+
import { useMemo, forwardRef } from "react";
|
|
3
3
|
import { Box, MenuItem, Select, Typography } from "@mui/material";
|
|
4
4
|
import { useFormContext } from "react-hook-form";
|
|
5
5
|
import { FlagEmoji, defaultCountries, parseCountry } from "react-international-phone";
|
|
6
|
-
CountrySelect
|
|
7
|
-
sx: {}
|
|
8
|
-
};
|
|
9
|
-
export default function CountrySelect({ value, onChange, name, sx }) {
|
|
6
|
+
const CountrySelect = forwardRef(({ value, onChange, name, sx }, ref) => {
|
|
10
7
|
const { setValue } = useFormContext();
|
|
11
8
|
const countryDetail = useMemo(() => {
|
|
12
9
|
const item = defaultCountries.find((v) => v[1] === value);
|
|
@@ -19,6 +16,7 @@ export default function CountrySelect({ value, onChange, name, sx }) {
|
|
|
19
16
|
return /* @__PURE__ */ jsx(
|
|
20
17
|
Select,
|
|
21
18
|
{
|
|
19
|
+
ref,
|
|
22
20
|
MenuProps: {
|
|
23
21
|
style: {
|
|
24
22
|
height: "300px",
|
|
@@ -35,7 +33,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
|
|
|
35
33
|
},
|
|
36
34
|
sx: {
|
|
37
35
|
width: "100%",
|
|
38
|
-
// Remove default outline (display only on focus)
|
|
39
36
|
fieldset: {
|
|
40
37
|
display: "none"
|
|
41
38
|
},
|
|
@@ -44,7 +41,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
|
|
|
44
41
|
display: "block"
|
|
45
42
|
}
|
|
46
43
|
},
|
|
47
|
-
// Update default spacing
|
|
48
44
|
".MuiSelect-select": {
|
|
49
45
|
padding: "8px",
|
|
50
46
|
paddingRight: "24px !important"
|
|
@@ -54,7 +50,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
|
|
|
54
50
|
},
|
|
55
51
|
".MuiMenuItem-root": {
|
|
56
52
|
justifyContent: "flex-start"
|
|
57
|
-
// 确保内容左对齐
|
|
58
53
|
},
|
|
59
54
|
...sx
|
|
60
55
|
},
|
|
@@ -79,4 +74,8 @@ export default function CountrySelect({ value, onChange, name, sx }) {
|
|
|
79
74
|
})
|
|
80
75
|
}
|
|
81
76
|
);
|
|
82
|
-
}
|
|
77
|
+
});
|
|
78
|
+
CountrySelect.defaultProps = {
|
|
79
|
+
sx: {}
|
|
80
|
+
};
|
|
81
|
+
export default CountrySelect;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Invoice, PaymentCurrency, PaymentMethod, Subscription } from '@blocklet/payment-types';
|
|
3
|
+
type DialogProps = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
type Props = {
|
|
9
|
+
subscriptionId: string;
|
|
10
|
+
mode?: 'default' | 'custom';
|
|
11
|
+
onPaid?: (subscriptionId: string, currencyId: string) => void;
|
|
12
|
+
dialogProps?: DialogProps;
|
|
13
|
+
children?: (handlePay: (item: SummaryItem) => void, data: {
|
|
14
|
+
subscription: Subscription;
|
|
15
|
+
summary: {
|
|
16
|
+
[key: string]: SummaryItem;
|
|
17
|
+
};
|
|
18
|
+
invoices: Invoice[];
|
|
19
|
+
subscriptionUrl: string;
|
|
20
|
+
}) => React.ReactNode;
|
|
21
|
+
};
|
|
22
|
+
type SummaryItem = {
|
|
23
|
+
amount: string;
|
|
24
|
+
currency: PaymentCurrency;
|
|
25
|
+
method: PaymentMethod;
|
|
26
|
+
};
|
|
27
|
+
declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, }: Props): import("react").JSX.Element;
|
|
28
|
+
declare namespace OverdueInvoicePayment {
|
|
29
|
+
var defaultProps: {
|
|
30
|
+
mode: string;
|
|
31
|
+
onPaid: () => void;
|
|
32
|
+
dialogProps: {
|
|
33
|
+
open: boolean;
|
|
34
|
+
};
|
|
35
|
+
children: null;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export default OverdueInvoicePayment;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Button, Typography, Stack, CircularProgress, Alert } from "@mui/material";
|
|
4
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
6
|
+
import { joinURL } from "ufo";
|
|
7
|
+
import { useRequest } from "ahooks";
|
|
8
|
+
import { Dialog } from "@arcblock/ux";
|
|
9
|
+
import { usePaymentContext } from "../contexts/payment.js";
|
|
10
|
+
import { formatAmount, formatError, getPrefix } from "../libs/util.js";
|
|
11
|
+
import { useSubscription } from "../hooks/subscription.js";
|
|
12
|
+
import api from "../libs/api.js";
|
|
13
|
+
const fetchOverdueInvoices = async (subscriptionId) => {
|
|
14
|
+
const res = await api.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
|
|
15
|
+
return res.data;
|
|
16
|
+
};
|
|
17
|
+
function OverdueInvoicePayment({
|
|
18
|
+
subscriptionId,
|
|
19
|
+
mode = "default",
|
|
20
|
+
dialogProps = {},
|
|
21
|
+
children,
|
|
22
|
+
onPaid = () => {
|
|
23
|
+
}
|
|
24
|
+
}) {
|
|
25
|
+
const { t } = useLocaleContext();
|
|
26
|
+
const { connect } = usePaymentContext();
|
|
27
|
+
const [selectCurrencyId, setSelectCurrencyId] = useState("");
|
|
28
|
+
const [payLoading, setPayLoading] = useState(false);
|
|
29
|
+
const [dialogOpen, setDialogOpen] = useState(dialogProps.open || false);
|
|
30
|
+
const [processedCurrencies, setProcessedCurrencies] = useState({});
|
|
31
|
+
const {
|
|
32
|
+
data = {
|
|
33
|
+
subscription: {},
|
|
34
|
+
summary: {},
|
|
35
|
+
invoices: []
|
|
36
|
+
},
|
|
37
|
+
error,
|
|
38
|
+
loading,
|
|
39
|
+
runAsync: refresh
|
|
40
|
+
} = useRequest(() => fetchOverdueInvoices(subscriptionId));
|
|
41
|
+
const subscriptionUrl = joinURL(getPrefix(), `/customer/subscription/${subscriptionId}`);
|
|
42
|
+
const summaryList = useMemo(() => {
|
|
43
|
+
if (!data?.summary) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return Object.values(data.summary);
|
|
47
|
+
}, [data?.summary]);
|
|
48
|
+
const subscription = useSubscription("events");
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (subscription) {
|
|
51
|
+
subscription.on("invoice.paid", ({ response }) => {
|
|
52
|
+
const uniqueKey = `${response.subscription_id}-${response.currency_id}`;
|
|
53
|
+
if (response.subscription_id === subscriptionId && !processedCurrencies[uniqueKey]) {
|
|
54
|
+
Toast.success(t("payment.customer.invoice.paySuccess"));
|
|
55
|
+
setPayLoading(false);
|
|
56
|
+
setProcessedCurrencies({ ...processedCurrencies, [uniqueKey]: 1 });
|
|
57
|
+
refresh().then((res) => {
|
|
58
|
+
if (res.invoices?.length === 0) {
|
|
59
|
+
setDialogOpen(false);
|
|
60
|
+
onPaid(subscriptionId, response.currency_id);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [subscription]);
|
|
67
|
+
const handlePay = (item) => {
|
|
68
|
+
const { currency, method } = item;
|
|
69
|
+
if (method.type === "stripe") {
|
|
70
|
+
Toast.error(t("payment.subscription.overdue.notSupport"));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (payLoading) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setSelectCurrencyId(currency.id);
|
|
77
|
+
setPayLoading(true);
|
|
78
|
+
if (method.type === "arcblock" || method.type === "ethereum") {
|
|
79
|
+
connect.open({
|
|
80
|
+
containerEl: void 0,
|
|
81
|
+
saveConnect: false,
|
|
82
|
+
action: "collect-batch",
|
|
83
|
+
prefix: joinURL("/api/did"),
|
|
84
|
+
extraParams: { currencyId: currency.id, subscriptionId },
|
|
85
|
+
onSuccess: () => {
|
|
86
|
+
connect.close();
|
|
87
|
+
},
|
|
88
|
+
onClose: () => {
|
|
89
|
+
connect.close();
|
|
90
|
+
setPayLoading(false);
|
|
91
|
+
},
|
|
92
|
+
onError: (err) => {
|
|
93
|
+
Toast.error(formatError(err));
|
|
94
|
+
setPayLoading(false);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
if (loading) {
|
|
100
|
+
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
101
|
+
}
|
|
102
|
+
const renderPayButton = (item, props) => {
|
|
103
|
+
const isPayLoading = payLoading && item.currency.id === selectCurrencyId;
|
|
104
|
+
if (item.method.type === "stripe") {
|
|
105
|
+
return /* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => window.open(subscriptionUrl, "_blank"), ...props, children: t("payment.subscription.overdue.viewNow") });
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ jsxs(Button, { variant: "contained", color: "primary", onClick: () => handlePay(item), ...props, disabled: isPayLoading, children: [
|
|
108
|
+
isPayLoading && /* @__PURE__ */ jsx(CircularProgress, { size: 14, sx: { mr: 1, color: "text.lighter" } }),
|
|
109
|
+
t("payment.subscription.overdue.payNow")
|
|
110
|
+
] });
|
|
111
|
+
};
|
|
112
|
+
if (mode === "custom" && children && typeof children === "function") {
|
|
113
|
+
return /* @__PURE__ */ jsx(Stack, { children: children(handlePay, {
|
|
114
|
+
subscription: data?.subscription,
|
|
115
|
+
subscriptionUrl,
|
|
116
|
+
summary: data?.summary,
|
|
117
|
+
invoices: data?.invoices
|
|
118
|
+
}) });
|
|
119
|
+
}
|
|
120
|
+
return /* @__PURE__ */ jsx(
|
|
121
|
+
Dialog,
|
|
122
|
+
{
|
|
123
|
+
open: dialogOpen,
|
|
124
|
+
onClose: () => setDialogOpen(false),
|
|
125
|
+
title: dialogProps.title || t("payment.subscription.overdue.pastDue"),
|
|
126
|
+
PaperProps: {
|
|
127
|
+
style: { minHeight: "auto" }
|
|
128
|
+
},
|
|
129
|
+
children: error ? /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message }) : /* @__PURE__ */ jsxs(Stack, { gap: 1, children: [
|
|
130
|
+
summaryList.length === 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Alert, { severity: "success", children: t("payment.subscription.overdue.empty", {
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
name: data?.subscription?.description
|
|
134
|
+
}) }),
|
|
135
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-end", mt: 2, children: /* @__PURE__ */ jsx(
|
|
136
|
+
Button,
|
|
137
|
+
{
|
|
138
|
+
variant: "outlined",
|
|
139
|
+
color: "primary",
|
|
140
|
+
onClick: () => setDialogOpen(false),
|
|
141
|
+
sx: { width: "fit-content" },
|
|
142
|
+
children: t("common.know")
|
|
143
|
+
}
|
|
144
|
+
) })
|
|
145
|
+
] }),
|
|
146
|
+
summaryList.length === 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
147
|
+
/* @__PURE__ */ jsxs(Typography, { color: "text.secondary", variant: "body1", children: [
|
|
148
|
+
t("payment.subscription.overdue.title", {
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
name: data?.subscription?.description,
|
|
151
|
+
count: data?.invoices?.length,
|
|
152
|
+
total: formatAmount(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
|
|
153
|
+
symbol: summaryList[0]?.currency?.symbol
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
156
|
+
t("payment.subscription.overdue.description"),
|
|
157
|
+
/* @__PURE__ */ jsx(
|
|
158
|
+
"a",
|
|
159
|
+
{
|
|
160
|
+
href: subscriptionUrl,
|
|
161
|
+
target: "_blank",
|
|
162
|
+
rel: "noreferrer",
|
|
163
|
+
style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
|
|
164
|
+
children: t("payment.subscription.overdue.view")
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "flex-end", gap: 2, mt: 2, children: [
|
|
169
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: () => setDialogOpen(false), children: t("common.cancel") }),
|
|
170
|
+
renderPayButton(summaryList[0])
|
|
171
|
+
] })
|
|
172
|
+
] }),
|
|
173
|
+
summaryList.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsxs(Typography, { color: "text.secondary", variant: "body1", children: [
|
|
175
|
+
t("payment.subscription.overdue.simpleTitle", {
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
name: data?.subscription?.description,
|
|
178
|
+
count: data?.invoices?.length
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
181
|
+
t("payment.subscription.overdue.description"),
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
"a",
|
|
184
|
+
{
|
|
185
|
+
href: subscriptionUrl,
|
|
186
|
+
target: "_blank",
|
|
187
|
+
rel: "noreferrer",
|
|
188
|
+
style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
|
|
189
|
+
children: t("payment.subscription.overdue.view")
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ jsx(Typography, { color: "text.secondary", variant: "body1", children: t("payment.subscription.overdue.list") }),
|
|
194
|
+
/* @__PURE__ */ jsx(Stack, { children: summaryList.map((item) => /* @__PURE__ */ jsxs(
|
|
195
|
+
Stack,
|
|
196
|
+
{
|
|
197
|
+
direction: "row",
|
|
198
|
+
justifyContent: "space-between",
|
|
199
|
+
alignItems: "center",
|
|
200
|
+
sx: {
|
|
201
|
+
py: 1,
|
|
202
|
+
px: 0.5,
|
|
203
|
+
borderBottom: "1px solid var(--foregrounds-fg-border, #E0E0E0)",
|
|
204
|
+
"&:hover": {
|
|
205
|
+
background: "var(--backgrounds-bg-highlight, #eff6ff)"
|
|
206
|
+
},
|
|
207
|
+
mt: 0
|
|
208
|
+
},
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Typography, { children: t("payment.subscription.overdue.total", {
|
|
211
|
+
total: formatAmount(item?.amount, item?.currency?.decimal),
|
|
212
|
+
currency: item?.currency?.symbol
|
|
213
|
+
}) }),
|
|
214
|
+
renderPayButton(item, {
|
|
215
|
+
variant: "text",
|
|
216
|
+
sx: {
|
|
217
|
+
color: "text.link"
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
item?.currency?.id
|
|
223
|
+
)) })
|
|
224
|
+
] })
|
|
225
|
+
] })
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
OverdueInvoicePayment.defaultProps = {
|
|
230
|
+
mode: "default",
|
|
231
|
+
onPaid: () => {
|
|
232
|
+
},
|
|
233
|
+
dialogProps: {
|
|
234
|
+
open: true
|
|
235
|
+
},
|
|
236
|
+
children: null
|
|
237
|
+
};
|
|
238
|
+
export default OverdueInvoicePayment;
|
|
@@ -167,13 +167,13 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
167
167
|
// }
|
|
168
168
|
}
|
|
169
169
|
@media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
170
|
-
.price-table-wrap:has(> div:nth-
|
|
170
|
+
.price-table-wrap:has(> div:nth-of-type(1)) {
|
|
171
171
|
max-width: 360px !important;
|
|
172
172
|
}
|
|
173
|
-
.price-table-wrap:has(> div:nth-
|
|
173
|
+
.price-table-wrap:has(> div:nth-of-type(2)) {
|
|
174
174
|
max-width: 780px !important;
|
|
175
175
|
}
|
|
176
|
-
.price-table-wrap:has(> div:nth-
|
|
176
|
+
.price-table-wrap:has(> div:nth-of-type(3)) {
|
|
177
177
|
max-width: 1200px !important;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -482,8 +482,6 @@ function Subscribe({ x, action, onSelect, currencyId }) {
|
|
|
482
482
|
loading: state.loading === x.price_id && !state.loaded,
|
|
483
483
|
disabled: x.is_disabled,
|
|
484
484
|
onClick: () => handleSelect(x.price_id),
|
|
485
|
-
loadingPosition: "end",
|
|
486
|
-
endIcon: null,
|
|
487
485
|
children: action
|
|
488
486
|
}
|
|
489
487
|
);
|
package/es/components/table.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import CountrySelect from './components/country-select';
|
|
|
28
28
|
import TruncatedText from './components/truncated-text';
|
|
29
29
|
import Link from './components/link';
|
|
30
30
|
import { createLazyComponent } from './components/lazy-loader';
|
|
31
|
+
import OverdueInvoicePayment from './components/over-due-invoice-payment';
|
|
31
32
|
export { PaymentThemeProvider } from './theme';
|
|
32
33
|
export * from './libs/util';
|
|
33
34
|
export * from './libs/connect';
|
|
@@ -38,4 +39,4 @@ export * from './hooks/mobile';
|
|
|
38
39
|
export * from './hooks/table';
|
|
39
40
|
export * from './hooks/scroll';
|
|
40
41
|
export { translations, createTranslator } from './locales';
|
|
41
|
-
export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, };
|
|
42
|
+
export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, };
|
package/es/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import CountrySelect from "./components/country-select.js";
|
|
|
28
28
|
import TruncatedText from "./components/truncated-text.js";
|
|
29
29
|
import Link from "./components/link.js";
|
|
30
30
|
import { createLazyComponent } from "./components/lazy-loader.js";
|
|
31
|
+
import OverdueInvoicePayment from "./components/over-due-invoice-payment.js";
|
|
31
32
|
export { PaymentThemeProvider } from "./theme/index.js";
|
|
32
33
|
export * from "./libs/util.js";
|
|
33
34
|
export * from "./libs/connect.js";
|
|
@@ -68,5 +69,6 @@ export {
|
|
|
68
69
|
CountrySelect,
|
|
69
70
|
Table,
|
|
70
71
|
TruncatedText,
|
|
71
|
-
Link
|
|
72
|
+
Link,
|
|
73
|
+
OverdueInvoicePayment
|
|
72
74
|
};
|
package/es/locales/en.js
CHANGED
|
@@ -90,7 +90,8 @@ export default flat({
|
|
|
90
90
|
amountPrecisionLimit: "Amount decimal places must be less than or equal to {precision}",
|
|
91
91
|
saveAsDefaultPriceSuccess: "Set default price successfully",
|
|
92
92
|
stakeAmount: "Stake Amount",
|
|
93
|
-
slashStakeAmount: "Slash Stake Amount"
|
|
93
|
+
slashStakeAmount: "Slash Stake Amount",
|
|
94
|
+
know: "I know"
|
|
94
95
|
},
|
|
95
96
|
payment: {
|
|
96
97
|
checkout: {
|
|
@@ -316,6 +317,21 @@ export default flat({
|
|
|
316
317
|
recharge: "Add funds",
|
|
317
318
|
rechargeForSubscription: "Add funds for subscription"
|
|
318
319
|
}
|
|
320
|
+
},
|
|
321
|
+
subscription: {
|
|
322
|
+
overdue: {
|
|
323
|
+
simpleTitle: "There are {count} due invoices for your subscription {name}, you need to pay them to activate your subscription or before making new purchases.",
|
|
324
|
+
title: "There are {count} due invoices for your subscription {name}, the total due amount is {total} {symbol}, you need to pay them to activate your subscription or before making new purchases.",
|
|
325
|
+
payNow: "Pay Now",
|
|
326
|
+
notSupport: "This payment method is not supported",
|
|
327
|
+
total: "Total {total} {currency}",
|
|
328
|
+
view: "View Subscription Details",
|
|
329
|
+
viewNow: "View Now",
|
|
330
|
+
pastDue: "Past Due Invoices",
|
|
331
|
+
description: "If you have any questions, you can choose ",
|
|
332
|
+
list: "Past Due Invoices:",
|
|
333
|
+
empty: "There are no overdue invoices for your subscription {name}."
|
|
334
|
+
}
|
|
319
335
|
}
|
|
320
336
|
},
|
|
321
337
|
refund: {
|
package/es/locales/zh.js
CHANGED
|
@@ -90,7 +90,8 @@ export default flat({
|
|
|
90
90
|
amountPrecisionLimit: "\u91D1\u989D\u5C0F\u6570\u4F4D\u6570\u5FC5\u987B\u5728 {precision} \u4F4D\u4EE5\u5185",
|
|
91
91
|
saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F",
|
|
92
92
|
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
93
|
-
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D"
|
|
93
|
+
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
|
|
94
|
+
know: "\u6211\u77E5\u9053\u4E86"
|
|
94
95
|
},
|
|
95
96
|
payment: {
|
|
96
97
|
checkout: {
|
|
@@ -316,6 +317,21 @@ export default flat({
|
|
|
316
317
|
recharge: "\u5145\u503C",
|
|
317
318
|
rechargeForSubscription: "\u8BA2\u9605\u5145\u503C"
|
|
318
319
|
}
|
|
320
|
+
},
|
|
321
|
+
subscription: {
|
|
322
|
+
overdue: {
|
|
323
|
+
title: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u603B\u8BA1 {total} {symbol}\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
324
|
+
simpleTitle: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
|
|
325
|
+
payNow: "\u7ACB\u5373\u652F\u4ED8",
|
|
326
|
+
notSupport: "\u6682\u4E0D\u652F\u6301\u8BE5\u652F\u4ED8\u65B9\u5F0F",
|
|
327
|
+
total: "\u603B\u8BA1 {total} {currency}",
|
|
328
|
+
view: "\u67E5\u770B\u8BA2\u9605\u8BE6\u60C5",
|
|
329
|
+
pastDue: "\u6B20\u8D39\u8D26\u5355",
|
|
330
|
+
viewNow: "\u7ACB\u5373\u67E5\u770B",
|
|
331
|
+
description: "\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u53EF\u4EE5\u9009\u62E9 ",
|
|
332
|
+
list: "\u6B20\u8D39\u8D26\u5355\uFF1A",
|
|
333
|
+
empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355"
|
|
334
|
+
}
|
|
319
335
|
}
|
|
320
336
|
},
|
|
321
337
|
refund: {
|
package/es/payment/summary.js
CHANGED
|
@@ -196,6 +196,7 @@ export default function PaymentSummary({
|
|
|
196
196
|
{
|
|
197
197
|
size: "small",
|
|
198
198
|
loadingPosition: "end",
|
|
199
|
+
endIcon: null,
|
|
199
200
|
color: "error",
|
|
200
201
|
variant: "text",
|
|
201
202
|
loading: state.loading,
|
|
@@ -225,6 +226,7 @@ export default function PaymentSummary({
|
|
|
225
226
|
{
|
|
226
227
|
size: "small",
|
|
227
228
|
loadingPosition: "end",
|
|
229
|
+
endIcon: null,
|
|
228
230
|
color: crossSellBehavior === "required" ? "info" : "info",
|
|
229
231
|
variant: crossSellBehavior === "required" ? "text" : "text",
|
|
230
232
|
loading: state.loading,
|
package/lib/checkout/table.js
CHANGED
|
@@ -70,7 +70,10 @@ function CheckoutTableInner({
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
const handleSelect = (priceId, currencyId) => {
|
|
73
|
-
_api.default.post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${(0, _util.mergeExtraParams)(
|
|
73
|
+
_api.default.post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${(0, _util.mergeExtraParams)({
|
|
74
|
+
...extraParams,
|
|
75
|
+
currencyId
|
|
76
|
+
})}`).then(res => {
|
|
74
77
|
if (mode === "standalone") {
|
|
75
78
|
let {
|
|
76
79
|
url
|
|
@@ -7,10 +7,5 @@ export type CountrySelectProps = {
|
|
|
7
7
|
name: string;
|
|
8
8
|
sx?: SxProps;
|
|
9
9
|
};
|
|
10
|
-
declare
|
|
11
|
-
declare namespace CountrySelect {
|
|
12
|
-
var defaultProps: {
|
|
13
|
-
sx: {};
|
|
14
|
-
};
|
|
15
|
-
}
|
|
10
|
+
declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
16
11
|
export default CountrySelect;
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _reactHookForm = require("react-hook-form");
|
|
11
11
|
var _reactInternationalPhone = require("react-international-phone");
|
|
12
|
-
CountrySelect
|
|
13
|
-
sx: {}
|
|
14
|
-
};
|
|
15
|
-
function CountrySelect({
|
|
12
|
+
const CountrySelect = (0, _react.forwardRef)(({
|
|
16
13
|
value,
|
|
17
14
|
onChange,
|
|
18
15
|
name,
|
|
19
16
|
sx
|
|
20
|
-
}) {
|
|
17
|
+
}, ref) => {
|
|
21
18
|
const {
|
|
22
19
|
setValue
|
|
23
20
|
} = (0, _reactHookForm.useFormContext)();
|
|
@@ -32,6 +29,7 @@ function CountrySelect({
|
|
|
32
29
|
setValue(name, e.target.value);
|
|
33
30
|
};
|
|
34
31
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Select, {
|
|
32
|
+
ref,
|
|
35
33
|
MenuProps: {
|
|
36
34
|
style: {
|
|
37
35
|
height: "300px",
|
|
@@ -48,7 +46,6 @@ function CountrySelect({
|
|
|
48
46
|
},
|
|
49
47
|
sx: {
|
|
50
48
|
width: "100%",
|
|
51
|
-
// Remove default outline (display only on focus)
|
|
52
49
|
fieldset: {
|
|
53
50
|
display: "none"
|
|
54
51
|
},
|
|
@@ -57,7 +54,6 @@ function CountrySelect({
|
|
|
57
54
|
display: "block"
|
|
58
55
|
}
|
|
59
56
|
},
|
|
60
|
-
// Update default spacing
|
|
61
57
|
".MuiSelect-select": {
|
|
62
58
|
padding: "8px",
|
|
63
59
|
paddingRight: "24px !important"
|
|
@@ -67,9 +63,7 @@ function CountrySelect({
|
|
|
67
63
|
},
|
|
68
64
|
".MuiMenuItem-root": {
|
|
69
65
|
justifyContent: "flex-start"
|
|
70
|
-
// 确保内容左对齐
|
|
71
66
|
},
|
|
72
|
-
|
|
73
67
|
...sx
|
|
74
68
|
},
|
|
75
69
|
value,
|
|
@@ -112,4 +106,8 @@ function CountrySelect({
|
|
|
112
106
|
}, parsed.iso2);
|
|
113
107
|
})
|
|
114
108
|
});
|
|
115
|
-
}
|
|
109
|
+
});
|
|
110
|
+
CountrySelect.defaultProps = {
|
|
111
|
+
sx: {}
|
|
112
|
+
};
|
|
113
|
+
module.exports = CountrySelect;
|