payment-kit 1.13.273 → 1.13.274
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/README.md +10 -0
- package/api/src/libs/subscription.ts +3 -0
- package/api/src/queues/subscription.ts +10 -1
- package/api/src/routes/subscriptions.ts +1 -3
- package/blocklet.yml +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -19,3 +19,13 @@ The decentralized stripe for blocklet platform.
|
|
|
19
19
|
### Test Stripe
|
|
20
20
|
|
|
21
21
|
Invoices for subscriptions are not finalized automatically. You can use stripe postman collection to finalize it and then confirm the payment.
|
|
22
|
+
|
|
23
|
+
### Easter Eggs
|
|
24
|
+
|
|
25
|
+
None public environment variables used in the code, can change the behavior of the payment-kit.
|
|
26
|
+
|
|
27
|
+
- PAYMENT_CHANGE_LOCKED_PRICE: allow change locked price, must be set to "1" to work
|
|
28
|
+
- PAYMENT_RELOAD_SUBSCRIPTION_JOBS: reload subscription jobs on start, must be set to "1" to work
|
|
29
|
+
- PAYMENT_BILLING_THRESHOLD: global default billing threshold, must be a number
|
|
30
|
+
- PAYMENT_DAYS_UNTIL_DUE: global default days until due, must be a number
|
|
31
|
+
- PAYMENT_DAYS_UNTIL_CANCEL: global default days until cancel, must be a number
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
TLineItemExpanded,
|
|
22
22
|
UsageRecord,
|
|
23
23
|
} from '../store/models';
|
|
24
|
+
import { createEvent } from './audit';
|
|
24
25
|
import dayjs from './dayjs';
|
|
25
26
|
import env from './env';
|
|
26
27
|
import logger from './logger';
|
|
@@ -584,6 +585,8 @@ export async function finalizeStripeSubscriptionUpdate({
|
|
|
584
585
|
const releaseAt = subscription.current_period_end;
|
|
585
586
|
await Lock.acquire(`${subscription.id}-change-plan`, releaseAt);
|
|
586
587
|
logger.info('subscription plan change lock acquired on finalize', { subscription: subscription.id, releaseAt });
|
|
588
|
+
|
|
589
|
+
createEvent('Subscription', 'customer.subscription.upgraded', subscription).catch(console.error);
|
|
587
590
|
}
|
|
588
591
|
|
|
589
592
|
logger.info('subscription update finalized', { subscription: subscription.id, updates, items });
|
|
@@ -501,7 +501,7 @@ export const startSubscriptionQueue = async () => {
|
|
|
501
501
|
if (supportAutoCharge === false) {
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
|
-
await addSubscriptionJob(x, 'cycle');
|
|
504
|
+
await addSubscriptionJob(x, 'cycle', process.env.PAYMENT_RELOAD_SUBSCRIPTION_JOBS === '1');
|
|
505
505
|
});
|
|
506
506
|
|
|
507
507
|
await batchHandleStripeSubscriptions();
|
|
@@ -568,6 +568,15 @@ events.on('customer.subscription.deleted', (subscription: Subscription) => {
|
|
|
568
568
|
// FIXME: ensure invoices that are open or uncollectible are voided
|
|
569
569
|
});
|
|
570
570
|
|
|
571
|
+
events.on('customer.subscription.upgraded', async (subscription: Subscription) => {
|
|
572
|
+
await subscriptionQueue.delete(subscription.id);
|
|
573
|
+
await addSubscriptionJob(subscription, 'cancel', true, subscription.current_period_end);
|
|
574
|
+
logger.info('subscription cycle job rescheduled after upgrade', {
|
|
575
|
+
subscription: subscription.id,
|
|
576
|
+
runAt: subscription.current_period_end,
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
|
|
571
580
|
events.on('customer.stake.revoked', async ({ subscriptionId, tx }: { subscriptionId: string; tx: any }) => {
|
|
572
581
|
const subscription = await Subscription.findByPk(subscriptionId);
|
|
573
582
|
if (!subscription) {
|
|
@@ -994,9 +994,7 @@ router.put('/:id', authPortal, async (req, res) => {
|
|
|
994
994
|
}
|
|
995
995
|
if (shouldCycle) {
|
|
996
996
|
await addSubscriptionJob(subscription, 'cycle', true, now);
|
|
997
|
-
logger.info('subscription job rescheduled on period end', {
|
|
998
|
-
subscription: subscription.id,
|
|
999
|
-
});
|
|
997
|
+
logger.info('subscription job rescheduled on period end', { subscription: subscription.id });
|
|
1000
998
|
}
|
|
1001
999
|
}
|
|
1002
1000
|
}
|
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.274",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@arcblock/ux": "^2.9.90",
|
|
52
52
|
"@arcblock/validator": "^1.18.123",
|
|
53
53
|
"@blocklet/logger": "1.16.26",
|
|
54
|
-
"@blocklet/payment-react": "1.13.
|
|
54
|
+
"@blocklet/payment-react": "1.13.274",
|
|
55
55
|
"@blocklet/sdk": "1.16.26",
|
|
56
56
|
"@blocklet/ui-react": "^2.9.90",
|
|
57
57
|
"@blocklet/uploader": "^0.1.6",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@abtnode/types": "1.16.26",
|
|
118
118
|
"@arcblock/eslint-config-ts": "^0.3.0",
|
|
119
|
-
"@blocklet/payment-types": "1.13.
|
|
119
|
+
"@blocklet/payment-types": "1.13.274",
|
|
120
120
|
"@types/cookie-parser": "^1.4.7",
|
|
121
121
|
"@types/cors": "^2.8.17",
|
|
122
122
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -155,5 +155,5 @@
|
|
|
155
155
|
"parser": "typescript"
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
|
-
"gitHead": "
|
|
158
|
+
"gitHead": "e16c193a6fe497c78f6d1b1ccb7627e1ff0224f2"
|
|
159
159
|
}
|