payment-kit 1.21.10 → 1.21.12

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.
@@ -111,6 +111,14 @@ export async function handleSubscriptionEvent(event: TEventExpanded, _: Stripe)
111
111
  fields.push('trial_end');
112
112
  }
113
113
 
114
+ const isPaused = event.data.object.pause_collection && event.data.object.pause_collection.behavior === 'void';
115
+ const currentMethod = await PaymentMethod.findByPk(subscription.default_payment_method_id);
116
+ if (isPaused && currentMethod?.type !== 'stripe') {
117
+ logger.info('subscription paused on stripe event and payment method is not stripe, skip update', {
118
+ id: subscription.id,
119
+ });
120
+ return;
121
+ }
114
122
  await finalizeStripeSubscriptionUpdate({
115
123
  subscription,
116
124
  updates: pick(event.data.object, fields),
@@ -128,6 +136,11 @@ export async function handleSubscriptionEvent(event: TEventExpanded, _: Stripe)
128
136
  })),
129
137
  });
130
138
 
139
+ logger.info('subscription updated on stripe event', {
140
+ id: subscription.id,
141
+ updates: pick(event.data.object, fields),
142
+ });
143
+
131
144
  return;
132
145
  }
133
146
 
@@ -1,5 +1,5 @@
1
1
  import type { CallbackArgs } from '../../libs/auth';
2
- import { type TLineItemExpanded } from '../../store/models';
2
+ import { PaymentMethod, type TLineItemExpanded } from '../../store/models';
3
3
  import { ensureReStakeContext, executeOcapTransactions, getAuthPrincipalClaim, getStakeTxClaim } from './shared';
4
4
  import { ensureStakeInvoice } from '../../libs/invoice';
5
5
  import logger from '../../libs/logger';
@@ -81,6 +81,16 @@ export default {
81
81
  customer!
82
82
  );
83
83
 
84
+ if (subscription.payment_details?.stripe?.subscription_id) {
85
+ const method = await PaymentMethod.findOne({ where: { type: 'stripe', livemode: subscription.livemode } });
86
+ if (method) {
87
+ const client = method.getStripeClient();
88
+ await client.subscriptions.update(subscription.payment_details.stripe.subscription_id, {
89
+ cancel_at_period_end: false,
90
+ cancel_at: null,
91
+ });
92
+ }
93
+ }
84
94
  await subscription.update({
85
95
  cancel_at_period_end: false,
86
96
  cancel_at: 0,
@@ -83,8 +83,8 @@ const authPortal = authenticate<Subscription>({
83
83
 
84
84
  const updateStripeSubscription = async (doc: Subscription, updates: any) => {
85
85
  if (doc.payment_details?.stripe?.subscription_id) {
86
- const method = await PaymentMethod.findByPk(doc.default_payment_method_id);
87
- if (method && method.type === 'stripe') {
86
+ const method = await PaymentMethod.findOne({ where: { type: 'stripe', livemode: doc.livemode } });
87
+ if (method) {
88
88
  const client = method.getStripeClient();
89
89
  await client.subscriptions.update(doc.payment_details.stripe.subscription_id, updates);
90
90
  }
@@ -533,14 +533,19 @@ router.put('/:id/recover', authPortal, async (req, res) => {
533
533
  }
534
534
  }
535
535
 
536
- if (doc.cancel_at_period_end) {
537
- await updateStripeSubscription(doc, { cancel_at_period_end: false });
538
- } else {
539
- await updateStripeSubscription(doc, { cancel_at: null });
540
- }
536
+ const updates: any = {
537
+ cancel_at_period_end: false,
538
+ cancel_at: 0,
539
+ };
540
+
541
+ await updateStripeSubscription(doc, { ...updates, cancellation_details: null });
541
542
 
542
543
  // @ts-ignore
543
- await doc.update({ cancel_at_period_end: false, cancel_at: 0, canceled_at: 0, cancelation_details: null });
544
+ await doc.update({
545
+ ...updates,
546
+ cancelation_details: null,
547
+ canceled_at: 0,
548
+ });
544
549
  await new SubscriptionWillCanceledSchedule().deleteScheduleSubscriptionJobs([doc]);
545
550
  // reschedule jobs
546
551
  subscriptionQueue
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.21.10
17
+ version: 1.21.12
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.21.10",
3
+ "version": "1.21.12",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
@@ -44,7 +44,7 @@
44
44
  ]
45
45
  },
46
46
  "dependencies": {
47
- "@abtnode/cron": "^1.16.52",
47
+ "@abtnode/cron": "^1.16.53-beta-20251011-054719-4ed2f6b7",
48
48
  "@arcblock/did": "^1.25.6",
49
49
  "@arcblock/did-connect-react": "^3.1.46",
50
50
  "@arcblock/did-connect-storage-nedb": "^1.8.0",
@@ -54,15 +54,15 @@
54
54
  "@arcblock/validator": "^1.25.6",
55
55
  "@blocklet/did-space-js": "^1.1.32",
56
56
  "@blocklet/error": "^0.2.5",
57
- "@blocklet/js-sdk": "^1.16.52",
58
- "@blocklet/logger": "^1.16.52",
59
- "@blocklet/payment-broker-client": "1.21.10",
60
- "@blocklet/payment-react": "1.21.10",
61
- "@blocklet/payment-vendor": "1.21.10",
62
- "@blocklet/sdk": "^1.16.52",
57
+ "@blocklet/js-sdk": "^1.16.53-beta-20251011-054719-4ed2f6b7",
58
+ "@blocklet/logger": "^1.16.53-beta-20251011-054719-4ed2f6b7",
59
+ "@blocklet/payment-broker-client": "1.21.12",
60
+ "@blocklet/payment-react": "1.21.12",
61
+ "@blocklet/payment-vendor": "1.21.12",
62
+ "@blocklet/sdk": "^1.16.53-beta-20251011-054719-4ed2f6b7",
63
63
  "@blocklet/ui-react": "^3.1.46",
64
- "@blocklet/uploader": "^0.2.13",
65
- "@blocklet/xss": "^0.2.10",
64
+ "@blocklet/uploader": "^0.2.15",
65
+ "@blocklet/xss": "^0.2.12",
66
66
  "@mui/icons-material": "^7.1.2",
67
67
  "@mui/lab": "7.0.0-beta.14",
68
68
  "@mui/material": "^7.1.2",
@@ -126,9 +126,9 @@
126
126
  "web3": "^4.16.0"
127
127
  },
128
128
  "devDependencies": {
129
- "@abtnode/types": "^1.16.52",
129
+ "@abtnode/types": "^1.16.53-beta-20251011-054719-4ed2f6b7",
130
130
  "@arcblock/eslint-config-ts": "^0.3.3",
131
- "@blocklet/payment-types": "1.21.10",
131
+ "@blocklet/payment-types": "1.21.12",
132
132
  "@types/cookie-parser": "^1.4.9",
133
133
  "@types/cors": "^2.8.19",
134
134
  "@types/debug": "^4.1.12",
@@ -175,5 +175,5 @@
175
175
  "parser": "typescript"
176
176
  }
177
177
  },
178
- "gitHead": "a7288f2742e4bb2622505b79dd539616a6a59878"
178
+ "gitHead": "8968cff415ab6906675fae48ff7a939e9d03d2ad"
179
179
  }