payment-kit 1.21.11 → 1.21.13
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,18 @@ 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
|
+
});
|
|
91
|
+
await client.subscriptions.update(subscription.payment_details.stripe.subscription_id, {
|
|
92
|
+
cancel_at: null,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
84
96
|
await subscription.update({
|
|
85
97
|
cancel_at_period_end: false,
|
|
86
98
|
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.
|
|
87
|
-
if (method
|
|
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,20 @@ router.put('/:id/recover', authPortal, async (req, res) => {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
536
|
+
const updates: any = {
|
|
537
|
+
cancel_at_period_end: false,
|
|
538
|
+
cancel_at: 0,
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
await updateStripeSubscription(doc, { cancel_at_period_end: false });
|
|
542
|
+
await updateStripeSubscription(doc, { cancel_at: null });
|
|
541
543
|
|
|
542
544
|
// @ts-ignore
|
|
543
|
-
await doc.update({
|
|
545
|
+
await doc.update({
|
|
546
|
+
...updates,
|
|
547
|
+
cancelation_details: null,
|
|
548
|
+
canceled_at: 0,
|
|
549
|
+
});
|
|
544
550
|
await new SubscriptionWillCanceledSchedule().deleteScheduleSubscriptionJobs([doc]);
|
|
545
551
|
// reschedule jobs
|
|
546
552
|
subscriptionQueue
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.13",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@blocklet/error": "^0.2.5",
|
|
57
57
|
"@blocklet/js-sdk": "^1.16.53-beta-20251011-054719-4ed2f6b7",
|
|
58
58
|
"@blocklet/logger": "^1.16.53-beta-20251011-054719-4ed2f6b7",
|
|
59
|
-
"@blocklet/payment-broker-client": "1.21.
|
|
60
|
-
"@blocklet/payment-react": "1.21.
|
|
61
|
-
"@blocklet/payment-vendor": "1.21.
|
|
59
|
+
"@blocklet/payment-broker-client": "1.21.13",
|
|
60
|
+
"@blocklet/payment-react": "1.21.13",
|
|
61
|
+
"@blocklet/payment-vendor": "1.21.13",
|
|
62
62
|
"@blocklet/sdk": "^1.16.53-beta-20251011-054719-4ed2f6b7",
|
|
63
63
|
"@blocklet/ui-react": "^3.1.46",
|
|
64
64
|
"@blocklet/uploader": "^0.2.15",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"devDependencies": {
|
|
129
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.
|
|
131
|
+
"@blocklet/payment-types": "1.21.13",
|
|
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": "
|
|
178
|
+
"gitHead": "b101cbdeded522328ac7c5ccd2ba44930467fe25"
|
|
179
179
|
}
|