payment-kit 1.13.111 → 1.13.113
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/api/src/libs/notification/template/subscription-trial-will-end.ts +1 -1
- package/api/src/libs/notification/template/subscription-will-renew.ts +1 -1
- package/api/src/routes/products.ts +1 -0
- package/api/src/routes/subscriptions.ts +2 -0
- package/blocklet.yml +1 -1
- package/package.json +6 -6
- package/src/components/actions.tsx +1 -2
- package/src/components/blockchain/tx.tsx +1 -1
- package/src/components/click-boundary.tsx +1 -2
- package/src/components/customer/actions.tsx +2 -3
- package/src/components/customer/edit.tsx +3 -3
- package/src/components/customer/form.tsx +22 -24
- package/src/components/drawer-form.tsx +2 -4
- package/src/components/event/list.tsx +2 -3
- package/src/components/invoice/action.tsx +2 -3
- package/src/components/invoice/list.tsx +3 -4
- package/src/components/invoice/table.tsx +7 -7
- package/src/components/metadata/form.tsx +3 -4
- package/src/components/passport/actions.tsx +1 -2
- package/src/components/passport/assign.tsx +1 -1
- package/src/components/payment-intent/actions.tsx +2 -3
- package/src/components/payment-intent/list.tsx +3 -4
- package/src/components/payment-link/actions.tsx +2 -3
- package/src/components/payment-link/item.tsx +3 -5
- package/src/components/payment-link/product-select.tsx +3 -4
- package/src/components/payment-link/rename.tsx +3 -4
- package/src/components/payment-method/arcblock.tsx +1 -2
- package/src/components/payment-method/bitcoin.tsx +1 -2
- package/src/components/payment-method/ethereum.tsx +1 -2
- package/src/components/payment-method/stripe.tsx +1 -2
- package/src/components/portal/invoice/list.tsx +4 -5
- package/src/components/portal/subscription/actions.tsx +7 -8
- package/src/components/portal/subscription/cancel.tsx +13 -12
- package/src/components/portal/subscription/list.tsx +4 -10
- package/src/components/price/currency-select.tsx +2 -2
- package/src/components/price/form.tsx +3 -4
- package/src/components/price/upsell-select.tsx +2 -3
- package/src/components/price/upsell.tsx +3 -5
- package/src/components/pricing-table/actions.tsx +2 -3
- package/src/components/pricing-table/payment-settings.tsx +4 -4
- package/src/components/pricing-table/price-item.tsx +4 -7
- package/src/components/pricing-table/product-item.tsx +3 -3
- package/src/components/pricing-table/rename.tsx +3 -4
- package/src/components/product/actions.tsx +2 -3
- package/src/components/product/add-price.tsx +2 -2
- package/src/components/product/create.tsx +2 -4
- package/src/components/product/cross-sell-select.tsx +3 -3
- package/src/components/product/cross-sell.tsx +4 -5
- package/src/components/product/edit.tsx +1 -1
- package/src/components/product/form.tsx +6 -6
- package/src/components/relative-time.tsx +1 -2
- package/src/components/subscription/actions/cancel.tsx +2 -3
- package/src/components/subscription/actions/index.tsx +2 -3
- package/src/components/subscription/items/actions.tsx +1 -1
- package/src/components/subscription/items/index.tsx +2 -2
- package/src/components/subscription/items/usage-records.tsx +2 -3
- package/src/components/subscription/list.tsx +3 -4
- package/src/components/subscription/metrics.tsx +2 -2
- package/src/components/subscription/status.tsx +3 -3
- package/src/components/webhook/attempts.tsx +3 -3
- package/src/contexts/products.tsx +2 -3
- package/src/libs/api.ts +2 -19
- package/src/libs/dayjs.ts +1 -15
- package/src/libs/util.ts +24 -555
- package/src/locales/en.tsx +0 -139
- package/src/locales/index.tsx +5 -23
- package/src/locales/zh.tsx +0 -136
- package/src/pages/admin/billing/index.tsx +4 -2
- package/src/pages/admin/billing/invoices/detail.tsx +3 -4
- package/src/pages/admin/billing/subscriptions/detail.tsx +3 -3
- package/src/pages/admin/customers/customers/detail.tsx +3 -5
- package/src/pages/admin/customers/customers/index.tsx +2 -3
- package/src/pages/admin/customers/index.tsx +4 -2
- package/src/pages/admin/developers/events/detail.tsx +2 -3
- package/src/pages/admin/developers/index.tsx +4 -2
- package/src/pages/admin/developers/webhooks/detail.tsx +3 -4
- package/src/pages/admin/developers/webhooks/index.tsx +3 -4
- package/src/pages/admin/index.tsx +10 -7
- package/src/pages/admin/payments/index.tsx +4 -2
- package/src/pages/admin/payments/intents/detail.tsx +4 -6
- package/src/pages/admin/payments/links/create.tsx +3 -5
- package/src/pages/admin/payments/links/detail.tsx +4 -5
- package/src/pages/admin/payments/links/index.tsx +4 -6
- package/src/pages/admin/products/passports/index.tsx +1 -1
- package/src/pages/admin/products/prices/actions.tsx +2 -3
- package/src/pages/admin/products/prices/detail.tsx +2 -3
- package/src/pages/admin/products/prices/list.tsx +2 -4
- package/src/pages/admin/products/pricing-tables/create.tsx +2 -3
- package/src/pages/admin/products/pricing-tables/detail.tsx +4 -5
- package/src/pages/admin/products/pricing-tables/index.tsx +2 -4
- package/src/pages/admin/products/products/create.tsx +2 -4
- package/src/pages/admin/products/products/detail.tsx +4 -5
- package/src/pages/admin/products/products/index.tsx +4 -6
- package/src/pages/admin/settings/index.tsx +4 -2
- package/src/pages/admin/settings/payment-methods/create.tsx +3 -5
- package/src/pages/admin/settings/payment-methods/index.tsx +2 -3
- package/src/pages/checkout/index.tsx +6 -3
- package/src/pages/checkout/pay.tsx +5 -69
- package/src/pages/checkout/pricing-table.tsx +3 -7
- package/src/pages/customer/index.tsx +7 -7
- package/src/pages/customer/invoice.tsx +10 -11
- package/src/pages/customer/subscription/detail.tsx +4 -4
- package/src/pages/customer/subscription/update.tsx +19 -19
- package/src/components/checkout/amount.tsx +0 -24
- package/src/components/checkout/error.tsx +0 -30
- package/src/components/checkout/footer.tsx +0 -12
- package/src/components/checkout/form/address.tsx +0 -119
- package/src/components/checkout/form/index.tsx +0 -400
- package/src/components/checkout/form/phone.tsx +0 -103
- package/src/components/checkout/form/stripe.tsx +0 -195
- package/src/components/checkout/form/user-buttons.tsx +0 -24
- package/src/components/checkout/header.tsx +0 -40
- package/src/components/checkout/pay.tsx +0 -385
- package/src/components/checkout/pricing-table.tsx +0 -205
- package/src/components/checkout/product-card.tsx +0 -52
- package/src/components/checkout/product-item.tsx +0 -111
- package/src/components/checkout/skeleton/overview.tsx +0 -21
- package/src/components/checkout/skeleton/payment.tsx +0 -35
- package/src/components/checkout/success.tsx +0 -183
- package/src/components/checkout/summary.tsx +0 -198
- package/src/components/input.tsx +0 -58
- package/src/components/livemode.tsx +0 -23
- package/src/components/pricing-table/product-skeleton.tsx +0 -39
- package/src/components/status.tsx +0 -19
- package/src/components/switch.tsx +0 -48
- package/src/contexts/settings.tsx +0 -54
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
4
4
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
5
|
-
import
|
|
5
|
+
import { api, formatError, usePaymentContext } from '@blocklet/payment-react';
|
|
6
|
+
import type { InferFormType, TPaymentLink } from '@blocklet/payment-types';
|
|
6
7
|
import { AddOutlined } from '@mui/icons-material';
|
|
7
8
|
import { Button, Stack, Typography } from '@mui/material';
|
|
8
9
|
import { useEffect, useState } from 'react';
|
|
@@ -16,9 +17,6 @@ import BeforePay from '../../../../components/payment-link/before-pay';
|
|
|
16
17
|
import PaymentLinkPreview from '../../../../components/payment-link/preview';
|
|
17
18
|
import { ProductsProvider } from '../../../../contexts/products';
|
|
18
19
|
import { useSessionContext } from '../../../../contexts/session';
|
|
19
|
-
import { useSettingsContext } from '../../../../contexts/settings';
|
|
20
|
-
import api from '../../../../libs/api';
|
|
21
|
-
import { formatError } from '../../../../libs/util';
|
|
22
20
|
|
|
23
21
|
type PaymentLink = InferFormType<TPaymentLink> & {
|
|
24
22
|
include_free_trial: boolean;
|
|
@@ -30,7 +28,7 @@ export default function CreatePaymentLink() {
|
|
|
30
28
|
const { session } = useSessionContext();
|
|
31
29
|
const [current, setCurrent] = useState('beforePay');
|
|
32
30
|
const [stashed, setStashed] = useState(0);
|
|
33
|
-
const { settings } =
|
|
31
|
+
const { settings } = usePaymentContext();
|
|
34
32
|
|
|
35
33
|
const methods = useForm<PaymentLink>({
|
|
36
34
|
shouldUnregister: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import
|
|
4
|
+
import { api, formatError, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
5
|
+
import type { TLineItemExpanded, TPaymentLinkExpanded, TPrice, TProduct } from '@blocklet/payment-types';
|
|
5
6
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
6
7
|
import { Alert, Box, Button, CircularProgress, Grid, Stack, Typography } from '@mui/material';
|
|
7
8
|
import { styled } from '@mui/system';
|
|
@@ -20,9 +21,7 @@ import PaymentLinkPreview from '../../../../components/payment-link/preview';
|
|
|
20
21
|
import AddPrice from '../../../../components/product/add-price';
|
|
21
22
|
import SectionHeader from '../../../../components/section/header';
|
|
22
23
|
import Table from '../../../../components/table';
|
|
23
|
-
import {
|
|
24
|
-
import api from '../../../../libs/api';
|
|
25
|
-
import { formatError, formatPaymentLinkPricing, formatProductPrice, formatTime } from '../../../../libs/util';
|
|
24
|
+
import { formatPaymentLinkPricing, formatProductPrice } from '../../../../libs/util';
|
|
26
25
|
|
|
27
26
|
const fetchData = (id: string): Promise<TPaymentLinkExpanded> => {
|
|
28
27
|
return api.get(`/api/payment-links/${id}`).then((res) => res.data);
|
|
@@ -31,7 +30,7 @@ const fetchData = (id: string): Promise<TPaymentLinkExpanded> => {
|
|
|
31
30
|
export default function PaymentLinkDetail(props: { id: string }) {
|
|
32
31
|
const { t, locale } = useLocaleContext();
|
|
33
32
|
const navigate = useNavigate();
|
|
34
|
-
const { settings } =
|
|
33
|
+
const { settings } = usePaymentContext();
|
|
35
34
|
const [state, setState] = useSetState({
|
|
36
35
|
adding: {
|
|
37
36
|
price: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { getDurableData } from '@arcblock/ux/lib/Datatable';
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import
|
|
4
|
+
import { Status, api, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPaymentLinkExpanded } from '@blocklet/payment-types';
|
|
5
6
|
import { Alert, CircularProgress, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
|
|
6
7
|
import { useRequest } from 'ahooks';
|
|
7
8
|
import { useEffect, useState } from 'react';
|
|
@@ -11,12 +12,9 @@ import useBus from 'use-bus';
|
|
|
11
12
|
|
|
12
13
|
import Copyable from '../../../../components/copyable';
|
|
13
14
|
import PaymentLinkActions from '../../../../components/payment-link/actions';
|
|
14
|
-
import Status from '../../../../components/status';
|
|
15
15
|
import Table from '../../../../components/table';
|
|
16
16
|
import { ProductsProvider } from '../../../../contexts/products';
|
|
17
|
-
import {
|
|
18
|
-
import api from '../../../../libs/api';
|
|
19
|
-
import { formatPaymentLinkPricing, formatTime } from '../../../../libs/util';
|
|
17
|
+
import { formatPaymentLinkPricing } from '../../../../libs/util';
|
|
20
18
|
|
|
21
19
|
const fetchData = (params: Record<string, any> = {}): Promise<{ list: TPaymentLinkExpanded[]; count: number }> => {
|
|
22
20
|
const search = new URLSearchParams();
|
|
@@ -29,7 +27,7 @@ const fetchData = (params: Record<string, any> = {}): Promise<{ list: TPaymentLi
|
|
|
29
27
|
function PaymentLinks() {
|
|
30
28
|
const listKey = 'payment-links';
|
|
31
29
|
const { t } = useLocaleContext();
|
|
32
|
-
const { settings } =
|
|
30
|
+
const { settings } = usePaymentContext();
|
|
33
31
|
const navigate = useNavigate();
|
|
34
32
|
|
|
35
33
|
const persisted = getDurableData(listKey);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { api } from '@blocklet/payment-react';
|
|
3
4
|
import { Alert, CircularProgress, Typography } from '@mui/material';
|
|
4
5
|
import { useRequest } from 'ahooks';
|
|
5
6
|
import { Link } from 'react-router-dom';
|
|
6
7
|
|
|
7
8
|
import PassportActions from '../../../../components/passport/actions';
|
|
8
9
|
import Table from '../../../../components/table';
|
|
9
|
-
import api from '../../../../libs/api';
|
|
10
10
|
|
|
11
11
|
const fetchData = (params: Record<string, any> = {}): Promise<any[]> => {
|
|
12
12
|
const search = new URLSearchParams();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPrice } from '@blocklet/payment-types';
|
|
4
5
|
import { useSetState } from 'ahooks';
|
|
5
6
|
import noop from 'lodash/noop';
|
|
6
7
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -8,8 +9,6 @@ import { useNavigate } from 'react-router-dom';
|
|
|
8
9
|
import Actions from '../../../../components/actions';
|
|
9
10
|
import ConfirmDialog from '../../../../components/confirm';
|
|
10
11
|
import EditPrice from '../../../../components/product/edit-price';
|
|
11
|
-
import api from '../../../../libs/api';
|
|
12
|
-
import { formatError } from '../../../../libs/util';
|
|
13
12
|
|
|
14
13
|
type Props = {
|
|
15
14
|
data: TPrice;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError, formatPrice, formatTime } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPrice, TPriceExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
5
6
|
import { Alert, AlertTitle, Box, Button, CircularProgress, Grid, Stack, Typography } from '@mui/material';
|
|
6
7
|
import { styled } from '@mui/system';
|
|
@@ -18,8 +19,6 @@ import PriceUpsell from '../../../../components/price/upsell';
|
|
|
18
19
|
import EditPrice from '../../../../components/product/edit-price';
|
|
19
20
|
import SectionHeader from '../../../../components/section/header';
|
|
20
21
|
import Table from '../../../../components/table';
|
|
21
|
-
import api from '../../../../libs/api';
|
|
22
|
-
import { formatError, formatPrice, formatTime } from '../../../../libs/util';
|
|
23
22
|
import PriceActions from './actions';
|
|
24
23
|
|
|
25
24
|
const fetchData = (id: string): Promise<TPriceExpanded> => {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { Status, formatPrice, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
3
4
|
import { LockOutlined } from '@mui/icons-material';
|
|
4
5
|
import { Stack, Tooltip, Typography } from '@mui/material';
|
|
5
6
|
import { Link } from 'react-router-dom';
|
|
6
7
|
|
|
7
8
|
import Copyable from '../../../../components/copyable';
|
|
8
9
|
import type { Product } from '../../../../components/product/form';
|
|
9
|
-
import Status from '../../../../components/status';
|
|
10
10
|
import Table from '../../../../components/table';
|
|
11
|
-
import { useSettingsContext } from '../../../../contexts/settings';
|
|
12
|
-
import { formatPrice, formatTime } from '../../../../libs/util';
|
|
13
11
|
import PriceActions from './actions';
|
|
14
12
|
|
|
15
13
|
export default function PricesList({ product, onChange }: { product: Product; onChange: Function }) {
|
|
16
14
|
const { t, locale } = useLocaleContext();
|
|
17
|
-
const { settings } =
|
|
15
|
+
const { settings } = usePaymentContext();
|
|
18
16
|
|
|
19
17
|
const columns = [
|
|
20
18
|
{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import
|
|
4
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPricingTable } from '@blocklet/payment-types';
|
|
5
6
|
import { AddOutlined } from '@mui/icons-material';
|
|
6
7
|
import { Box, Button, Stack, Typography } from '@mui/material';
|
|
7
8
|
import { useEffect, useState } from 'react';
|
|
@@ -16,8 +17,6 @@ import PricingTablePreview from '../../../../components/pricing-table/preview';
|
|
|
16
17
|
import PricingTableProductSettings from '../../../../components/pricing-table/product-settings';
|
|
17
18
|
import { ProductsProvider } from '../../../../contexts/products';
|
|
18
19
|
import { useSessionContext } from '../../../../contexts/session';
|
|
19
|
-
import api from '../../../../libs/api';
|
|
20
|
-
import { formatError } from '../../../../libs/util';
|
|
21
20
|
|
|
22
21
|
export default function CreatePricingTable() {
|
|
23
22
|
const { t } = useLocaleContext();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import
|
|
4
|
+
import { api, formatError, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPricingTableExpanded, TProduct } from '@blocklet/payment-types';
|
|
5
6
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
6
7
|
import { Alert, Box, Button, CircularProgress, Grid, Stack, Typography } from '@mui/material';
|
|
7
8
|
import { styled } from '@mui/system';
|
|
@@ -19,9 +20,7 @@ import PricingTableActions from '../../../../components/pricing-table/actions';
|
|
|
19
20
|
import PricingTablePreview from '../../../../components/pricing-table/preview';
|
|
20
21
|
import SectionHeader from '../../../../components/section/header';
|
|
21
22
|
import Table from '../../../../components/table';
|
|
22
|
-
import {
|
|
23
|
-
import api from '../../../../libs/api';
|
|
24
|
-
import { formatError, formatProductPrice, formatTime } from '../../../../libs/util';
|
|
23
|
+
import { formatProductPrice } from '../../../../libs/util';
|
|
25
24
|
|
|
26
25
|
const fetchData = (id: string): Promise<TPricingTableExpanded> => {
|
|
27
26
|
return api.get(`/api/pricing-tables/${id}`).then((res) => res.data);
|
|
@@ -30,7 +29,7 @@ const fetchData = (id: string): Promise<TPricingTableExpanded> => {
|
|
|
30
29
|
export default function PricingTableDetail(props: { id: string }) {
|
|
31
30
|
const { t, locale } = useLocaleContext();
|
|
32
31
|
const navigate = useNavigate();
|
|
33
|
-
const { settings } =
|
|
32
|
+
const { settings } = usePaymentContext();
|
|
34
33
|
const [state, setState] = useSetState({
|
|
35
34
|
adding: {
|
|
36
35
|
price: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { getDurableData } from '@arcblock/ux/lib/Datatable';
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import
|
|
4
|
+
import { Status, api, formatTime } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPricingTableExpanded } from '@blocklet/payment-types';
|
|
5
6
|
import { Alert, CircularProgress, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
|
|
6
7
|
import { useRequest } from 'ahooks';
|
|
7
8
|
import { useEffect, useState } from 'react';
|
|
@@ -11,11 +12,8 @@ import useBus from 'use-bus';
|
|
|
11
12
|
|
|
12
13
|
import Copyable from '../../../../components/copyable';
|
|
13
14
|
import PricingTableActions from '../../../../components/pricing-table/actions';
|
|
14
|
-
import Status from '../../../../components/status';
|
|
15
15
|
import Table from '../../../../components/table';
|
|
16
16
|
import { ProductsProvider } from '../../../../contexts/products';
|
|
17
|
-
import api from '../../../../libs/api';
|
|
18
|
-
import { formatTime } from '../../../../libs/util';
|
|
19
17
|
|
|
20
18
|
const fetchData = (params: Record<string, any> = {}): Promise<{ list: TPricingTableExpanded[]; count: number }> => {
|
|
21
19
|
const search = new URLSearchParams();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
import { api, formatError, formatPrice, usePaymentContext } from '@blocklet/payment-react';
|
|
4
5
|
import { AddOutlined } from '@mui/icons-material';
|
|
5
6
|
import { Box, Button, Divider, Typography } from '@mui/material';
|
|
6
7
|
import { cloneDeep } from 'lodash';
|
|
@@ -13,13 +14,10 @@ import DrawerForm from '../../../../components/drawer-form';
|
|
|
13
14
|
import PriceActions from '../../../../components/price/actions';
|
|
14
15
|
import PriceForm, { DEFAULT_PRICE } from '../../../../components/price/form';
|
|
15
16
|
import ProductForm, { Product } from '../../../../components/product/form';
|
|
16
|
-
import { useSettingsContext } from '../../../../contexts/settings';
|
|
17
|
-
import api from '../../../../libs/api';
|
|
18
|
-
import { formatError, formatPrice } from '../../../../libs/util';
|
|
19
17
|
|
|
20
18
|
export default function ProductsCreate() {
|
|
21
19
|
const { t, locale } = useLocaleContext();
|
|
22
|
-
const { settings } =
|
|
20
|
+
const { settings } = usePaymentContext();
|
|
23
21
|
|
|
24
22
|
const methods = useForm<Product>({
|
|
25
23
|
defaultValues: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPrice, TProduct, TProductExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { ArrowBackOutlined, Edit } from '@mui/icons-material';
|
|
5
6
|
import { Alert, AlertTitle, Box, Button, CircularProgress, Grid, Stack, Typography } from '@mui/material';
|
|
6
7
|
import { styled } from '@mui/system';
|
|
@@ -19,9 +20,7 @@ import AddPrice from '../../../../components/product/add-price';
|
|
|
19
20
|
import ProductCrossSell from '../../../../components/product/cross-sell';
|
|
20
21
|
import EditProduct from '../../../../components/product/edit';
|
|
21
22
|
import SectionHeader from '../../../../components/section/header';
|
|
22
|
-
import {
|
|
23
|
-
import api from '../../../../libs/api';
|
|
24
|
-
import { formatError, formatProductPrice, formatTime } from '../../../../libs/util';
|
|
23
|
+
import { formatProductPrice } from '../../../../libs/util';
|
|
25
24
|
import PricesList from '../prices/list';
|
|
26
25
|
|
|
27
26
|
const getProduct = (id: string): Promise<TProductExpanded> => {
|
|
@@ -31,7 +30,7 @@ const getProduct = (id: string): Promise<TProductExpanded> => {
|
|
|
31
30
|
export default function ProductDetail(props: { id: string }) {
|
|
32
31
|
const { t, locale } = useLocaleContext();
|
|
33
32
|
const navigate = useNavigate();
|
|
34
|
-
const { settings } =
|
|
33
|
+
const { settings } = usePaymentContext();
|
|
35
34
|
const [state, setState] = useSetState({
|
|
36
35
|
adding: {
|
|
37
36
|
price: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { getDurableData } from '@arcblock/ux/lib/Datatable';
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import
|
|
4
|
+
import { Status, api, formatTime, usePaymentContext } from '@blocklet/payment-react';
|
|
5
|
+
import type { TProductExpanded } from '@blocklet/payment-types';
|
|
5
6
|
import { Alert, CircularProgress, ToggleButton, ToggleButtonGroup } from '@mui/material';
|
|
6
7
|
import { useRequest } from 'ahooks';
|
|
7
8
|
import { useEffect, useState } from 'react';
|
|
@@ -10,11 +11,8 @@ import useBus from 'use-bus';
|
|
|
10
11
|
|
|
11
12
|
import InfoCard from '../../../../components/info-card';
|
|
12
13
|
import ProductActions from '../../../../components/product/actions';
|
|
13
|
-
import Status from '../../../../components/status';
|
|
14
14
|
import Table from '../../../../components/table';
|
|
15
|
-
import {
|
|
16
|
-
import api from '../../../../libs/api';
|
|
17
|
-
import { formatProductPrice, formatTime } from '../../../../libs/util';
|
|
15
|
+
import { formatProductPrice } from '../../../../libs/util';
|
|
18
16
|
|
|
19
17
|
const fetchData = (params: Record<string, any> = {}): Promise<{ list: TProductExpanded[]; count: number }> => {
|
|
20
18
|
const search = new URLSearchParams();
|
|
@@ -30,7 +28,7 @@ export default function ProductsList() {
|
|
|
30
28
|
|
|
31
29
|
const { t, locale } = useLocaleContext();
|
|
32
30
|
const navigate = useNavigate();
|
|
33
|
-
const { settings } =
|
|
31
|
+
const { settings } = usePaymentContext();
|
|
34
32
|
const [search, setSearch] = useState<{ active: string; pageSize: number; page: number }>({
|
|
35
33
|
active: '',
|
|
36
34
|
pageSize: persisted.rowsPerPage || 20,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
3
3
|
import { Stack, Typography } from '@mui/material';
|
|
4
|
-
import React, { isValidElement } from 'react';
|
|
4
|
+
import React, { isValidElement, startTransition } from 'react';
|
|
5
5
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
const PaymentMethodCreate = React.lazy(() => import('./payment-methods/create'));
|
|
@@ -18,7 +18,9 @@ export default function SettingsIndex() {
|
|
|
18
18
|
const { page = 'payment-methods' } = useParams();
|
|
19
19
|
|
|
20
20
|
const onTabChange = (newTab: string) => {
|
|
21
|
-
|
|
21
|
+
startTransition(() => {
|
|
22
|
+
navigate(`/admin/settings/${newTab}`);
|
|
23
|
+
});
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
// @ts-ignore
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import
|
|
4
|
+
import { api, formatError, usePaymentContext } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPaymentMethod } from '@blocklet/payment-types';
|
|
5
6
|
import { AddOutlined } from '@mui/icons-material';
|
|
6
7
|
import { Button, Typography } from '@mui/material';
|
|
7
8
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
@@ -9,13 +10,10 @@ import { dispatch } from 'use-bus';
|
|
|
9
10
|
|
|
10
11
|
import DrawerForm from '../../../../components/drawer-form';
|
|
11
12
|
import PaymentMethodForm from '../../../../components/payment-method/form';
|
|
12
|
-
import { useSettingsContext } from '../../../../contexts/settings';
|
|
13
|
-
import api from '../../../../libs/api';
|
|
14
|
-
import { formatError } from '../../../../libs/util';
|
|
15
13
|
|
|
16
14
|
export default function PaymentMethodCreate() {
|
|
17
15
|
const { t } = useLocaleContext();
|
|
18
|
-
const settings =
|
|
16
|
+
const settings = usePaymentContext();
|
|
19
17
|
|
|
20
18
|
const methods = useForm<TPaymentMethod>({
|
|
21
19
|
defaultValues: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import
|
|
2
|
+
import { Switch, api } from '@blocklet/payment-react';
|
|
3
|
+
import type { TPaymentMethodExpanded } from '@blocklet/payment-types';
|
|
3
4
|
import { Alert, Box, CircularProgress, Grid, Typography } from '@mui/material';
|
|
4
5
|
import { useRequest } from 'ahooks';
|
|
5
6
|
import useBus from 'use-bus';
|
|
@@ -7,8 +8,6 @@ import useBus from 'use-bus';
|
|
|
7
8
|
import IconCollapse from '../../../../components/collapse';
|
|
8
9
|
import InfoCard from '../../../../components/info-card';
|
|
9
10
|
import InfoRow from '../../../../components/info-row';
|
|
10
|
-
import Switch from '../../../../components/switch';
|
|
11
|
-
import api from '../../../../libs/api';
|
|
12
11
|
|
|
13
12
|
const getMethods = (params: Record<string, any> = {}): Promise<TPaymentMethodExpanded[]> => {
|
|
14
13
|
const search = new URLSearchParams();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { PaymentProvider } from '@blocklet/payment-react';
|
|
1
2
|
import { Box } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { useParams } from 'react-router-dom';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import { useSessionContext } from '../../contexts/session';
|
|
6
7
|
|
|
7
8
|
const pages = {
|
|
8
9
|
pay: React.lazy(() => import('./pay')),
|
|
@@ -23,9 +24,11 @@ function Checkout() {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export default function WrappedAdmin() {
|
|
27
|
+
const { session, connectApi } = useSessionContext();
|
|
28
|
+
|
|
26
29
|
return (
|
|
27
|
-
<
|
|
30
|
+
<PaymentProvider session={session} connect={connectApi}>
|
|
28
31
|
<Checkout />
|
|
29
|
-
</
|
|
32
|
+
</PaymentProvider>
|
|
30
33
|
);
|
|
31
34
|
}
|
|
@@ -1,91 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
TCheckoutSessionExpanded,
|
|
3
|
-
TCustomer,
|
|
4
|
-
TPaymentIntent,
|
|
5
|
-
TPaymentLink,
|
|
6
|
-
TPaymentMethodExpanded,
|
|
7
|
-
} from '@did-pay/types';
|
|
8
|
-
import { useRequest, useSetState } from 'ahooks';
|
|
9
|
-
import { useEffect } from 'react';
|
|
10
|
-
import { useNavigate, useSearchParams } from 'react-router-dom';
|
|
11
|
-
|
|
12
|
-
import CheckoutPay from '../../components/checkout/pay';
|
|
13
|
-
import api from '../../libs/api';
|
|
1
|
+
import { Checkout } from '@blocklet/payment-react';
|
|
14
2
|
|
|
15
3
|
type Props = {
|
|
16
4
|
id: string;
|
|
17
5
|
};
|
|
18
6
|
|
|
19
|
-
type PageData = {
|
|
20
|
-
checkoutSession: TCheckoutSessionExpanded;
|
|
21
|
-
paymentMethods: TPaymentMethodExpanded[];
|
|
22
|
-
paymentLink?: TPaymentLink;
|
|
23
|
-
paymentIntent?: TPaymentIntent;
|
|
24
|
-
customer?: TCustomer;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const startFromPaymentLink = async (id: string, params: string): Promise<PageData> => {
|
|
28
|
-
const { data } = await api.post(`/api/checkout-sessions/start/${id}?${params}`);
|
|
29
|
-
return data;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const fetchCheckoutSession = async (id: string): Promise<PageData> => {
|
|
33
|
-
const { data } = await api.get(`/api/checkout-sessions/retrieve/${id}`);
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
7
|
export default function Payment({ id }: Props) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const navigate = useNavigate();
|
|
41
|
-
const [params] = useSearchParams();
|
|
42
|
-
const [state, setState] = useSetState({ completed: false, appError: null });
|
|
43
|
-
|
|
44
|
-
const { error: apiError, data } = useRequest(() =>
|
|
45
|
-
type === 'paymentLink' ? startFromPaymentLink(id, params.toString()) : fetchCheckoutSession(id)
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (data && type === 'paymentLink') {
|
|
50
|
-
navigate(`/checkout/pay/${data.checkoutSession.id}`, { replace: true });
|
|
51
|
-
}
|
|
52
|
-
}, [type, data, navigate]);
|
|
53
|
-
|
|
54
|
-
const onPaid = () => {
|
|
55
|
-
setState({ completed: true });
|
|
8
|
+
const onPaid = (data: any) => {
|
|
56
9
|
if (data?.checkoutSession?.success_url) {
|
|
57
10
|
setTimeout(() => {
|
|
58
11
|
const tmp = new URL(data.checkoutSession.success_url as string, window.location.origin);
|
|
59
12
|
tmp.searchParams.set('checkout_session_id', data.checkoutSession.id);
|
|
60
|
-
window.location.
|
|
13
|
+
window.location.replace(tmp.href);
|
|
61
14
|
}, 1000);
|
|
62
15
|
} else if (data?.paymentLink) {
|
|
63
16
|
if (data.paymentLink.after_completion?.type === 'redirect' && data.paymentLink.after_completion?.redirect?.url) {
|
|
64
17
|
setTimeout(() => {
|
|
65
18
|
const tmp = new URL(data.paymentLink?.after_completion?.redirect?.url as string, window.location.origin);
|
|
66
19
|
tmp.searchParams.set('checkout_session_id', data.checkoutSession.id);
|
|
67
|
-
window.location.
|
|
20
|
+
window.location.replace(tmp.href);
|
|
68
21
|
}, 1000);
|
|
69
22
|
}
|
|
70
23
|
}
|
|
71
24
|
};
|
|
72
25
|
|
|
73
|
-
|
|
74
|
-
setState({ appError: err });
|
|
75
|
-
console.error(err);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<CheckoutPay
|
|
80
|
-
checkoutSession={data?.checkoutSession}
|
|
81
|
-
paymentMethods={data?.paymentMethods}
|
|
82
|
-
paymentIntent={data?.paymentIntent}
|
|
83
|
-
paymentLink={data?.paymentLink}
|
|
84
|
-
customer={data?.customer}
|
|
85
|
-
completed={state.completed}
|
|
86
|
-
error={apiError || state.appError}
|
|
87
|
-
onPaid={onPaid}
|
|
88
|
-
onError={onError}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
26
|
+
return <Checkout mode="standalone" id={id} onPaid={onPaid} />;
|
|
91
27
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import Center from '@arcblock/ux/lib/Center';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
import { Livemode, PricingTable, ProductSkeleton, api } from '@blocklet/payment-react';
|
|
5
|
+
import type { TPricingTableExpanded } from '@blocklet/payment-types';
|
|
4
6
|
import Header from '@blocklet/ui-react/lib/Header';
|
|
5
|
-
import type { TPricingTableExpanded } from '@did-pay/types';
|
|
6
7
|
import { Alert, Box, Skeleton, Stack, Typography } from '@mui/material';
|
|
7
8
|
import { useLocalStorageState, useRequest } from 'ahooks';
|
|
8
9
|
import { useSearchParams } from 'react-router-dom';
|
|
9
10
|
|
|
10
|
-
import PricingTable from '../../components/checkout/pricing-table';
|
|
11
|
-
import Livemode from '../../components/livemode';
|
|
12
|
-
import ProductSkeleton from '../../components/pricing-table/product-skeleton';
|
|
13
|
-
import api from '../../libs/api';
|
|
14
|
-
|
|
15
11
|
type Props = {
|
|
16
12
|
id: string;
|
|
17
13
|
};
|
|
@@ -105,7 +101,7 @@ export default function PricingTablePage({ id }: Props) {
|
|
|
105
101
|
theme={undefined}
|
|
106
102
|
/>
|
|
107
103
|
<Center relative="parent">
|
|
108
|
-
<Alert severity="warning">{t('checkout.noPricing')}</Alert>
|
|
104
|
+
<Alert severity="warning">{t('payment.checkout.noPricing')}</Alert>
|
|
109
105
|
</Center>
|
|
110
106
|
</Box>
|
|
111
107
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { TCustomerExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { Edit } from '@mui/icons-material';
|
|
5
6
|
import { Alert, Box, Button, CircularProgress, Grid, Stack } from '@mui/material';
|
|
6
7
|
import { styled } from '@mui/system';
|
|
@@ -15,7 +16,6 @@ import CurrentSubscriptions from '../../components/portal/subscription/list';
|
|
|
15
16
|
import SectionHeader from '../../components/section/header';
|
|
16
17
|
import { useSessionContext } from '../../contexts/session';
|
|
17
18
|
import api from '../../libs/api';
|
|
18
|
-
import { formatError } from '../../libs/util';
|
|
19
19
|
|
|
20
20
|
const fetchData = (): Promise<TCustomerExpanded> => {
|
|
21
21
|
return api.get('/api/customers/me').then((res) => res.data);
|
|
@@ -44,7 +44,7 @@ export default function CustomerHome() {
|
|
|
44
44
|
if (!data) {
|
|
45
45
|
return (
|
|
46
46
|
<Alert sx={{ mt: 3 }} severity="info">
|
|
47
|
-
{t('customer.empty')}
|
|
47
|
+
{t('payment.customer.empty')}
|
|
48
48
|
</Alert>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -68,7 +68,7 @@ export default function CustomerHome() {
|
|
|
68
68
|
<Grid item xs={12} md={8}>
|
|
69
69
|
<Root direction="column" spacing={3} sx={{ my: 2 }}>
|
|
70
70
|
<Box className="section">
|
|
71
|
-
<SectionHeader title={t('customer.subscriptions.current')} mb={0} />
|
|
71
|
+
<SectionHeader title={t('payment.customer.subscriptions.current')} mb={0} />
|
|
72
72
|
<Box className="section-body">
|
|
73
73
|
<CurrentSubscriptions
|
|
74
74
|
id={data.id}
|
|
@@ -83,7 +83,7 @@ export default function CustomerHome() {
|
|
|
83
83
|
</Box>
|
|
84
84
|
</Box>
|
|
85
85
|
<Box className="section">
|
|
86
|
-
<SectionHeader title={t('customer.invoices')} mb={0} />
|
|
86
|
+
<SectionHeader title={t('payment.customer.invoices')} mb={0} />
|
|
87
87
|
<Box className="section-body">
|
|
88
88
|
<CustomerInvoiceList customer_id={data.id} />
|
|
89
89
|
</Box>
|
|
@@ -93,7 +93,7 @@ export default function CustomerHome() {
|
|
|
93
93
|
<Grid item xs={12} md={4}>
|
|
94
94
|
<Root direction="column" spacing={4} sx={{ my: 2 }}>
|
|
95
95
|
<Box className="section">
|
|
96
|
-
<SectionHeader title={t('customer.details')}>
|
|
96
|
+
<SectionHeader title={t('payment.customer.details')}>
|
|
97
97
|
<Button
|
|
98
98
|
variant="outlined"
|
|
99
99
|
color="inherit"
|
|
@@ -101,7 +101,7 @@ export default function CustomerHome() {
|
|
|
101
101
|
disabled={state.editing || state.loading}
|
|
102
102
|
onClick={() => setState({ editing: true })}>
|
|
103
103
|
<Edit fontSize="small" sx={{ mr: 0.5 }} />
|
|
104
|
-
{t('customer.update')}
|
|
104
|
+
{t('payment.customer.update')}
|
|
105
105
|
</Button>
|
|
106
106
|
</SectionHeader>
|
|
107
107
|
<Stack>
|