payment-kit 1.19.0 → 1.19.1
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/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 +715 -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/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 +14 -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/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/customer/credit-grant-item-list.tsx +99 -0
- package/src/components/customer/credit-overview.tsx +233 -0
- package/src/components/customer/form.tsx +5 -2
- package/src/components/invoice/list.tsx +19 -1
- package/src/components/metadata/form.tsx +286 -90
- 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/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/price/currency-select.tsx +51 -31
- package/src/components/price/form.tsx +881 -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 +104 -89
- 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 +385 -4
- package/src/locales/zh.tsx +364 -0
- 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 +22 -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 +35 -2
- 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,27 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/brace-style */
|
|
2
2
|
/* eslint-disable @typescript-eslint/indent */
|
|
3
3
|
import { fromUnitToToken, toDid } from '@ocap/util';
|
|
4
|
-
import prettyMsI18n from 'pretty-ms-i18n';
|
|
5
4
|
import logger from '../../logger';
|
|
6
|
-
import { getUserLocale } from '../../../integrations/blocklet/notification';
|
|
7
5
|
import { translate } from '../../../locales';
|
|
8
|
-
import {
|
|
9
|
-
CheckoutSession,
|
|
10
|
-
Customer,
|
|
11
|
-
NFTMintChainType,
|
|
12
|
-
Invoice,
|
|
13
|
-
NftMintItem,
|
|
14
|
-
PaymentIntent,
|
|
15
|
-
PaymentMethod,
|
|
16
|
-
Subscription,
|
|
17
|
-
} from '../../../store/models';
|
|
6
|
+
import { CheckoutSession, NFTMintChainType, Invoice, NftMintItem, PaymentIntent } from '../../../store/models';
|
|
18
7
|
import { PaymentCurrency } from '../../../store/models/payment-currency';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { formatTime, getPrettyMsI18nLocale } from '../../time';
|
|
23
|
-
import { formatCurrencyInfo, getExplorerLink, getSubscriptionNotificationCustomActions } from '../../util';
|
|
24
|
-
import type { BaseEmailTemplate, BaseEmailTemplateType } from './base';
|
|
8
|
+
import { formatTime } from '../../time';
|
|
9
|
+
import { formatCurrencyInfo, getExplorerLink } from '../../util';
|
|
10
|
+
import { BaseSubscriptionEmailTemplate, BaseEmailTemplateType } from './base';
|
|
25
11
|
|
|
26
12
|
export interface SubscriptionRenewedEmailTemplateOptions {
|
|
27
13
|
subscriptionId: string;
|
|
@@ -32,133 +18,112 @@ interface SubscriptionRenewedEmailTemplateContext {
|
|
|
32
18
|
locale: string;
|
|
33
19
|
productName: string;
|
|
34
20
|
at: string;
|
|
35
|
-
|
|
36
21
|
nftMintItem: NftMintItem | undefined;
|
|
37
22
|
userDid: string;
|
|
38
23
|
paymentInfo: string;
|
|
39
|
-
/**
|
|
40
|
-
* @description 支付金额
|
|
41
|
-
* @type {number}
|
|
42
|
-
* @memberof SubscriptionRenewedEmailTemplateContext
|
|
43
|
-
*/
|
|
44
24
|
amountPaid: number;
|
|
45
25
|
currentPeriodStart: string;
|
|
46
26
|
currentPeriodEnd: string;
|
|
47
27
|
duration: string;
|
|
48
|
-
|
|
49
28
|
viewSubscriptionLink: string;
|
|
50
29
|
viewInvoiceLink: string;
|
|
51
30
|
viewTxHashLink: string | undefined;
|
|
52
31
|
invoice: Invoice;
|
|
53
32
|
customActions: any[];
|
|
33
|
+
isCreditSubscription: boolean;
|
|
54
34
|
}
|
|
55
35
|
|
|
56
|
-
export class SubscriptionRenewedEmailTemplate
|
|
36
|
+
export class SubscriptionRenewedEmailTemplate extends BaseSubscriptionEmailTemplate<SubscriptionRenewedEmailTemplateContext> {
|
|
57
37
|
options: SubscriptionRenewedEmailTemplateOptions;
|
|
58
38
|
|
|
59
39
|
constructor(options: SubscriptionRenewedEmailTemplateOptions) {
|
|
40
|
+
super();
|
|
60
41
|
this.options = options;
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
async getContext(): Promise<SubscriptionRenewedEmailTemplateContext> {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
// 获取基础订阅数据
|
|
46
|
+
const basicData = await this.getSubscriptionBasicData(this.options.subscriptionId);
|
|
47
|
+
const { subscription, userDid, locale, productName, isCreditSubscription } = basicData;
|
|
48
|
+
|
|
68
49
|
if (subscription.status !== 'active') {
|
|
69
50
|
throw new Error(`Subscription not active: ${this.options.subscriptionId}`);
|
|
70
51
|
}
|
|
71
52
|
|
|
72
|
-
|
|
73
|
-
if (!customer) {
|
|
74
|
-
throw new Error(`Customer not found: ${subscription.customer_id}`);
|
|
75
|
-
}
|
|
76
|
-
|
|
53
|
+
// 获取发票信息
|
|
77
54
|
const invoice = (
|
|
78
55
|
this.options.invoiceId
|
|
79
56
|
? await Invoice.findByPk(this.options.invoiceId)
|
|
80
57
|
: await Invoice.findByPk(subscription.latest_invoice_id)
|
|
81
58
|
) as Invoice;
|
|
82
59
|
|
|
83
|
-
const paymentIntent = await PaymentIntent.findByPk(invoice.payment_intent_id);
|
|
84
60
|
const paymentCurrency = (await PaymentCurrency.findOne({
|
|
85
|
-
where: {
|
|
86
|
-
id: invoice.currency_id,
|
|
87
|
-
},
|
|
61
|
+
where: { id: invoice.currency_id },
|
|
88
62
|
})) as PaymentCurrency;
|
|
89
63
|
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const hasNft: boolean = checkoutSession?.nft_mint_status === 'minted';
|
|
97
|
-
const nftMintItem: NftMintItem | undefined = hasNft
|
|
98
|
-
? checkoutSession?.nft_mint_details?.[checkoutSession?.nft_mint_details?.type as NFTMintChainType]
|
|
99
|
-
: undefined;
|
|
100
|
-
const amountPaid = +fromUnitToToken(invoice.total, paymentCurrency.decimal);
|
|
101
|
-
const currentPeriodStart: string = formatTime(invoice.period_start * 1000);
|
|
102
|
-
const currentPeriodEnd: string = formatTime(invoice.period_end * 1000);
|
|
103
|
-
const duration: string = prettyMsI18n(
|
|
104
|
-
new Date(currentPeriodEnd).getTime() - new Date(currentPeriodStart).getTime(),
|
|
105
|
-
{
|
|
106
|
-
locale: getPrettyMsI18nLocale(locale),
|
|
107
|
-
}
|
|
64
|
+
// 获取支付信息
|
|
65
|
+
const paymentInfoResult = await this.getPaymentInfo(
|
|
66
|
+
subscription,
|
|
67
|
+
paymentCurrency,
|
|
68
|
+
isCreditSubscription,
|
|
69
|
+
invoice?.id
|
|
108
70
|
);
|
|
109
71
|
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const chainHost: string | undefined =
|
|
114
|
-
paymentMethod?.settings?.[checkoutSession?.nft_mint_details?.type as NFTMintChainType]?.api_host;
|
|
115
|
-
const viewSubscriptionLink = getCustomerSubscriptionPageUrl({
|
|
116
|
-
subscriptionId: subscription.id,
|
|
72
|
+
// 获取链接
|
|
73
|
+
const links = this.generateSubscriptionLinks(
|
|
74
|
+
subscription,
|
|
117
75
|
locale,
|
|
118
76
|
userDid,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
77
|
+
'customer.subscription.renewed',
|
|
78
|
+
invoice?.id,
|
|
79
|
+
isCreditSubscription
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// 获取 NFT 信息
|
|
83
|
+
const nftInfo = await this.getNftMintInfo(subscription.id);
|
|
84
|
+
|
|
85
|
+
// 计算支付金额
|
|
86
|
+
const amountPaid = +fromUnitToToken(invoice.total, paymentCurrency.decimal);
|
|
87
|
+
const formattedPaymentInfo = formatCurrencyInfo(invoice.total, paymentCurrency, paymentInfoResult.paymentMethod);
|
|
88
|
+
|
|
89
|
+
// 格式化时间信息
|
|
90
|
+
const periodInfo = this.formatSubscriptionPeriod(invoice.period_start, invoice.period_end, locale);
|
|
91
|
+
|
|
92
|
+
// 获取交易哈希链接
|
|
93
|
+
const checkoutSession = await CheckoutSession.findBySubscriptionId(subscription.id);
|
|
94
|
+
const paymentIntent = await PaymentIntent.findByPk(invoice.payment_intent_id);
|
|
125
95
|
const txHash: string | undefined =
|
|
126
96
|
paymentIntent?.payment_details?.[checkoutSession?.nft_mint_details?.type as NFTMintChainType]?.tx_hash;
|
|
97
|
+
|
|
98
|
+
const chainHost: string | undefined =
|
|
99
|
+
paymentInfoResult.paymentMethod?.settings?.[checkoutSession?.nft_mint_details?.type as NFTMintChainType]
|
|
100
|
+
?.api_host;
|
|
101
|
+
|
|
127
102
|
const viewTxHashLink: string | undefined =
|
|
128
|
-
hasNft && txHash
|
|
129
|
-
|
|
130
|
-
type: 'tx',
|
|
131
|
-
did: txHash,
|
|
132
|
-
chainHost,
|
|
133
|
-
})
|
|
134
|
-
: undefined;
|
|
135
|
-
const customActions = getSubscriptionNotificationCustomActions(
|
|
136
|
-
subscription,
|
|
137
|
-
'customer.subscription.renewed',
|
|
138
|
-
locale
|
|
139
|
-
);
|
|
103
|
+
nftInfo.hasNft && txHash ? getExplorerLink({ type: 'tx', did: txHash, chainHost }) : undefined;
|
|
104
|
+
|
|
140
105
|
return {
|
|
141
106
|
locale,
|
|
142
107
|
productName,
|
|
143
|
-
at,
|
|
144
|
-
|
|
145
|
-
nftMintItem,
|
|
108
|
+
at: formatTime((invoice?.status_transitions?.paid_at ?? Math.floor(Date.now() / 1000)) * 1000),
|
|
109
|
+
nftMintItem: nftInfo.nftMintItem,
|
|
146
110
|
userDid,
|
|
147
|
-
paymentInfo,
|
|
111
|
+
paymentInfo: formattedPaymentInfo,
|
|
148
112
|
amountPaid,
|
|
149
|
-
currentPeriodStart,
|
|
150
|
-
currentPeriodEnd,
|
|
151
|
-
duration,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
viewInvoiceLink,
|
|
113
|
+
currentPeriodStart: periodInfo.currentPeriodStart,
|
|
114
|
+
currentPeriodEnd: periodInfo.currentPeriodEnd,
|
|
115
|
+
duration: periodInfo.duration,
|
|
116
|
+
viewSubscriptionLink: links.viewSubscriptionLink,
|
|
117
|
+
viewInvoiceLink: links.viewInvoiceLink!,
|
|
155
118
|
viewTxHashLink,
|
|
156
119
|
invoice,
|
|
157
|
-
customActions,
|
|
120
|
+
customActions: links.customActions,
|
|
121
|
+
isCreditSubscription,
|
|
158
122
|
};
|
|
159
123
|
}
|
|
160
124
|
|
|
161
125
|
async getTemplate(): Promise<BaseEmailTemplateType | null> {
|
|
126
|
+
const context = await this.getContext();
|
|
162
127
|
const {
|
|
163
128
|
locale,
|
|
164
129
|
productName,
|
|
@@ -175,126 +140,91 @@ export class SubscriptionRenewedEmailTemplate implements BaseEmailTemplate<Subsc
|
|
|
175
140
|
viewTxHashLink,
|
|
176
141
|
invoice,
|
|
177
142
|
customActions,
|
|
178
|
-
|
|
143
|
+
isCreditSubscription,
|
|
144
|
+
} = context;
|
|
179
145
|
|
|
180
146
|
if (invoice.total === '0') {
|
|
181
147
|
logger.info('Invoice amount is 0, skipping renewed notification');
|
|
182
148
|
return null;
|
|
183
149
|
}
|
|
150
|
+
|
|
151
|
+
// 构建基础字段
|
|
152
|
+
const commonFields = this.buildCommonFields(userDid, productName, locale);
|
|
153
|
+
|
|
154
|
+
// 构建支付金额字段(包含特殊处理)
|
|
155
|
+
const paymentFields = isCreditSubscription
|
|
156
|
+
? []
|
|
157
|
+
: [
|
|
158
|
+
{
|
|
159
|
+
type: 'text',
|
|
160
|
+
data: {
|
|
161
|
+
type: 'plain',
|
|
162
|
+
color: '#9397A1',
|
|
163
|
+
text: translate('notification.common.paymentAmount', locale),
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
type: 'text',
|
|
168
|
+
data: {
|
|
169
|
+
type: 'plain',
|
|
170
|
+
text: `${paymentInfo}${
|
|
171
|
+
amountPaid === 0 ? ` (${translate('notification.subscriptionRenewed.noExpenseIncurred', locale)})` : ''
|
|
172
|
+
}`,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
const periodFields = this.buildPeriodField(
|
|
178
|
+
currentPeriodStart,
|
|
179
|
+
currentPeriodEnd,
|
|
180
|
+
duration,
|
|
181
|
+
locale,
|
|
182
|
+
isCreditSubscription
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
// NFT 地址字段
|
|
186
|
+
const nftFields = nftMintItem
|
|
187
|
+
? [
|
|
188
|
+
{
|
|
189
|
+
type: 'text',
|
|
190
|
+
data: {
|
|
191
|
+
type: 'plain',
|
|
192
|
+
color: '#9397A1',
|
|
193
|
+
text: translate('notification.common.nftAddress', locale),
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: 'text',
|
|
198
|
+
data: {
|
|
199
|
+
type: 'plain',
|
|
200
|
+
text: toDid(nftMintItem.address),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
]
|
|
204
|
+
: [];
|
|
205
|
+
|
|
206
|
+
// 构建操作按钮
|
|
207
|
+
const actions = this.buildCommonActions(viewSubscriptionLink, viewInvoiceLink, locale, isCreditSubscription, [
|
|
208
|
+
viewTxHashLink && {
|
|
209
|
+
name: translate('notification.common.viewTxHash', locale),
|
|
210
|
+
title: translate('notification.common.viewTxHash', locale),
|
|
211
|
+
link: viewTxHashLink as string,
|
|
212
|
+
},
|
|
213
|
+
...customActions,
|
|
214
|
+
]);
|
|
215
|
+
|
|
184
216
|
const template: BaseEmailTemplateType = {
|
|
185
|
-
title:
|
|
186
|
-
|
|
187
|
-
})}`,
|
|
188
|
-
body: `${translate('notification.subscriptionRenewed.body', locale, {
|
|
189
|
-
at,
|
|
190
|
-
productName,
|
|
191
|
-
})}`,
|
|
217
|
+
title: translate('notification.subscriptionRenewed.title', locale, { productName }),
|
|
218
|
+
body: translate('notification.subscriptionRenewed.body', locale, { at, productName }),
|
|
192
219
|
// @ts-expect-error
|
|
193
220
|
attachments: [
|
|
194
221
|
{
|
|
195
222
|
type: 'section',
|
|
196
|
-
fields: [
|
|
197
|
-
{
|
|
198
|
-
type: 'text',
|
|
199
|
-
data: {
|
|
200
|
-
type: 'plain',
|
|
201
|
-
color: '#9397A1',
|
|
202
|
-
text: translate('notification.common.account', locale),
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
type: 'text',
|
|
207
|
-
data: {
|
|
208
|
-
type: 'plain',
|
|
209
|
-
text: userDid,
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
type: 'text',
|
|
214
|
-
data: {
|
|
215
|
-
type: 'plain',
|
|
216
|
-
color: '#9397A1',
|
|
217
|
-
text: translate('notification.common.product', locale),
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
type: 'text',
|
|
222
|
-
data: {
|
|
223
|
-
type: 'plain',
|
|
224
|
-
text: productName,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
type: 'text',
|
|
229
|
-
data: {
|
|
230
|
-
type: 'plain',
|
|
231
|
-
color: '#9397A1',
|
|
232
|
-
text: translate('notification.common.paymentAmount', locale),
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
type: 'text',
|
|
237
|
-
data: {
|
|
238
|
-
type: 'plain',
|
|
239
|
-
text: `${paymentInfo}${
|
|
240
|
-
amountPaid === 0
|
|
241
|
-
? ` (${translate('notification.subscriptionRenewed.noExpenseIncurred', locale)})`
|
|
242
|
-
: ''
|
|
243
|
-
}`,
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
type: 'text',
|
|
248
|
-
data: {
|
|
249
|
-
type: 'plain',
|
|
250
|
-
color: '#9397A1',
|
|
251
|
-
text: translate('notification.common.validityPeriod', locale),
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
type: 'text',
|
|
256
|
-
data: {
|
|
257
|
-
type: 'plain',
|
|
258
|
-
text: `${currentPeriodStart} ~ ${currentPeriodEnd}(${duration})`,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
nftMintItem && {
|
|
262
|
-
type: 'text',
|
|
263
|
-
data: {
|
|
264
|
-
type: 'plain',
|
|
265
|
-
color: '#9397A1',
|
|
266
|
-
text: translate('notification.common.nftAddress', locale),
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
nftMintItem && {
|
|
270
|
-
type: 'text',
|
|
271
|
-
data: {
|
|
272
|
-
type: 'plain',
|
|
273
|
-
text: toDid(nftMintItem.address),
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
].filter(Boolean),
|
|
223
|
+
fields: [...commonFields, ...paymentFields, ...periodFields, ...nftFields].filter(Boolean),
|
|
277
224
|
},
|
|
278
225
|
].filter(Boolean),
|
|
279
226
|
// @ts-ignore
|
|
280
|
-
actions:
|
|
281
|
-
{
|
|
282
|
-
name: translate('notification.common.viewSubscription', locale),
|
|
283
|
-
title: translate('notification.common.viewSubscription', locale),
|
|
284
|
-
link: viewSubscriptionLink,
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
name: translate('notification.common.viewInvoice', locale),
|
|
288
|
-
title: translate('notification.common.viewInvoice', locale),
|
|
289
|
-
link: viewInvoiceLink,
|
|
290
|
-
},
|
|
291
|
-
viewTxHashLink && {
|
|
292
|
-
name: translate('notification.common.viewTxHash', locale),
|
|
293
|
-
title: translate('notification.common.viewTxHash', locale),
|
|
294
|
-
link: viewTxHashLink as string,
|
|
295
|
-
},
|
|
296
|
-
...customActions,
|
|
297
|
-
].filter(Boolean),
|
|
227
|
+
actions: actions.filter(Boolean),
|
|
298
228
|
};
|
|
299
229
|
|
|
300
230
|
return template;
|