payment-kit 1.13.82 → 1.13.83
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/api/src/routes/subscriptions.ts +13 -10
- package/blocklet.yml +1 -1
- package/package.json +3 -3
|
@@ -431,22 +431,26 @@ router.put('/:id', auth, async (req, res) => {
|
|
|
431
431
|
|
|
432
432
|
// handle updates
|
|
433
433
|
const updates: Partial<TSubscription> = {};
|
|
434
|
+
|
|
435
|
+
// only metadata can be updated when immutable
|
|
434
436
|
if (req.body.metadata) {
|
|
435
437
|
updates.metadata = formatMetadata(req.body.metadata);
|
|
436
438
|
}
|
|
437
439
|
if (subscription.isImmutable()) {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return res.json({ subscription });
|
|
441
|
-
}
|
|
442
|
-
return res.status(400).json({ error: 'Only metadata can be updated when subscription is immutable' });
|
|
443
|
-
}
|
|
444
|
-
if (subscription.isActive() === false) {
|
|
445
|
-
return res.status(400).json({ error: 'Subscription can only be updated when active' });
|
|
440
|
+
await subscription.update(updates);
|
|
441
|
+
return res.json(subscription);
|
|
446
442
|
}
|
|
443
|
+
|
|
444
|
+
// only metadata + description can be updated when not active
|
|
447
445
|
if (req.body.description) {
|
|
448
446
|
updates.description = req.body.description;
|
|
449
447
|
}
|
|
448
|
+
if (subscription.isActive() === false) {
|
|
449
|
+
await subscription.update(updates);
|
|
450
|
+
return res.json(subscription);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// other updates are allowed
|
|
450
454
|
if (req.body.payment_behavior) {
|
|
451
455
|
updates.payment_behavior = req.body.payment_behavior;
|
|
452
456
|
}
|
|
@@ -710,8 +714,7 @@ router.put('/:id', auth, async (req, res) => {
|
|
|
710
714
|
}
|
|
711
715
|
|
|
712
716
|
await subscription.update(updates);
|
|
713
|
-
|
|
714
|
-
return res.json({ subscription, invoice });
|
|
717
|
+
return res.json(subscription);
|
|
715
718
|
});
|
|
716
719
|
} catch (err) {
|
|
717
720
|
console.error(err);
|
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.83",
|
|
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.83",
|
|
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": "e6357508c38296224f7c493b6630a45fd359d6bc"
|
|
153
153
|
}
|