payment-kit 1.13.87 → 1.13.89

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 ADDED
@@ -0,0 +1 @@
1
+ COMPONENT_STORE_URL="https://test.store.blocklet.dev"
@@ -1,5 +1,10 @@
1
1
  import { component } from '@blocklet/sdk';
2
+ import type { LiteralUnion } from 'type-fest';
2
3
 
3
- export function getCustomerInvoicePageUrl(invoiceId: string, locale: string = 'en') {
4
- return component.getUrl(`customer/invoice/${invoiceId}?locale=${locale}`);
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') {
@@ -458,10 +458,6 @@ router.put('/:id', auth, async (req, res) => {
458
458
  updates.proration_behavior = req.body.proration_behavior;
459
459
  }
460
460
 
461
- const lastInvoice = await Invoice.findByPk(subscription.latest_invoice_id);
462
- if (!lastInvoice) {
463
- throw new Error('Subscription should have latest invoice');
464
- }
465
461
  const paymentCurrency = await PaymentCurrency.findByPk(subscription.currency_id);
466
462
  if (!paymentCurrency) {
467
463
  throw new Error('Subscription should have payment currency');
@@ -562,6 +558,11 @@ router.put('/:id', auth, async (req, res) => {
562
558
  // handle proration
563
559
  const prorationBehavior = updates.proration_behavior || subscription.proration_behavior || 'none';
564
560
  if (prorationBehavior === 'create_prorations') {
561
+ const lastInvoice = await Invoice.findByPk(subscription.latest_invoice_id);
562
+ if (!lastInvoice) {
563
+ throw new Error('Subscription should have latest invoice');
564
+ }
565
+
565
566
  // 0. get last invoice, and invoice items, filter invoice items that are in licensed recurring mode
566
567
  const invoiceItems = await InvoiceItem.findAll({ where: { invoice_id: lastInvoice.id } });
567
568
  const invoiceItemsExpanded = await Price.expand(invoiceItems.map((x) => x.toJSON()));
@@ -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
- resolve: ({ name, path, context }) => {
13
- // eslint-disable-next-line import/no-dynamic-require, global-require
14
- const migration = require(path!);
15
- return {
16
- name: name.replace(/\.ts$/, '.js'),
17
- up: () => migration.up({ context }),
18
- down: () => migration.down({ context }),
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 (!previousLatestInvoiceId && model.latest_invoice_id) {
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
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.13.87
17
+ version: 1.13.89
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.87",
3
+ "version": "1.13.89",
4
4
  "scripts": {
5
5
  "dev": "COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
6
6
  "eject": "vite eject",
@@ -42,27 +42,27 @@
42
42
  ]
43
43
  },
44
44
  "dependencies": {
45
- "@abtnode/cron": "1.16.21-beta-e828f413",
46
- "@arcblock/did": "^1.18.106",
45
+ "@abtnode/cron": "1.16.21",
46
+ "@arcblock/did": "^1.18.108",
47
47
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
48
- "@arcblock/did-connect": "^2.8.23",
49
- "@arcblock/did-util": "^1.18.106",
50
- "@arcblock/jwt": "^1.18.106",
51
- "@arcblock/ux": "^2.8.23",
52
- "@blocklet/logger": "1.16.21-beta-e828f413",
53
- "@blocklet/sdk": "1.16.21-beta-e828f413",
54
- "@blocklet/ui-react": "^2.8.23",
55
- "@blocklet/uploader": "^0.0.56",
48
+ "@arcblock/did-connect": "^2.9.6",
49
+ "@arcblock/did-util": "^1.18.108",
50
+ "@arcblock/jwt": "^1.18.108",
51
+ "@arcblock/ux": "^2.9.6",
52
+ "@blocklet/logger": "1.16.21",
53
+ "@blocklet/sdk": "1.16.21",
54
+ "@blocklet/ui-react": "^2.9.6",
55
+ "@blocklet/uploader": "^0.0.62",
56
56
  "@mui/icons-material": "^5.14.19",
57
57
  "@mui/lab": "^5.0.0-alpha.155",
58
58
  "@mui/material": "^5.14.20",
59
59
  "@mui/styles": "^5.14.20",
60
60
  "@mui/system": "^5.14.20",
61
- "@ocap/asset": "^1.18.106",
62
- "@ocap/client": "^1.18.106",
63
- "@ocap/mcrypto": "^1.18.106",
64
- "@ocap/util": "^1.18.106",
65
- "@ocap/wallet": "^1.18.106",
61
+ "@ocap/asset": "^1.18.108",
62
+ "@ocap/client": "^1.18.108",
63
+ "@ocap/mcrypto": "^1.18.108",
64
+ "@ocap/util": "^1.18.108",
65
+ "@ocap/wallet": "^1.18.108",
66
66
  "@stripe/react-stripe-js": "^2.4.0",
67
67
  "@stripe/stripe-js": "^2.2.0",
68
68
  "ahooks": "^3.7.8",
@@ -107,10 +107,10 @@
107
107
  "validator": "^13.11.0"
108
108
  },
109
109
  "devDependencies": {
110
- "@abtnode/types": "1.16.21-beta-e828f413",
110
+ "@abtnode/types": "1.16.21",
111
111
  "@arcblock/eslint-config": "^0.2.4",
112
112
  "@arcblock/eslint-config-ts": "^0.2.4",
113
- "@did-pay/types": "1.13.87",
113
+ "@did-pay/types": "1.13.89",
114
114
  "@types/cookie-parser": "^1.4.6",
115
115
  "@types/cors": "^2.8.17",
116
116
  "@types/dotenv-flow": "^3.3.3",
@@ -134,7 +134,7 @@
134
134
  "type-fest": "^4.8.3",
135
135
  "typescript": "^4.9.5",
136
136
  "vite": "^4.5.1",
137
- "vite-plugin-blocklet": "^0.6.16",
137
+ "vite-plugin-blocklet": "^0.7.2",
138
138
  "vite-plugin-node-polyfills": "^0.7.0",
139
139
  "vite-plugin-svgr": "^2.4.0",
140
140
  "zx": "^7.2.3"
@@ -149,5 +149,5 @@
149
149
  "parser": "typescript"
150
150
  }
151
151
  },
152
- "gitHead": "e56e774ed27b74caa9b6ecdc8e02d7e0cc8d7fce"
152
+ "gitHead": "309312b8ffce48cd121af0a5b75494a1ae5dada0"
153
153
  }