payment-kit 1.18.39 → 1.18.40
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/subscription.ts +107 -97
- package/api/src/routes/checkout-sessions.ts +3 -1
- package/api/src/routes/subscriptions.ts +3 -1
- package/blocklet.yml +1 -1
- package/package.json +9 -9
- package/scripts/sdk.js +27 -1
- package/src/components/customer/link.tsx +6 -0
- package/src/components/info-card.tsx +2 -2
- package/src/components/info-metric.tsx +1 -1
- package/src/components/metadata/list.tsx +4 -2
- package/src/components/subscription/description.tsx +8 -6
- package/src/components/subscription/portal/actions.tsx +105 -36
- package/src/components/subscription/portal/list.tsx +152 -74
- package/src/components/subscription/status.tsx +17 -5
- package/src/locales/en.tsx +12 -7
- package/src/locales/zh.tsx +6 -2
- package/src/pages/admin/billing/invoices/detail.tsx +1 -5
- package/src/pages/admin/billing/subscriptions/detail.tsx +1 -5
- package/src/pages/admin/customers/customers/detail.tsx +1 -5
- package/src/pages/admin/developers/events/detail.tsx +1 -5
- package/src/pages/admin/developers/index.tsx +1 -1
- package/src/pages/admin/developers/webhooks/detail.tsx +1 -3
- package/src/pages/admin/overview.tsx +4 -4
- package/src/pages/admin/payments/intents/detail.tsx +1 -5
- package/src/pages/admin/payments/payouts/detail.tsx +1 -5
- package/src/pages/admin/payments/refunds/detail.tsx +1 -5
- package/src/pages/admin/products/links/detail.tsx +1 -5
- package/src/pages/admin/products/prices/detail.tsx +1 -5
- package/src/pages/admin/products/pricing-tables/detail.tsx +1 -5
- package/src/pages/admin/products/products/detail.tsx +1 -5
- package/src/pages/admin/settings/payment-methods/index.tsx +1 -1
- package/src/pages/customer/index.tsx +67 -138
- package/src/pages/customer/payout/detail.tsx +37 -49
- package/src/pages/customer/subscription/change-payment.tsx +2 -35
- package/src/pages/customer/subscription/detail.tsx +1 -5
- package/src/pages/integrations/donations/index.tsx +1 -1
- package/src/pages/integrations/overview.tsx +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import { Status,
|
|
2
|
+
import { Status, getSubscriptionStatusColor, formatSubscriptionStatus, getLineTimeInfo } from '@blocklet/payment-react';
|
|
3
3
|
import type { TSubscription } from '@blocklet/payment-types';
|
|
4
4
|
import { AccessTimeOutlined } from '@mui/icons-material';
|
|
5
5
|
|
|
@@ -13,10 +13,14 @@ export default function SubscriptionStatus({
|
|
|
13
13
|
const { t } = useLocaleContext();
|
|
14
14
|
if (subscription.status === 'active' || subscription.status === 'trialing') {
|
|
15
15
|
if (subscription.cancel_at_period_end && subscription.current_period_end > Date.now() / 1000) {
|
|
16
|
+
const dateInfo = getLineTimeInfo(subscription.current_period_end * 1000);
|
|
16
17
|
return (
|
|
17
18
|
<Status
|
|
18
19
|
icon={<AccessTimeOutlined />}
|
|
19
|
-
label={t('admin.subscription.cancel.will', {
|
|
20
|
+
label={t('admin.subscription.cancel.will', {
|
|
21
|
+
date: dateInfo.time,
|
|
22
|
+
prefix: dateInfo.isToday ? 'at' : 'on',
|
|
23
|
+
})}
|
|
20
24
|
color="warning"
|
|
21
25
|
{...rest}
|
|
22
26
|
/>
|
|
@@ -24,10 +28,14 @@ export default function SubscriptionStatus({
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
if (subscription.cancel_at && subscription.cancel_at >= Date.now() / 1000) {
|
|
31
|
+
const dateInfo = getLineTimeInfo(subscription.cancel_at * 1000);
|
|
27
32
|
return (
|
|
28
33
|
<Status
|
|
29
34
|
icon={<AccessTimeOutlined />}
|
|
30
|
-
label={t('admin.subscription.cancel.will', {
|
|
35
|
+
label={t('admin.subscription.cancel.will', {
|
|
36
|
+
date: dateInfo.time,
|
|
37
|
+
prefix: dateInfo.isToday ? 'at' : 'on',
|
|
38
|
+
})}
|
|
31
39
|
color="warning"
|
|
32
40
|
{...rest}
|
|
33
41
|
/>
|
|
@@ -35,10 +43,12 @@ export default function SubscriptionStatus({
|
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
if (subscription.trial_end && subscription.trial_end > Date.now() / 1000) {
|
|
46
|
+
const dateInfo = getLineTimeInfo(subscription.trial_end * 1000);
|
|
38
47
|
return (
|
|
39
48
|
<Status
|
|
40
49
|
label={t('admin.subscription.trialEnd', {
|
|
41
|
-
date:
|
|
50
|
+
date: dateInfo.time,
|
|
51
|
+
prefix: dateInfo.isToday ? 'at' : 'on',
|
|
42
52
|
})}
|
|
43
53
|
color="info"
|
|
44
54
|
{...rest}
|
|
@@ -49,11 +59,13 @@ export default function SubscriptionStatus({
|
|
|
49
59
|
|
|
50
60
|
if (subscription.pause_collection && ['active', 'trialing'].includes(subscription.status)) {
|
|
51
61
|
if (subscription.pause_collection.resumes_at && subscription.pause_collection.resumes_at > Date.now() / 1000) {
|
|
62
|
+
const dateInfo = getLineTimeInfo(subscription.pause_collection.resumes_at * 1000);
|
|
52
63
|
return (
|
|
53
64
|
<Status
|
|
54
65
|
icon={<AccessTimeOutlined />}
|
|
55
66
|
label={t('admin.subscription.pause.until.custom', {
|
|
56
|
-
date:
|
|
67
|
+
date: dateInfo.time,
|
|
68
|
+
prefix: dateInfo.isToday ? 'at' : 'on',
|
|
57
69
|
})}
|
|
58
70
|
color="default"
|
|
59
71
|
{...rest}
|
package/src/locales/en.tsx
CHANGED
|
@@ -506,7 +506,7 @@ export default flat({
|
|
|
506
506
|
attention: 'Uncollectible invoices',
|
|
507
507
|
name: 'Invoice',
|
|
508
508
|
from: 'Billed from',
|
|
509
|
-
empty: 'No
|
|
509
|
+
empty: 'No invoices',
|
|
510
510
|
number: 'Invoice Number',
|
|
511
511
|
description: 'Billing Description',
|
|
512
512
|
dueDate: 'Due',
|
|
@@ -522,7 +522,7 @@ export default flat({
|
|
|
522
522
|
subscription: {
|
|
523
523
|
view: 'View subscription',
|
|
524
524
|
name: 'Subscription',
|
|
525
|
-
empty: 'No
|
|
525
|
+
empty: 'No subscriptions',
|
|
526
526
|
viewAll: 'View all subscriptions',
|
|
527
527
|
noActiveEmpty: 'You currently have no active subscriptions. You can choose to view your subscription history.',
|
|
528
528
|
attention: 'Past due subscriptions',
|
|
@@ -530,7 +530,10 @@ export default flat({
|
|
|
530
530
|
collectionMethod: 'Billing',
|
|
531
531
|
currentPeriod: 'Current Period',
|
|
532
532
|
trialingPeriod: 'Trial Period',
|
|
533
|
-
trialEnd: 'Trial ends {date}',
|
|
533
|
+
trialEnd: 'Trial ends {prefix} {date}',
|
|
534
|
+
willEnd: 'Will end {prefix} {date}',
|
|
535
|
+
ended: 'Ended {prefix} {date}',
|
|
536
|
+
renew: 'Renew {prefix} {date}',
|
|
534
537
|
discount: 'Discount',
|
|
535
538
|
startedAt: 'Started',
|
|
536
539
|
nextInvoice: 'Next Invoice',
|
|
@@ -547,7 +550,7 @@ export default flat({
|
|
|
547
550
|
schedule: 'Scheduled to cancel',
|
|
548
551
|
title: 'Cancel subscription',
|
|
549
552
|
required: 'Custom cancel time is required',
|
|
550
|
-
will: 'End
|
|
553
|
+
will: 'End {prefix} {date}',
|
|
551
554
|
done: 'Canceled',
|
|
552
555
|
at: {
|
|
553
556
|
title: 'Cancel',
|
|
@@ -813,10 +816,12 @@ export default flat({
|
|
|
813
816
|
customer: {
|
|
814
817
|
subscription: {
|
|
815
818
|
cancel: 'Cancel Subscription',
|
|
819
|
+
manage: 'Manage Subscription',
|
|
820
|
+
title: 'Subscriptions',
|
|
816
821
|
},
|
|
817
822
|
invoiceHistory: 'Invoice History',
|
|
818
823
|
product: {
|
|
819
|
-
empty: 'No
|
|
824
|
+
empty: 'No Products',
|
|
820
825
|
},
|
|
821
826
|
recharge: {
|
|
822
827
|
title: 'Add Funds',
|
|
@@ -885,12 +890,12 @@ export default flat({
|
|
|
885
890
|
donation: 'Donation',
|
|
886
891
|
},
|
|
887
892
|
payout: {
|
|
888
|
-
empty: 'No
|
|
893
|
+
empty: 'No Revenues',
|
|
889
894
|
payer: 'Payer',
|
|
890
895
|
receiver: 'Receiver',
|
|
891
896
|
payTxHash: 'Payment TxHash',
|
|
892
897
|
viewReference: 'View Reference',
|
|
893
|
-
title: '
|
|
898
|
+
title: 'Revenues',
|
|
894
899
|
},
|
|
895
900
|
pastDue: {
|
|
896
901
|
warning: 'You have due invoices, please pay them to keep your services active',
|
package/src/locales/zh.tsx
CHANGED
|
@@ -519,7 +519,10 @@ export default flat({
|
|
|
519
519
|
collectionMethod: '计费',
|
|
520
520
|
currentPeriod: '当前周期',
|
|
521
521
|
trialingPeriod: '试用期',
|
|
522
|
-
trialEnd: '试用期结束于{date}',
|
|
522
|
+
trialEnd: '试用期结束于 {date}',
|
|
523
|
+
willEnd: '将于 {date} 结束',
|
|
524
|
+
ended: '结束于 {date}',
|
|
525
|
+
renew: '下次续费: {date}',
|
|
523
526
|
discount: '折扣',
|
|
524
527
|
startedAt: '开始于',
|
|
525
528
|
nextInvoice: '下次账单时间',
|
|
@@ -535,7 +538,7 @@ export default flat({
|
|
|
535
538
|
schedule: '计划取消',
|
|
536
539
|
title: '取消订阅',
|
|
537
540
|
required: '必须指定自定义取消时间',
|
|
538
|
-
will: '于{date}取消',
|
|
541
|
+
will: '于 {date} 取消',
|
|
539
542
|
done: '已取消',
|
|
540
543
|
at: {
|
|
541
544
|
title: '取消',
|
|
@@ -789,6 +792,7 @@ export default flat({
|
|
|
789
792
|
},
|
|
790
793
|
customer: {
|
|
791
794
|
subscription: {
|
|
795
|
+
manage: '管理订阅',
|
|
792
796
|
cancel: '取消订阅',
|
|
793
797
|
},
|
|
794
798
|
invoiceHistory: '历史账单',
|
|
@@ -172,11 +172,7 @@ export default function InvoiceDetail(props: { id: string }) {
|
|
|
172
172
|
sm: 'column',
|
|
173
173
|
md: 'row',
|
|
174
174
|
},
|
|
175
|
-
alignItems:
|
|
176
|
-
xs: 'flex-start',
|
|
177
|
-
sm: 'flex-start',
|
|
178
|
-
md: 'center',
|
|
179
|
-
},
|
|
175
|
+
alignItems: 'flex-start',
|
|
180
176
|
gap: {
|
|
181
177
|
xs: 1,
|
|
182
178
|
sm: 1,
|
|
@@ -143,11 +143,7 @@ export default function SubscriptionDetail(props: { id: string }) {
|
|
|
143
143
|
sm: 'column',
|
|
144
144
|
md: 'row',
|
|
145
145
|
},
|
|
146
|
-
alignItems:
|
|
147
|
-
xs: 'flex-start',
|
|
148
|
-
sm: 'flex-start',
|
|
149
|
-
md: 'center',
|
|
150
|
-
},
|
|
146
|
+
alignItems: 'flex-start',
|
|
151
147
|
gap: {
|
|
152
148
|
xs: 1,
|
|
153
149
|
sm: 1,
|
|
@@ -232,11 +232,7 @@ export default function CustomerDetail(props: { id: string }) {
|
|
|
232
232
|
sm: 'column',
|
|
233
233
|
md: 'row',
|
|
234
234
|
},
|
|
235
|
-
alignItems:
|
|
236
|
-
xs: 'flex-start',
|
|
237
|
-
sm: 'flex-start',
|
|
238
|
-
md: 'center',
|
|
239
|
-
},
|
|
235
|
+
alignItems: 'flex-start',
|
|
240
236
|
gap: {
|
|
241
237
|
xs: 1,
|
|
242
238
|
sm: 1,
|
|
@@ -49,9 +49,7 @@ export default function WebhookDetail(props: { id: string }) {
|
|
|
49
49
|
<Box mt={2}>
|
|
50
50
|
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
|
51
51
|
<Stack direction="column" alignItems="flex-start">
|
|
52
|
-
<Typography variant="h5"
|
|
53
|
-
{data.url}
|
|
54
|
-
</Typography>
|
|
52
|
+
<Typography variant="h5">{data.url}</Typography>
|
|
55
53
|
<Typography variant="body1" color="text.secondary">
|
|
56
54
|
{data.description}
|
|
57
55
|
</Typography>
|
|
@@ -222,19 +222,19 @@ export default function Overview() {
|
|
|
222
222
|
</Button>
|
|
223
223
|
</Stack>
|
|
224
224
|
<Stack direction="column" gap={1}>
|
|
225
|
-
<Typography component="h4" variant="
|
|
225
|
+
<Typography component="h4" variant="subtitle1">
|
|
226
226
|
{t('admin.paymentIntent.list')}
|
|
227
227
|
</Typography>
|
|
228
228
|
<Chart loading={!trend.data} height={320} data={payments} currencies={currencies} />
|
|
229
229
|
</Stack>
|
|
230
230
|
<Stack direction="column" gap={1}>
|
|
231
|
-
<Typography component="h4" variant="
|
|
231
|
+
<Typography component="h4" variant="subtitle1">
|
|
232
232
|
{t('admin.payouts')}
|
|
233
233
|
</Typography>
|
|
234
234
|
<Chart loading={!trend.data} height={320} data={payouts} currencies={currencies} />
|
|
235
235
|
</Stack>
|
|
236
236
|
<Stack direction="column" gap={1}>
|
|
237
|
-
<Typography component="h4" variant="
|
|
237
|
+
<Typography component="h4" variant="subtitle1">
|
|
238
238
|
{t('admin.refunds')}
|
|
239
239
|
</Typography>
|
|
240
240
|
<Chart loading={!trend.data} height={320} data={refunds} currencies={currencies} />
|
|
@@ -298,7 +298,7 @@ export default function Overview() {
|
|
|
298
298
|
sx={{ width: 36, height: 36 }}
|
|
299
299
|
/>
|
|
300
300
|
<Box flex={1}>
|
|
301
|
-
<Typography variant="
|
|
301
|
+
<Typography variant="body1" component="div" sx={{ fontSize: '1.75rem' }}>
|
|
302
302
|
{formatBNStr(
|
|
303
303
|
summary.data?.balances?.[currencyId] as string,
|
|
304
304
|
currencies[currencyId]?.decimal as number
|
|
@@ -161,11 +161,7 @@ export default function PaymentIntentDetail(props: { id: string }) {
|
|
|
161
161
|
sm: 'column',
|
|
162
162
|
md: 'row',
|
|
163
163
|
},
|
|
164
|
-
alignItems:
|
|
165
|
-
xs: 'flex-start',
|
|
166
|
-
sm: 'flex-start',
|
|
167
|
-
md: 'center',
|
|
168
|
-
},
|
|
164
|
+
alignItems: 'flex-start',
|
|
169
165
|
gap: {
|
|
170
166
|
xs: 1,
|
|
171
167
|
sm: 1,
|
|
@@ -182,11 +182,7 @@ export default function PayoutDetail(props: { id: string }) {
|
|
|
182
182
|
sm: 'column',
|
|
183
183
|
md: 'row',
|
|
184
184
|
},
|
|
185
|
-
alignItems:
|
|
186
|
-
xs: 'flex-start',
|
|
187
|
-
sm: 'flex-start',
|
|
188
|
-
md: 'center',
|
|
189
|
-
},
|
|
185
|
+
alignItems: 'flex-start',
|
|
190
186
|
gap: {
|
|
191
187
|
xs: 1,
|
|
192
188
|
sm: 1,
|
|
@@ -156,11 +156,7 @@ export default function RefundDetail(props: { id: string }) {
|
|
|
156
156
|
sm: 'column',
|
|
157
157
|
md: 'row',
|
|
158
158
|
},
|
|
159
|
-
alignItems:
|
|
160
|
-
xs: 'flex-start',
|
|
161
|
-
sm: 'flex-start',
|
|
162
|
-
md: 'center',
|
|
163
|
-
},
|
|
159
|
+
alignItems: 'flex-start',
|
|
164
160
|
gap: {
|
|
165
161
|
xs: 1,
|
|
166
162
|
sm: 1,
|
|
@@ -171,11 +171,7 @@ export default function PaymentLinkDetail(props: { id: string }) {
|
|
|
171
171
|
sm: 'column',
|
|
172
172
|
md: 'row',
|
|
173
173
|
},
|
|
174
|
-
alignItems:
|
|
175
|
-
xs: 'flex-start',
|
|
176
|
-
sm: 'flex-start',
|
|
177
|
-
md: 'center',
|
|
178
|
-
},
|
|
174
|
+
alignItems: 'flex-start',
|
|
179
175
|
gap: {
|
|
180
176
|
xs: 1,
|
|
181
177
|
sm: 1,
|
|
@@ -161,11 +161,7 @@ export default function PriceDetail(props: { id: string }) {
|
|
|
161
161
|
sm: 'column',
|
|
162
162
|
md: 'row',
|
|
163
163
|
},
|
|
164
|
-
alignItems:
|
|
165
|
-
xs: 'flex-start',
|
|
166
|
-
sm: 'flex-start',
|
|
167
|
-
md: 'center',
|
|
168
|
-
},
|
|
164
|
+
alignItems: 'flex-start',
|
|
169
165
|
gap: {
|
|
170
166
|
xs: 1,
|
|
171
167
|
sm: 1,
|
|
@@ -157,11 +157,7 @@ export default function PricingTableDetail(props: { id: string }) {
|
|
|
157
157
|
sm: 'column',
|
|
158
158
|
md: 'row',
|
|
159
159
|
},
|
|
160
|
-
alignItems:
|
|
161
|
-
xs: 'flex-start',
|
|
162
|
-
sm: 'flex-start',
|
|
163
|
-
md: 'center',
|
|
164
|
-
},
|
|
160
|
+
alignItems: 'flex-start',
|
|
165
161
|
gap: {
|
|
166
162
|
xs: 1,
|
|
167
163
|
sm: 1,
|
|
@@ -197,11 +197,7 @@ export default function ProductDetail(props: { id: string }) {
|
|
|
197
197
|
sm: 'column',
|
|
198
198
|
md: 'row',
|
|
199
199
|
},
|
|
200
|
-
alignItems:
|
|
201
|
-
xs: 'flex-start',
|
|
202
|
-
sm: 'flex-start',
|
|
203
|
-
md: 'center',
|
|
204
|
-
},
|
|
200
|
+
alignItems: 'flex-start',
|
|
205
201
|
gap: {
|
|
206
202
|
xs: 1,
|
|
207
203
|
sm: 1,
|
|
@@ -421,7 +421,7 @@ export default function PaymentMethods() {
|
|
|
421
421
|
{Object.keys(groups).map((x) => (
|
|
422
422
|
<Box key={x} mt={3}>
|
|
423
423
|
<Stack direction="row" alignItems="center" mb={1} flexWrap="wrap" gap={1}>
|
|
424
|
-
<Typography variant="
|
|
424
|
+
<Typography variant="subtitle2" sx={{ textTransform: 'uppercase' }}>
|
|
425
425
|
{x}
|
|
426
426
|
</Typography>
|
|
427
427
|
</Stack>
|