payment-kit 1.13.15
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/.eslintrc.js +15 -0
- package/README.md +3 -0
- package/api/dev.ts +6 -0
- package/api/hooks/pre-start.js +12 -0
- package/api/src/hooks/pre-start.ts +21 -0
- package/api/src/index.ts +92 -0
- package/api/src/jobs/event.ts +72 -0
- package/api/src/jobs/invoice.ts +148 -0
- package/api/src/jobs/payment.ts +208 -0
- package/api/src/jobs/subscription.ts +301 -0
- package/api/src/jobs/webhook.ts +113 -0
- package/api/src/libs/audit.ts +73 -0
- package/api/src/libs/auth.ts +40 -0
- package/api/src/libs/chain/arcblock.ts +13 -0
- package/api/src/libs/dayjs.ts +17 -0
- package/api/src/libs/env.ts +5 -0
- package/api/src/libs/hooks.ts +42 -0
- package/api/src/libs/logger.ts +27 -0
- package/api/src/libs/middleware.ts +12 -0
- package/api/src/libs/payment.ts +53 -0
- package/api/src/libs/queue/index.ts +263 -0
- package/api/src/libs/queue/store.ts +47 -0
- package/api/src/libs/security.ts +95 -0
- package/api/src/libs/session.ts +164 -0
- package/api/src/libs/util.ts +93 -0
- package/api/src/locales/en.ts +3 -0
- package/api/src/locales/index.ts +37 -0
- package/api/src/locales/zh.ts +3 -0
- package/api/src/routes/checkout-sessions.ts +536 -0
- package/api/src/routes/connect/collect.ts +109 -0
- package/api/src/routes/connect/pay.ts +116 -0
- package/api/src/routes/connect/setup.ts +121 -0
- package/api/src/routes/connect/shared.ts +410 -0
- package/api/src/routes/connect/subscribe.ts +128 -0
- package/api/src/routes/customers.ts +70 -0
- package/api/src/routes/events.ts +76 -0
- package/api/src/routes/index.ts +59 -0
- package/api/src/routes/invoices.ts +126 -0
- package/api/src/routes/payment-currencies.ts +38 -0
- package/api/src/routes/payment-intents.ts +122 -0
- package/api/src/routes/payment-links.ts +221 -0
- package/api/src/routes/payment-methods.ts +39 -0
- package/api/src/routes/prices.ts +134 -0
- package/api/src/routes/products.ts +191 -0
- package/api/src/routes/settings.ts +33 -0
- package/api/src/routes/subscription-items.ts +148 -0
- package/api/src/routes/subscriptions.ts +254 -0
- package/api/src/routes/usage-records.ts +120 -0
- package/api/src/routes/webhook-attempts.ts +57 -0
- package/api/src/routes/webhook-endpoints.ts +105 -0
- package/api/src/store/migrate.ts +16 -0
- package/api/src/store/migrations/20230905-genesis.ts +52 -0
- package/api/src/store/migrations/20230911-seeding.ts +145 -0
- package/api/src/store/models/checkout-session.ts +395 -0
- package/api/src/store/models/coupon.ts +137 -0
- package/api/src/store/models/customer.ts +199 -0
- package/api/src/store/models/discount.ts +116 -0
- package/api/src/store/models/event.ts +111 -0
- package/api/src/store/models/index.ts +165 -0
- package/api/src/store/models/invoice-item.ts +185 -0
- package/api/src/store/models/invoice.ts +492 -0
- package/api/src/store/models/job.ts +75 -0
- package/api/src/store/models/payment-currency.ts +139 -0
- package/api/src/store/models/payment-intent.ts +282 -0
- package/api/src/store/models/payment-link.ts +219 -0
- package/api/src/store/models/payment-method.ts +169 -0
- package/api/src/store/models/price.ts +266 -0
- package/api/src/store/models/product.ts +162 -0
- package/api/src/store/models/promotion-code.ts +112 -0
- package/api/src/store/models/setup-intent.ts +206 -0
- package/api/src/store/models/subscription-item.ts +103 -0
- package/api/src/store/models/subscription-schedule.ts +157 -0
- package/api/src/store/models/subscription.ts +307 -0
- package/api/src/store/models/types.ts +406 -0
- package/api/src/store/models/usage-record.ts +132 -0
- package/api/src/store/models/webhook-attempt.ts +96 -0
- package/api/src/store/models/webhook-endpoint.ts +96 -0
- package/api/src/store/sequelize.ts +15 -0
- package/api/third.d.ts +28 -0
- package/blocklet.md +3 -0
- package/blocklet.yml +89 -0
- package/index.html +14 -0
- package/logo.png +0 -0
- package/package.json +133 -0
- package/public/.gitkeep +0 -0
- package/screenshots/.gitkeep +0 -0
- package/screenshots/1-subscription.png +0 -0
- package/screenshots/2-customer-1.png +0 -0
- package/screenshots/3-customer-2.png +0 -0
- package/screenshots/4-admin-3.png +0 -0
- package/screenshots/5-admin-4.png +0 -0
- package/scripts/build-clean.js +6 -0
- package/scripts/bump-version.mjs +35 -0
- package/src/app.tsx +68 -0
- package/src/components/actions.tsx +85 -0
- package/src/components/blockchain/tx.tsx +29 -0
- package/src/components/checkout/amount.tsx +24 -0
- package/src/components/checkout/error.tsx +30 -0
- package/src/components/checkout/footer.tsx +12 -0
- package/src/components/checkout/form/address.tsx +38 -0
- package/src/components/checkout/form/index.tsx +295 -0
- package/src/components/checkout/header.tsx +23 -0
- package/src/components/checkout/pay.tsx +222 -0
- package/src/components/checkout/product-card.tsx +56 -0
- package/src/components/checkout/product-item.tsx +37 -0
- package/src/components/checkout/skeleton/overview.tsx +21 -0
- package/src/components/checkout/skeleton/payment.tsx +35 -0
- package/src/components/checkout/success.tsx +183 -0
- package/src/components/checkout/summary.tsx +34 -0
- package/src/components/collapse.tsx +50 -0
- package/src/components/confirm.tsx +55 -0
- package/src/components/copyable.tsx +38 -0
- package/src/components/currency.tsx +15 -0
- package/src/components/customer/actions.tsx +73 -0
- package/src/components/data.tsx +20 -0
- package/src/components/drawer-form.tsx +77 -0
- package/src/components/error-fallback.tsx +7 -0
- package/src/components/error.tsx +39 -0
- package/src/components/event/list.tsx +217 -0
- package/src/components/info-card.tsx +40 -0
- package/src/components/info-metric.tsx +35 -0
- package/src/components/info-row.tsx +28 -0
- package/src/components/input.tsx +40 -0
- package/src/components/invoice/action.tsx +94 -0
- package/src/components/invoice/list.tsx +225 -0
- package/src/components/invoice/table.tsx +110 -0
- package/src/components/layout.tsx +70 -0
- package/src/components/livemode.tsx +23 -0
- package/src/components/metadata/editor.tsx +57 -0
- package/src/components/metadata/form.tsx +45 -0
- package/src/components/payment-intent/actions.tsx +81 -0
- package/src/components/payment-intent/list.tsx +204 -0
- package/src/components/payment-link/actions.tsx +114 -0
- package/src/components/payment-link/after-pay.tsx +87 -0
- package/src/components/payment-link/before-pay.tsx +175 -0
- package/src/components/payment-link/item.tsx +135 -0
- package/src/components/payment-link/product-select.tsx +66 -0
- package/src/components/payment-link/rename.tsx +64 -0
- package/src/components/portal/invoice/list.tsx +110 -0
- package/src/components/portal/subscription/cancel.tsx +83 -0
- package/src/components/portal/subscription/list.tsx +232 -0
- package/src/components/price/actions.tsx +21 -0
- package/src/components/price/form.tsx +292 -0
- package/src/components/product/actions.tsx +125 -0
- package/src/components/product/add-price.tsx +59 -0
- package/src/components/product/create.tsx +97 -0
- package/src/components/product/edit-price.tsx +75 -0
- package/src/components/product/edit.tsx +67 -0
- package/src/components/product/features.tsx +32 -0
- package/src/components/product/form.tsx +76 -0
- package/src/components/relative-time.tsx +41 -0
- package/src/components/section/header.tsx +29 -0
- package/src/components/status.tsx +12 -0
- package/src/components/subscription/actions/cancel.tsx +66 -0
- package/src/components/subscription/actions/index.tsx +172 -0
- package/src/components/subscription/actions/pause.tsx +83 -0
- package/src/components/subscription/items/actions.tsx +31 -0
- package/src/components/subscription/items/index.tsx +107 -0
- package/src/components/subscription/list.tsx +200 -0
- package/src/components/switch.tsx +48 -0
- package/src/components/table.tsx +66 -0
- package/src/components/uploader.tsx +81 -0
- package/src/components/webhook/attempts.tsx +149 -0
- package/src/contexts/products.tsx +42 -0
- package/src/contexts/session.ts +10 -0
- package/src/contexts/settings.tsx +54 -0
- package/src/env.d.ts +17 -0
- package/src/global.css +97 -0
- package/src/hooks/mobile.ts +15 -0
- package/src/index.tsx +6 -0
- package/src/libs/api.ts +19 -0
- package/src/libs/dayjs.ts +17 -0
- package/src/libs/util.ts +474 -0
- package/src/locales/en.tsx +395 -0
- package/src/locales/index.tsx +8 -0
- package/src/locales/zh.tsx +389 -0
- package/src/pages/admin/billing/index.tsx +56 -0
- package/src/pages/admin/billing/invoices/detail.tsx +215 -0
- package/src/pages/admin/billing/invoices/index.tsx +5 -0
- package/src/pages/admin/billing/subscriptions/detail.tsx +237 -0
- package/src/pages/admin/billing/subscriptions/index.tsx +5 -0
- package/src/pages/admin/customers/customers/detail.tsx +209 -0
- package/src/pages/admin/customers/customers/index.tsx +109 -0
- package/src/pages/admin/customers/index.tsx +47 -0
- package/src/pages/admin/developers/events/detail.tsx +77 -0
- package/src/pages/admin/developers/events/index.tsx +5 -0
- package/src/pages/admin/developers/index.tsx +60 -0
- package/src/pages/admin/developers/logs.tsx +3 -0
- package/src/pages/admin/developers/overview.tsx +3 -0
- package/src/pages/admin/developers/webhooks/detail.tsx +109 -0
- package/src/pages/admin/developers/webhooks/index.tsx +102 -0
- package/src/pages/admin/index.tsx +120 -0
- package/src/pages/admin/overview.tsx +3 -0
- package/src/pages/admin/payments/index.tsx +65 -0
- package/src/pages/admin/payments/intents/detail.tsx +205 -0
- package/src/pages/admin/payments/intents/index.tsx +5 -0
- package/src/pages/admin/payments/links/create.tsx +141 -0
- package/src/pages/admin/payments/links/detail.tsx +318 -0
- package/src/pages/admin/payments/links/index.tsx +167 -0
- package/src/pages/admin/products/coupons/index.tsx +3 -0
- package/src/pages/admin/products/index.tsx +81 -0
- package/src/pages/admin/products/prices/actions.tsx +151 -0
- package/src/pages/admin/products/prices/detail.tsx +203 -0
- package/src/pages/admin/products/prices/list.tsx +95 -0
- package/src/pages/admin/products/pricing-tables.tsx +3 -0
- package/src/pages/admin/products/products/create.tsx +105 -0
- package/src/pages/admin/products/products/detail.tsx +246 -0
- package/src/pages/admin/products/products/index.tsx +154 -0
- package/src/pages/admin/settings/branding.tsx +3 -0
- package/src/pages/admin/settings/business.tsx +3 -0
- package/src/pages/admin/settings/index.tsx +47 -0
- package/src/pages/admin/settings/payment-methods.tsx +80 -0
- package/src/pages/checkout/index.tsx +38 -0
- package/src/pages/checkout/pay.tsx +89 -0
- package/src/pages/customer/index.tsx +93 -0
- package/src/pages/customer/invoice.tsx +147 -0
- package/src/pages/home.tsx +9 -0
- package/tsconfig.api.json +9 -0
- package/tsconfig.eslint.json +7 -0
- package/tsconfig.json +99 -0
- package/tsconfig.types.json +11 -0
- package/vite.config.ts +19 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
|
|
5
|
+
|
|
6
|
+
export function useSessionContext(): any {
|
|
7
|
+
return useContext(SessionContext);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SessionProvider, SessionContext, SessionConsumer, withSession };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TPaymentCurrency, TPaymentMethod } from '@did-pay/types';
|
|
2
|
+
import { Alert, CircularProgress } from '@mui/material';
|
|
3
|
+
import { useLocalStorageState, useRequest } from 'ahooks';
|
|
4
|
+
import type { Axios } from 'axios';
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
|
|
7
|
+
import api from '../libs/api';
|
|
8
|
+
|
|
9
|
+
export interface Settings {
|
|
10
|
+
paymentMethods: TPaymentMethod[];
|
|
11
|
+
baseCurrency: TPaymentCurrency;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type SettingsContextType = {
|
|
15
|
+
livemode: boolean;
|
|
16
|
+
settings: Settings;
|
|
17
|
+
refresh: () => void;
|
|
18
|
+
setLivemode: (livemode: boolean) => void;
|
|
19
|
+
api: Axios;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
const SettingsContext = createContext<SettingsContextType>({ api });
|
|
24
|
+
const { Provider, Consumer } = SettingsContext;
|
|
25
|
+
|
|
26
|
+
const getSettings = async () => {
|
|
27
|
+
const { data } = await api.get('/api/settings');
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line react/prop-types
|
|
32
|
+
function SettingsProvider({ children }: { children: any }): JSX.Element {
|
|
33
|
+
const { data, error, run, loading } = useRequest(getSettings);
|
|
34
|
+
const [livemode, setLivemode] = useLocalStorageState('livemode', { defaultValue: true });
|
|
35
|
+
|
|
36
|
+
if (error) {
|
|
37
|
+
return <Alert severity="error">{error.message}</Alert>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (loading) {
|
|
41
|
+
return <CircularProgress />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Provider value={{ livemode: !!livemode, settings: data, refresh: run, setLivemode, api }}>{children}</Provider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function useSettingsContext() {
|
|
50
|
+
const context = useContext(SettingsContext);
|
|
51
|
+
return context;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { SettingsContext, SettingsProvider, Consumer as SettingsConsumer, useSettingsContext };
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare var blocklet: {
|
|
2
|
+
appName: string;
|
|
3
|
+
appLogo: string;
|
|
4
|
+
appUrl: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
languages: { code: string; name: string }[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare module '*.svg';
|
|
10
|
+
|
|
11
|
+
declare module 'flat';
|
|
12
|
+
|
|
13
|
+
declare module '@arcblock/*';
|
|
14
|
+
|
|
15
|
+
declare module '@blocklet/*';
|
|
16
|
+
|
|
17
|
+
declare module 'pretty-ms-i18n';
|
package/src/global.css
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
html,
|
|
2
|
+
body {
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: 0;
|
|
5
|
+
font-size: 14px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
a {
|
|
9
|
+
text-decoration: none;
|
|
10
|
+
color: rgba(0, 0, 0, 0.87);
|
|
11
|
+
}
|
|
12
|
+
a:hover {
|
|
13
|
+
color: rgba(0, 0, 0, 0.87);
|
|
14
|
+
text-decoration: underline;
|
|
15
|
+
}
|
|
16
|
+
a:visited {
|
|
17
|
+
color: rgba(0, 0, 0, 0.87);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.MuiButton-sizeSmall {
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
font-size: 1rem;
|
|
23
|
+
line-height: 1.5;
|
|
24
|
+
border-color: #ccc;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.MuiTab-root {
|
|
28
|
+
padding: 0;
|
|
29
|
+
margin-right: 24px;
|
|
30
|
+
min-height: 32px;
|
|
31
|
+
min-width: auto;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.MuiTabs-root {
|
|
35
|
+
min-height: 32px;
|
|
36
|
+
margin-bottom: 8px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.MuiTabs-scroller {
|
|
40
|
+
border-bottom: 1px solid #eee;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.MuiCheckbox-root {
|
|
44
|
+
padding: 0;
|
|
45
|
+
padding-right: 4px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.MuiFormLabel-root {
|
|
49
|
+
color: rgba(0, 0, 0, 0.8);
|
|
50
|
+
display: block;
|
|
51
|
+
margin-bottom: 8px;
|
|
52
|
+
font-weight: 500;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.MuiToggleButton-root {
|
|
56
|
+
padding: 4px 16px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.MuiDialogContent-root {
|
|
60
|
+
padding: 0 24px 16px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.MuiTableCell-root {
|
|
64
|
+
font-size: 1rem !important;
|
|
65
|
+
padding-right: 24px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
th.MuiTableCell-head {
|
|
69
|
+
padding: 8px 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.MuiRadio-root {
|
|
73
|
+
padding: 4px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.MuiDialogActions-root {
|
|
77
|
+
padding-top: 16px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.MuiDialogContent-root {
|
|
81
|
+
padding-top: 0px !important;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.MuiFormHelperText-root {
|
|
85
|
+
margin-left: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.codeblock__inner {
|
|
89
|
+
display: block;
|
|
90
|
+
width: 100%;
|
|
91
|
+
max-height: 100% !important;
|
|
92
|
+
overflow: auto !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.MuiTableRow-hover {
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useTheme } from '@mui/material/styles';
|
|
2
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
3
|
+
|
|
4
|
+
const MOBILE_POINT = 'md';
|
|
5
|
+
|
|
6
|
+
function useMobile() {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
isMobile: useMediaQuery(theme.breakpoints.down(MOBILE_POINT)),
|
|
11
|
+
mobileSize: `${theme.breakpoints.values[MOBILE_POINT]}px`,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default useMobile;
|
package/src/index.tsx
ADDED
package/src/libs/api.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getLocale } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
axios.interceptors.request.use(
|
|
5
|
+
(config) => {
|
|
6
|
+
const prefix = window.blocklet ? window.blocklet.prefix : '/';
|
|
7
|
+
config.baseURL = prefix || '';
|
|
8
|
+
config.timeout = 200000;
|
|
9
|
+
|
|
10
|
+
const livemode = localStorage.getItem('livemode');
|
|
11
|
+
const locale = getLocale(window.blocklet.languages);
|
|
12
|
+
config.params = { ...(config.params || {}), livemode, locale };
|
|
13
|
+
|
|
14
|
+
return config;
|
|
15
|
+
},
|
|
16
|
+
(error) => Promise.reject(error)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default axios;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import duration from 'dayjs/plugin/duration';
|
|
3
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
5
|
+
import timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin
|
|
6
|
+
import utc from 'dayjs/plugin/utc';
|
|
7
|
+
|
|
8
|
+
import('dayjs/locale/en');
|
|
9
|
+
import('dayjs/locale/zh');
|
|
10
|
+
|
|
11
|
+
dayjs.extend(relativeTime);
|
|
12
|
+
dayjs.extend(localizedFormat);
|
|
13
|
+
dayjs.extend(duration);
|
|
14
|
+
dayjs.extend(utc);
|
|
15
|
+
dayjs.extend(timezone);
|
|
16
|
+
|
|
17
|
+
export default dayjs;
|