payment-kit 1.13.86 → 1.13.88
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/.env +1 -0
- package/api/src/libs/invoice.ts +7 -2
- package/api/src/libs/notification/template/subscription-renew-failed.ts +1 -1
- package/api/src/queues/payment.ts +7 -0
- package/api/src/store/migrate.ts +10 -9
- package/api/src/store/models/subscription.ts +1 -5
- package/blocklet.yml +1 -1
- package/package.json +3 -3
package/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
COMPONENT_STORE_URL="https://test.store.blocklet.dev"
|
package/api/src/libs/invoice.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { component } from '@blocklet/sdk';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
2
3
|
|
|
3
|
-
export function getCustomerInvoicePageUrl(
|
|
4
|
-
|
|
4
|
+
export function getCustomerInvoicePageUrl(
|
|
5
|
+
invoiceId: string,
|
|
6
|
+
locale: string = 'en',
|
|
7
|
+
action: LiteralUnion<'pay', string> = ''
|
|
8
|
+
) {
|
|
9
|
+
return component.getUrl(`customer/invoice/${invoiceId}?locale=${locale}&action=${action}`);
|
|
5
10
|
}
|
|
@@ -122,7 +122,7 @@ export class SubscriptionRenewFailedEmailTemplate
|
|
|
122
122
|
const chainHost: string | undefined =
|
|
123
123
|
paymentMethod?.settings?.[checkoutSession?.nft_mint_details?.type as 'arcblock' | 'ethereum']?.api_host;
|
|
124
124
|
const viewSubscriptionLink = getCustomerSubscriptionPageUrl(subscription.id, locale);
|
|
125
|
-
const viewInvoiceLink = getCustomerInvoicePageUrl(invoice.id, locale);
|
|
125
|
+
const viewInvoiceLink = getCustomerInvoicePageUrl(invoice.id, locale, 'pay');
|
|
126
126
|
const txHash: string | undefined =
|
|
127
127
|
paymentIntent?.payment_details?.[checkoutSession?.nft_mint_details?.type as 'arcblock' | 'ethereum']?.tx_hash;
|
|
128
128
|
const viewTxHashLink: string | undefined = hasNft && txHash ? getExplorerLink(chainHost, txHash, 'tx') : undefined;
|
|
@@ -61,6 +61,13 @@ export const handlePaymentSucceed = async (paymentIntent: PaymentIntent, invoice
|
|
|
61
61
|
if (subscription) {
|
|
62
62
|
if (subscription.status === 'incomplete') {
|
|
63
63
|
await subscription.update({ status: subscription.trail_end ? 'trialing' : 'active' });
|
|
64
|
+
|
|
65
|
+
if (subscription.trail_end) {
|
|
66
|
+
events.emit('customer.subscription.trial_start', subscription);
|
|
67
|
+
} else {
|
|
68
|
+
events.emit('customer.subscription.started', subscription);
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
logger.info(`Subscription ${subscription.id} updated on payment done ${invoice.id}`);
|
|
65
72
|
} else if (subscription.status === 'past_due') {
|
|
66
73
|
if (subscription.cancel_at_period_end && subscription.cancelation_details?.reason === 'payment_failed') {
|
package/api/src/store/migrate.ts
CHANGED
|
@@ -9,15 +9,16 @@ import { sequelize } from './sequelize';
|
|
|
9
9
|
const umzug = new Umzug({
|
|
10
10
|
migrations: {
|
|
11
11
|
glob: ['migrations/*.{ts,js}', { cwd: __dirname }],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
12
|
+
// @FIXME: @wangshijun jianchao这边的注释了才能 blocklet dev 成功
|
|
13
|
+
// resolve: ({ name, path, context }) => {
|
|
14
|
+
// // eslint-disable-next-line import/no-dynamic-require, global-require
|
|
15
|
+
// const migration = require(path!);
|
|
16
|
+
// return {
|
|
17
|
+
// name: name.replace(/\.ts$/, '.js'),
|
|
18
|
+
// up: () => migration.up({ context }),
|
|
19
|
+
// down: () => migration.down({ context }),
|
|
20
|
+
// };
|
|
21
|
+
// },
|
|
21
22
|
},
|
|
22
23
|
context: sequelize.getQueryInterface(),
|
|
23
24
|
storage: new SequelizeStorage({ sequelize }),
|
|
@@ -296,9 +296,7 @@ export class Subscription extends Model<InferAttributes<Subscription>, InferCrea
|
|
|
296
296
|
if (model.trail_start) {
|
|
297
297
|
const previousLatestInvoiceId = model.previous('latest_invoice_id');
|
|
298
298
|
|
|
299
|
-
if (
|
|
300
|
-
createEvent('Subscription', 'customer.subscription.trial_start', model, options).catch(console.error);
|
|
301
|
-
} else if (
|
|
299
|
+
if (
|
|
302
300
|
previousLatestInvoiceId &&
|
|
303
301
|
model.latest_invoice_id &&
|
|
304
302
|
previousLatestInvoiceId !== model.latest_invoice_id
|
|
@@ -313,8 +311,6 @@ export class Subscription extends Model<InferAttributes<Subscription>, InferCrea
|
|
|
313
311
|
createEvent('Subscription', 'customer.subscription.trial_end', model, options).catch(console.error);
|
|
314
312
|
}
|
|
315
313
|
}
|
|
316
|
-
} else if (!model.previous('latest_invoice_id') && model.latest_invoice_id) {
|
|
317
|
-
createEvent('Subscription', 'customer.subscription.started', model, options).catch(console.error);
|
|
318
314
|
}
|
|
319
315
|
|
|
320
316
|
createStatusEvent(
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.88",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@abtnode/types": "1.16.21-beta-e828f413",
|
|
111
111
|
"@arcblock/eslint-config": "^0.2.4",
|
|
112
112
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
113
|
-
"@did-pay/types": "1.13.
|
|
113
|
+
"@did-pay/types": "1.13.88",
|
|
114
114
|
"@types/cookie-parser": "^1.4.6",
|
|
115
115
|
"@types/cors": "^2.8.17",
|
|
116
116
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"parser": "typescript"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "1c1c92c77043c0c77f0cda969a299b31d06f70e5"
|
|
153
153
|
}
|