payment-kit 1.13.310 → 1.14.1
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.
|
@@ -224,6 +224,14 @@ const handleSubscriptionWhenActive = async (subscription: Subscription) => {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
// change to active if still in trialing
|
|
228
|
+
if (subscription.status === 'trialing') {
|
|
229
|
+
const now = dayjs().unix();
|
|
230
|
+
if (subscription.trial_end && subscription.trial_end <= now) {
|
|
231
|
+
await subscription.update({ status: 'active' });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
227
235
|
const invoice = await handleSubscriptionInvoice({
|
|
228
236
|
subscription,
|
|
229
237
|
filter: () => true, // include all items
|
|
@@ -1008,12 +1008,14 @@ router.put('/:id', authPortal, async (req, res) => {
|
|
|
1008
1008
|
await subscription.update(updates);
|
|
1009
1009
|
} else {
|
|
1010
1010
|
const now = dayjs().unix();
|
|
1011
|
+
let jobRunAt = 0;
|
|
1011
1012
|
let shouldCycle = false;
|
|
1012
1013
|
let periodChanged = false;
|
|
1013
1014
|
if (value.trial_end && subscription.isActive()) {
|
|
1014
1015
|
if (value.trial_end === 'now') {
|
|
1015
1016
|
if (subscription.status === 'trialing') {
|
|
1016
1017
|
updates.trial_end = now;
|
|
1018
|
+
jobRunAt = now;
|
|
1017
1019
|
shouldCycle = true;
|
|
1018
1020
|
periodChanged = true;
|
|
1019
1021
|
} else {
|
|
@@ -1021,6 +1023,8 @@ router.put('/:id', authPortal, async (req, res) => {
|
|
|
1021
1023
|
}
|
|
1022
1024
|
} else if ((value.trial_end as number) > now) {
|
|
1023
1025
|
updates.trial_end = value.trial_end as number;
|
|
1026
|
+
jobRunAt = updates.trial_end;
|
|
1027
|
+
shouldCycle = true;
|
|
1024
1028
|
periodChanged = true;
|
|
1025
1029
|
} else {
|
|
1026
1030
|
throw new Error('trial_end must be a future timestamp');
|
|
@@ -1062,7 +1066,7 @@ router.put('/:id', authPortal, async (req, res) => {
|
|
|
1062
1066
|
});
|
|
1063
1067
|
}
|
|
1064
1068
|
if (shouldCycle) {
|
|
1065
|
-
await addSubscriptionJob(subscription, 'cycle', true,
|
|
1069
|
+
await addSubscriptionJob(subscription, 'cycle', true, jobRunAt);
|
|
1066
1070
|
logger.info('subscription job rescheduled on period end', { subscription: subscription.id });
|
|
1067
1071
|
}
|
|
1068
1072
|
}
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@arcblock/validator": "^1.18.124",
|
|
53
53
|
"@blocklet/js-sdk": "1.16.28",
|
|
54
54
|
"@blocklet/logger": "1.16.28",
|
|
55
|
-
"@blocklet/payment-react": "1.
|
|
55
|
+
"@blocklet/payment-react": "1.14.1",
|
|
56
56
|
"@blocklet/sdk": "1.16.28",
|
|
57
57
|
"@blocklet/ui-react": "^2.10.3",
|
|
58
58
|
"@blocklet/uploader": "^0.1.20",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"devDependencies": {
|
|
119
119
|
"@abtnode/types": "1.16.28",
|
|
120
120
|
"@arcblock/eslint-config-ts": "^0.3.2",
|
|
121
|
-
"@blocklet/payment-types": "1.
|
|
121
|
+
"@blocklet/payment-types": "1.14.1",
|
|
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": "cd7d7d1c330860cb03de37a6006f1985d8dcea58"
|
|
164
164
|
}
|