payment-kit 1.15.14 → 1.15.15
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.
|
@@ -326,6 +326,9 @@ export async function forwardUsageRecordToStripe(
|
|
|
326
326
|
if (!method) {
|
|
327
327
|
return null;
|
|
328
328
|
}
|
|
329
|
+
if (method.type !== 'stripe') {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
329
332
|
|
|
330
333
|
const client = method.getStripeClient();
|
|
331
334
|
const result = await client.subscriptionItems.createUsageRecord(subscriptionItem.metadata.stripe_id, {
|
|
@@ -510,7 +510,7 @@ router.put('/:id/resume', auth, async (req, res) => {
|
|
|
510
510
|
if (!doc) {
|
|
511
511
|
return res.status(404).json({ error: 'Subscription not found' });
|
|
512
512
|
}
|
|
513
|
-
if (doc.status !== 'paused') {
|
|
513
|
+
if (doc.status !== 'paused' || doc.pause_collection === null) {
|
|
514
514
|
return res.status(400).json({ error: 'Subscription not paused' });
|
|
515
515
|
}
|
|
516
516
|
|
|
@@ -1486,22 +1486,6 @@ router.post('/:id/change-payment', authPortal, async (req, res) => {
|
|
|
1486
1486
|
});
|
|
1487
1487
|
}
|
|
1488
1488
|
} else {
|
|
1489
|
-
// changing from stripe to crypto: pause stripe subscription
|
|
1490
|
-
if (previousPaymentMethod!.type === 'stripe') {
|
|
1491
|
-
const client = await previousPaymentMethod?.getStripeClient();
|
|
1492
|
-
const stripeSubscriptionId = subscription.payment_details?.stripe?.subscription_id as string;
|
|
1493
|
-
const result = await client?.subscriptions.update(stripeSubscriptionId, {
|
|
1494
|
-
pause_collection: {
|
|
1495
|
-
behavior: 'void',
|
|
1496
|
-
},
|
|
1497
|
-
});
|
|
1498
|
-
logger.info('stripe subscription paused on payment change', {
|
|
1499
|
-
subscription: subscription.id,
|
|
1500
|
-
stripeSubscription: stripeSubscriptionId,
|
|
1501
|
-
result,
|
|
1502
|
-
});
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
1489
|
// changing from crypto to crypto: just update the subscription
|
|
1506
1490
|
delegation = await isDelegationSufficientForPayment({
|
|
1507
1491
|
paymentMethod,
|
|
@@ -1528,6 +1512,23 @@ router.post('/:id/change-payment', authPortal, async (req, res) => {
|
|
|
1528
1512
|
intent: setupIntent.id,
|
|
1529
1513
|
});
|
|
1530
1514
|
}
|
|
1515
|
+
|
|
1516
|
+
// NOTE: this should only happen when local subscription is updated
|
|
1517
|
+
// changing from stripe to crypto: pause stripe subscription
|
|
1518
|
+
if (previousPaymentMethod!.type === 'stripe') {
|
|
1519
|
+
const client = await previousPaymentMethod?.getStripeClient();
|
|
1520
|
+
const stripeSubscriptionId = subscription.payment_details?.stripe?.subscription_id as string;
|
|
1521
|
+
const result = await client?.subscriptions.update(stripeSubscriptionId, {
|
|
1522
|
+
pause_collection: {
|
|
1523
|
+
behavior: 'void',
|
|
1524
|
+
},
|
|
1525
|
+
});
|
|
1526
|
+
logger.info('stripe subscription paused on payment change', {
|
|
1527
|
+
subscription: subscription.id,
|
|
1528
|
+
stripeSubscription: stripeSubscriptionId,
|
|
1529
|
+
result,
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1531
1532
|
}
|
|
1532
1533
|
|
|
1533
1534
|
return res.json({
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.15",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@arcblock/validator": "^1.18.135",
|
|
53
53
|
"@blocklet/js-sdk": "^1.16.32",
|
|
54
54
|
"@blocklet/logger": "^1.16.32",
|
|
55
|
-
"@blocklet/payment-react": "1.15.
|
|
55
|
+
"@blocklet/payment-react": "1.15.15",
|
|
56
56
|
"@blocklet/sdk": "^1.16.32",
|
|
57
57
|
"@blocklet/ui-react": "^2.10.39",
|
|
58
58
|
"@blocklet/uploader": "^0.1.40",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"devDependencies": {
|
|
119
119
|
"@abtnode/types": "^1.16.32",
|
|
120
120
|
"@arcblock/eslint-config-ts": "^0.3.2",
|
|
121
|
-
"@blocklet/payment-types": "1.15.
|
|
121
|
+
"@blocklet/payment-types": "1.15.15",
|
|
122
122
|
"@types/cookie-parser": "^1.4.7",
|
|
123
123
|
"@types/cors": "^2.8.17",
|
|
124
124
|
"@types/debug": "^4.1.12",
|
|
@@ -160,5 +160,5 @@
|
|
|
160
160
|
"parser": "typescript"
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
|
-
"gitHead": "
|
|
163
|
+
"gitHead": "a4661fedeb5c77d1c89736f9030f89cb2fc03474"
|
|
164
164
|
}
|
|
@@ -110,7 +110,7 @@ function SubscriptionActionsInner({ data, variant, onChange }: Props) {
|
|
|
110
110
|
color: 'primary',
|
|
111
111
|
disabled: data.status === 'canceled',
|
|
112
112
|
},
|
|
113
|
-
data.status === 'paused' ? resume : pause,
|
|
113
|
+
data.status === 'paused' || data.pause_collection ? resume : pause,
|
|
114
114
|
{
|
|
115
115
|
label: t('admin.subscription.cancel.title'),
|
|
116
116
|
handler: () => setState({ action: 'cancel' }),
|