payment-kit 1.19.0 → 1.19.2
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/crons/index.ts +8 -0
- package/api/src/index.ts +4 -0
- package/api/src/libs/credit-grant.ts +146 -0
- package/api/src/libs/env.ts +1 -0
- package/api/src/libs/invoice.ts +4 -3
- package/api/src/libs/notification/template/base.ts +388 -2
- package/api/src/libs/notification/template/customer-credit-grant-granted.ts +149 -0
- package/api/src/libs/notification/template/customer-credit-grant-low-balance.ts +151 -0
- package/api/src/libs/notification/template/customer-credit-insufficient.ts +254 -0
- package/api/src/libs/notification/template/subscription-canceled.ts +193 -202
- package/api/src/libs/notification/template/subscription-refund-succeeded.ts +215 -237
- package/api/src/libs/notification/template/subscription-renewed.ts +130 -200
- package/api/src/libs/notification/template/subscription-succeeded.ts +100 -202
- package/api/src/libs/notification/template/subscription-trial-start.ts +142 -188
- package/api/src/libs/notification/template/subscription-trial-will-end.ts +146 -174
- package/api/src/libs/notification/template/subscription-upgraded.ts +96 -192
- package/api/src/libs/notification/template/subscription-will-canceled.ts +94 -135
- package/api/src/libs/notification/template/subscription-will-renew.ts +220 -245
- package/api/src/libs/payment.ts +69 -0
- package/api/src/libs/queue/index.ts +3 -2
- package/api/src/libs/session.ts +8 -0
- package/api/src/libs/subscription.ts +74 -3
- package/api/src/libs/util.ts +3 -1
- package/api/src/libs/ws.ts +23 -1
- package/api/src/locales/en.ts +33 -0
- package/api/src/locales/zh.ts +31 -0
- package/api/src/queues/credit-consume.ts +728 -0
- package/api/src/queues/credit-grant.ts +572 -0
- package/api/src/queues/notification.ts +173 -128
- package/api/src/queues/payment.ts +210 -122
- package/api/src/queues/subscription.ts +179 -0
- package/api/src/routes/checkout-sessions.ts +157 -9
- package/api/src/routes/connect/shared.ts +3 -2
- package/api/src/routes/credit-grants.ts +241 -0
- package/api/src/routes/credit-transactions.ts +208 -0
- package/api/src/routes/customers.ts +34 -5
- package/api/src/routes/index.ts +8 -0
- package/api/src/routes/meter-events.ts +347 -0
- package/api/src/routes/meters.ts +219 -0
- package/api/src/routes/payment-currencies.ts +20 -2
- package/api/src/routes/payment-links.ts +1 -1
- package/api/src/routes/payment-methods.ts +14 -2
- package/api/src/routes/prices.ts +43 -0
- package/api/src/routes/pricing-table.ts +13 -7
- package/api/src/routes/products.ts +63 -4
- package/api/src/routes/settings.ts +1 -1
- package/api/src/routes/subscriptions.ts +4 -0
- package/api/src/routes/webhook-endpoints.ts +0 -3
- package/api/src/store/migrations/20250610-billing-credit.ts +43 -0
- package/api/src/store/models/credit-grant.ts +486 -0
- package/api/src/store/models/credit-transaction.ts +268 -0
- package/api/src/store/models/customer.ts +8 -0
- package/api/src/store/models/index.ts +52 -1
- package/api/src/store/models/meter-event.ts +423 -0
- package/api/src/store/models/meter.ts +176 -0
- package/api/src/store/models/payment-currency.ts +66 -14
- package/api/src/store/models/price.ts +6 -0
- package/api/src/store/models/product.ts +2 -2
- package/api/src/store/models/subscription.ts +24 -0
- package/api/src/store/models/types.ts +28 -2
- package/api/tests/libs/subscription.spec.ts +53 -0
- package/blocklet.yml +9 -1
- package/package.json +4 -4
- package/scripts/sdk.js +233 -1
- package/src/app.tsx +10 -0
- package/src/components/collapse.tsx +11 -1
- package/src/components/conditional-section.tsx +87 -0
- package/src/components/customer/credit-grant-item-list.tsx +99 -0
- package/src/components/customer/credit-overview.tsx +246 -0
- package/src/components/customer/form.tsx +7 -3
- package/src/components/invoice/list.tsx +19 -1
- package/src/components/metadata/form.tsx +287 -91
- package/src/components/meter/actions.tsx +101 -0
- package/src/components/meter/add-usage-dialog.tsx +239 -0
- package/src/components/meter/events-list.tsx +657 -0
- package/src/components/meter/form.tsx +245 -0
- package/src/components/meter/products.tsx +264 -0
- package/src/components/meter/usage-guide.tsx +174 -0
- package/src/components/payment-currency/form.tsx +2 -0
- package/src/components/payment-intent/list.tsx +19 -1
- package/src/components/payment-link/item.tsx +2 -2
- package/src/components/payment-link/preview.tsx +1 -1
- package/src/components/payment-link/product-select.tsx +52 -12
- package/src/components/payment-method/arcblock.tsx +2 -0
- package/src/components/payment-method/base.tsx +2 -0
- package/src/components/payment-method/bitcoin.tsx +2 -0
- package/src/components/payment-method/ethereum.tsx +2 -0
- package/src/components/payment-method/stripe.tsx +2 -0
- package/src/components/payouts/list.tsx +19 -1
- package/src/components/payouts/portal/list.tsx +6 -11
- package/src/components/price/currency-select.tsx +56 -32
- package/src/components/price/form.tsx +912 -407
- package/src/components/pricing-table/preview.tsx +1 -1
- package/src/components/product/add-price.tsx +9 -7
- package/src/components/product/create.tsx +7 -4
- package/src/components/product/edit-price.tsx +21 -12
- package/src/components/product/features.tsx +17 -7
- package/src/components/product/form.tsx +100 -90
- package/src/components/refund/list.tsx +19 -1
- package/src/components/section/header.tsx +5 -18
- package/src/components/subscription/items/index.tsx +1 -1
- package/src/components/subscription/metrics.tsx +37 -5
- package/src/components/subscription/portal/actions.tsx +2 -1
- package/src/contexts/products.tsx +26 -9
- package/src/hooks/subscription.ts +34 -0
- package/src/libs/meter-utils.ts +196 -0
- package/src/libs/util.ts +4 -0
- package/src/locales/en.tsx +389 -5
- package/src/locales/zh.tsx +368 -1
- package/src/pages/admin/billing/index.tsx +61 -33
- package/src/pages/admin/billing/invoices/detail.tsx +1 -1
- package/src/pages/admin/billing/meters/create.tsx +60 -0
- package/src/pages/admin/billing/meters/detail.tsx +435 -0
- package/src/pages/admin/billing/meters/index.tsx +210 -0
- package/src/pages/admin/billing/meters/meter-event.tsx +346 -0
- package/src/pages/admin/billing/subscriptions/detail.tsx +47 -14
- package/src/pages/admin/customers/customers/credit-grant/detail.tsx +391 -0
- package/src/pages/admin/customers/customers/detail.tsx +14 -10
- package/src/pages/admin/customers/index.tsx +5 -0
- package/src/pages/admin/developers/events/detail.tsx +1 -1
- package/src/pages/admin/developers/index.tsx +1 -1
- package/src/pages/admin/payments/intents/detail.tsx +1 -1
- package/src/pages/admin/payments/payouts/detail.tsx +1 -1
- package/src/pages/admin/payments/refunds/detail.tsx +1 -1
- package/src/pages/admin/products/index.tsx +3 -2
- package/src/pages/admin/products/links/detail.tsx +1 -1
- package/src/pages/admin/products/prices/actions.tsx +16 -4
- package/src/pages/admin/products/prices/detail.tsx +30 -3
- package/src/pages/admin/products/prices/list.tsx +8 -1
- package/src/pages/admin/products/pricing-tables/detail.tsx +1 -1
- package/src/pages/admin/products/products/create.tsx +233 -57
- package/src/pages/admin/products/products/detail.tsx +2 -1
- package/src/pages/admin/settings/payment-methods/index.tsx +3 -0
- package/src/pages/customer/credit-grant/detail.tsx +308 -0
- package/src/pages/customer/index.tsx +44 -9
- package/src/pages/customer/recharge/account.tsx +5 -5
- package/src/pages/customer/subscription/change-payment.tsx +4 -2
- package/src/pages/customer/subscription/detail.tsx +48 -14
- package/src/pages/customer/subscription/embed.tsx +1 -1
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/brace-style */
|
|
2
2
|
/* eslint-disable @typescript-eslint/indent */
|
|
3
|
-
import prettyMsI18n from 'pretty-ms-i18n';
|
|
4
|
-
|
|
5
|
-
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
6
3
|
import { translate } from '../../../locales';
|
|
7
|
-
import {
|
|
8
|
-
CheckoutSession,
|
|
9
|
-
Customer,
|
|
10
|
-
NFTMintChainType,
|
|
11
|
-
NftMintItem,
|
|
12
|
-
PaymentIntent,
|
|
13
|
-
PaymentMethod,
|
|
14
|
-
Subscription,
|
|
15
|
-
} from '../../../store/models';
|
|
4
|
+
import { PaymentIntent, NftMintItem } from '../../../store/models';
|
|
16
5
|
import { Invoice } from '../../../store/models/invoice';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { getCustomerSubscriptionPageUrl } from '../../subscription';
|
|
21
|
-
import { formatTime, getPrettyMsI18nLocale } from '../../time';
|
|
22
|
-
import { formatCurrencyInfo, getExplorerLink, getSubscriptionNotificationCustomActions } from '../../util';
|
|
23
|
-
import type { BaseEmailTemplate, BaseEmailTemplateType } from './base';
|
|
6
|
+
import { formatTime } from '../../time';
|
|
7
|
+
import { formatCurrencyInfo, getExplorerLink } from '../../util';
|
|
8
|
+
import { BaseSubscriptionEmailTemplate, BaseEmailTemplateType } from './base';
|
|
24
9
|
|
|
25
10
|
export interface SubscriptionUpgradedEmailTemplateOptions {
|
|
26
11
|
subscriptionId: string;
|
|
@@ -42,123 +27,98 @@ interface SubscriptionUpgradedEmailTemplateContext {
|
|
|
42
27
|
viewTxHashLink: string | undefined;
|
|
43
28
|
skipInvoice: boolean;
|
|
44
29
|
customActions: any[];
|
|
30
|
+
isCreditSubscription: boolean;
|
|
45
31
|
}
|
|
46
32
|
|
|
47
|
-
export class SubscriptionUpgradedEmailTemplate
|
|
33
|
+
export class SubscriptionUpgradedEmailTemplate extends BaseSubscriptionEmailTemplate<SubscriptionUpgradedEmailTemplateContext> {
|
|
48
34
|
options: SubscriptionUpgradedEmailTemplateOptions;
|
|
49
35
|
|
|
50
36
|
constructor(options: SubscriptionUpgradedEmailTemplateOptions) {
|
|
37
|
+
super();
|
|
51
38
|
this.options = options;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
async getContext(): Promise<SubscriptionUpgradedEmailTemplateContext> {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
// 获取基础订阅数据
|
|
43
|
+
const basicData = await this.getSubscriptionBasicData(this.options.subscriptionId);
|
|
44
|
+
const { subscription, userDid, locale, productName, paymentCurrency, isCreditSubscription } = basicData;
|
|
45
|
+
|
|
59
46
|
if (!subscription.isActive()) {
|
|
60
47
|
throw new Error(`Subscription not active: ${this.options.subscriptionId}`);
|
|
61
48
|
}
|
|
62
49
|
|
|
63
|
-
const customer = await Customer.findByPk(subscription.customer_id);
|
|
64
|
-
if (!customer) {
|
|
65
|
-
throw new Error(`Customer not found: ${subscription.customer_id}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
50
|
// invoice应该是最新的subscription_update invoice
|
|
69
51
|
const invoiceId = subscription.pending_update?.updates?.latest_invoice_id || subscription.latest_invoice_id;
|
|
70
52
|
const invoice = (await Invoice.findByPk(invoiceId)) as Invoice;
|
|
71
53
|
const skipInvoice = subscription.status === 'trialing' || invoice.billing_reason !== 'subscription_update';
|
|
72
54
|
const paymentIntent = await PaymentIntent.findByPk(invoice.payment_intent_id);
|
|
73
|
-
const paymentCurrency = (await PaymentCurrency.findOne({
|
|
74
|
-
where: {
|
|
75
|
-
id: subscription.currency_id,
|
|
76
|
-
},
|
|
77
|
-
})) as PaymentCurrency;
|
|
78
|
-
|
|
79
|
-
const checkoutSession = await CheckoutSession.findBySubscriptionId(subscription.id);
|
|
80
|
-
|
|
81
|
-
const userDid: string = customer.did;
|
|
82
|
-
const locale = await getUserLocale(userDid);
|
|
83
|
-
const productName = await getMainProductName(subscription.id);
|
|
84
|
-
const at: string = formatTime(subscription.created_at);
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
const currentPeriodEnd: string = formatTime(
|
|
94
|
-
skipInvoice ? subscription.current_period_end * 1000 : invoice.period_end * 1000
|
|
56
|
+
// 获取支付信息
|
|
57
|
+
const paymentInfoResult = await this.getPaymentInfo(
|
|
58
|
+
subscription,
|
|
59
|
+
paymentCurrency,
|
|
60
|
+
isCreditSubscription,
|
|
61
|
+
invoice?.id
|
|
95
62
|
);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
63
|
+
|
|
64
|
+
// 获取链接
|
|
65
|
+
const links = this.generateSubscriptionLinks(
|
|
66
|
+
subscription,
|
|
67
|
+
locale,
|
|
68
|
+
userDid,
|
|
69
|
+
'customer.subscription.upgraded',
|
|
70
|
+
invoice?.id,
|
|
71
|
+
isCreditSubscription
|
|
101
72
|
);
|
|
102
73
|
|
|
103
|
-
|
|
74
|
+
// 获取 NFT 信息
|
|
75
|
+
const nftInfo = await this.getNftMintInfo(subscription.id);
|
|
104
76
|
|
|
105
|
-
|
|
77
|
+
// 格式化支付信息
|
|
78
|
+
const formattedPaymentInfo = formatCurrencyInfo(
|
|
106
79
|
paymentIntent?.amount || invoice.amount_paid,
|
|
107
80
|
paymentCurrency,
|
|
108
|
-
paymentMethod
|
|
81
|
+
paymentInfoResult.paymentMethod
|
|
109
82
|
);
|
|
110
83
|
|
|
111
|
-
//
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
locale,
|
|
116
|
-
userDid,
|
|
117
|
-
});
|
|
118
|
-
const viewInvoiceLink = getCustomerInvoicePageUrl({
|
|
119
|
-
invoiceId: invoice.id,
|
|
120
|
-
userDid,
|
|
121
|
-
locale,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// @ts-expect-error
|
|
125
|
-
const txHash: string | undefined = paymentIntent?.payment_details?.[paymentMethod.type]?.tx_hash;
|
|
126
|
-
const viewTxHashLink: string | undefined =
|
|
127
|
-
txHash &&
|
|
128
|
-
getExplorerLink({
|
|
129
|
-
type: 'tx',
|
|
130
|
-
did: txHash,
|
|
131
|
-
chainHost,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const customActions = getSubscriptionNotificationCustomActions(
|
|
135
|
-
subscription,
|
|
136
|
-
'customer.subscription.upgraded',
|
|
84
|
+
// 格式化时间信息
|
|
85
|
+
const periodInfo = this.formatSubscriptionPeriod(
|
|
86
|
+
skipInvoice ? subscription.current_period_start : invoice.period_start,
|
|
87
|
+
skipInvoice ? subscription.current_period_end : invoice.period_end,
|
|
137
88
|
locale
|
|
138
89
|
);
|
|
139
90
|
|
|
91
|
+
// 获取交易哈希链接
|
|
92
|
+
const txHash: string | undefined = (paymentIntent?.payment_details as any)?.[
|
|
93
|
+
paymentInfoResult?.paymentMethod?.type as string
|
|
94
|
+
]?.tx_hash;
|
|
95
|
+
const chainHost: string | undefined = (paymentInfoResult?.paymentMethod?.settings as any)?.[
|
|
96
|
+
paymentInfoResult.paymentMethod?.type as string
|
|
97
|
+
]?.api_host;
|
|
98
|
+
const viewTxHashLink: string | undefined = txHash && getExplorerLink({ type: 'tx', did: txHash, chainHost });
|
|
99
|
+
|
|
140
100
|
return {
|
|
141
101
|
locale,
|
|
142
102
|
productName,
|
|
143
|
-
at,
|
|
144
|
-
|
|
103
|
+
at: formatTime(subscription.created_at),
|
|
145
104
|
userDid,
|
|
146
|
-
nftMintItem,
|
|
105
|
+
nftMintItem: nftInfo.nftMintItem,
|
|
147
106
|
chainHost,
|
|
148
|
-
paymentInfo,
|
|
149
|
-
currentPeriodStart,
|
|
150
|
-
currentPeriodEnd,
|
|
151
|
-
duration,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
viewInvoiceLink,
|
|
107
|
+
paymentInfo: formattedPaymentInfo,
|
|
108
|
+
currentPeriodStart: periodInfo.currentPeriodStart,
|
|
109
|
+
currentPeriodEnd: periodInfo.currentPeriodEnd,
|
|
110
|
+
duration: periodInfo.duration,
|
|
111
|
+
viewSubscriptionLink: links.viewSubscriptionLink,
|
|
112
|
+
viewInvoiceLink: links.viewInvoiceLink!,
|
|
155
113
|
viewTxHashLink,
|
|
156
114
|
skipInvoice,
|
|
157
|
-
customActions,
|
|
115
|
+
customActions: links.customActions,
|
|
116
|
+
isCreditSubscription,
|
|
158
117
|
};
|
|
159
118
|
}
|
|
160
119
|
|
|
161
120
|
async getTemplate(): Promise<BaseEmailTemplateType> {
|
|
121
|
+
const context = await this.getContext();
|
|
162
122
|
const {
|
|
163
123
|
locale,
|
|
164
124
|
productName,
|
|
@@ -175,116 +135,60 @@ export class SubscriptionUpgradedEmailTemplate implements BaseEmailTemplate<Subs
|
|
|
175
135
|
viewTxHashLink,
|
|
176
136
|
skipInvoice,
|
|
177
137
|
customActions,
|
|
178
|
-
|
|
138
|
+
isCreditSubscription,
|
|
139
|
+
} = context;
|
|
140
|
+
|
|
141
|
+
// 构建基础字段
|
|
142
|
+
const commonFields = this.buildCommonFields(userDid, productName, locale);
|
|
143
|
+
|
|
144
|
+
// 构建支付金额字段(跳过发票时不显示)
|
|
145
|
+
const paymentFields = skipInvoice || isCreditSubscription ? [] : this.buildPaymentField(paymentInfo, locale, false);
|
|
146
|
+
|
|
147
|
+
// 构建有效期字段
|
|
148
|
+
const periodFields = this.buildPeriodField(
|
|
149
|
+
currentPeriodStart,
|
|
150
|
+
currentPeriodEnd,
|
|
151
|
+
duration,
|
|
152
|
+
locale,
|
|
153
|
+
isCreditSubscription
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// 构建操作按钮
|
|
157
|
+
const baseActions = this.buildCommonActions(
|
|
158
|
+
viewSubscriptionLink,
|
|
159
|
+
skipInvoice ? undefined : viewInvoiceLink,
|
|
160
|
+
locale,
|
|
161
|
+
isCreditSubscription,
|
|
162
|
+
[]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const additionalActions = [
|
|
166
|
+
!skipInvoice &&
|
|
167
|
+
viewTxHashLink && {
|
|
168
|
+
name: translate('notification.common.viewTxHash', locale),
|
|
169
|
+
title: translate('notification.common.viewTxHash', locale),
|
|
170
|
+
link: viewTxHashLink,
|
|
171
|
+
},
|
|
172
|
+
...customActions,
|
|
173
|
+
];
|
|
179
174
|
|
|
180
175
|
const template: BaseEmailTemplateType = {
|
|
181
|
-
title:
|
|
182
|
-
|
|
183
|
-
})}`,
|
|
184
|
-
body: `${translate('notification.subscriptionUpgraded.body', locale, {
|
|
185
|
-
at,
|
|
186
|
-
productName,
|
|
187
|
-
})}`,
|
|
176
|
+
title: translate('notification.subscriptionUpgraded.title', locale, { productName }),
|
|
177
|
+
body: translate('notification.subscriptionUpgraded.body', locale, { at, productName }),
|
|
188
178
|
// @ts-expect-error
|
|
189
179
|
attachments: [
|
|
190
180
|
nftMintItem &&
|
|
191
181
|
chainHost && {
|
|
192
182
|
type: 'asset',
|
|
193
|
-
data: {
|
|
194
|
-
chainHost,
|
|
195
|
-
did: nftMintItem.address,
|
|
196
|
-
},
|
|
183
|
+
data: { chainHost, did: nftMintItem.address },
|
|
197
184
|
},
|
|
198
185
|
{
|
|
199
186
|
type: 'section',
|
|
200
|
-
fields: [
|
|
201
|
-
{
|
|
202
|
-
type: 'text',
|
|
203
|
-
data: {
|
|
204
|
-
type: 'plain',
|
|
205
|
-
color: '#9397A1',
|
|
206
|
-
text: translate('notification.common.account', locale),
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
type: 'text',
|
|
211
|
-
data: {
|
|
212
|
-
type: 'plain',
|
|
213
|
-
text: userDid,
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
type: 'text',
|
|
218
|
-
data: {
|
|
219
|
-
type: 'plain',
|
|
220
|
-
color: '#9397A1',
|
|
221
|
-
text: translate('notification.common.product', locale),
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
type: 'text',
|
|
226
|
-
data: {
|
|
227
|
-
type: 'plain',
|
|
228
|
-
text: productName,
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
...(skipInvoice
|
|
232
|
-
? []
|
|
233
|
-
: [
|
|
234
|
-
{
|
|
235
|
-
type: 'text',
|
|
236
|
-
data: {
|
|
237
|
-
type: 'plain',
|
|
238
|
-
color: '#9397A1',
|
|
239
|
-
text: translate('notification.common.paymentAmount', locale),
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
type: 'text',
|
|
244
|
-
data: {
|
|
245
|
-
type: 'plain',
|
|
246
|
-
text: paymentInfo,
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
]),
|
|
250
|
-
{
|
|
251
|
-
type: 'text',
|
|
252
|
-
data: {
|
|
253
|
-
type: 'plain',
|
|
254
|
-
color: '#9397A1',
|
|
255
|
-
text: translate('notification.common.validityPeriod', locale),
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
type: 'text',
|
|
260
|
-
data: {
|
|
261
|
-
type: 'plain',
|
|
262
|
-
text: `${currentPeriodStart} ~ ${currentPeriodEnd}(${duration})`,
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
].filter(Boolean),
|
|
187
|
+
fields: [...commonFields, ...paymentFields, ...periodFields].filter(Boolean),
|
|
266
188
|
},
|
|
267
189
|
].filter(Boolean),
|
|
268
190
|
// @ts-ignore
|
|
269
|
-
actions: [
|
|
270
|
-
{
|
|
271
|
-
name: translate('notification.common.viewSubscription', locale),
|
|
272
|
-
title: translate('notification.common.viewSubscription', locale),
|
|
273
|
-
link: viewSubscriptionLink,
|
|
274
|
-
},
|
|
275
|
-
!skipInvoice && {
|
|
276
|
-
name: translate('notification.common.viewInvoice', locale),
|
|
277
|
-
title: translate('notification.common.viewInvoice', locale),
|
|
278
|
-
link: viewInvoiceLink,
|
|
279
|
-
},
|
|
280
|
-
!skipInvoice &&
|
|
281
|
-
viewTxHashLink && {
|
|
282
|
-
name: translate('notification.common.viewTxHash', locale),
|
|
283
|
-
title: translate('notification.common.viewTxHash', locale),
|
|
284
|
-
link: viewTxHashLink,
|
|
285
|
-
},
|
|
286
|
-
...customActions,
|
|
287
|
-
].filter(Boolean),
|
|
191
|
+
actions: [...baseActions, ...additionalActions].filter(Boolean),
|
|
288
192
|
};
|
|
289
193
|
|
|
290
194
|
return template;
|