backend-manager 3.0.8 → 3.0.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-manager",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"wonderful-log": "^1.0.5",
|
|
70
70
|
"yargs": "^17.7.2"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -171,7 +171,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
171
171
|
if (resolved.status === 'active') {
|
|
172
172
|
// Set days left
|
|
173
173
|
if (resolved.trial.active) {
|
|
174
|
-
resolved.trial.daysLeft = resolved.expires.timestamp.diff(options.today, 'days');
|
|
174
|
+
resolved.trial.daysLeft = Math.abs(resolved.expires.timestamp.diff(options.today, 'days'));
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
// Set expiration
|
|
@@ -368,11 +368,16 @@ SubscriptionResolver.prototype.resolve_paypal = function (profile, resource, res
|
|
|
368
368
|
I want to put the subscription in a suspended state if it's even one day past due
|
|
369
369
|
*/
|
|
370
370
|
const trialLength = get(trialTenure, 'frequency.interval_count', 0);
|
|
371
|
-
const daysSinceStart = moment(
|
|
371
|
+
const daysSinceStart = Math.abs(moment(options.today).diff(moment(resolved.start.timestamp), 'days'));
|
|
372
372
|
if (daysSinceStart > trialLength) {
|
|
373
373
|
resolved.status = 'suspended';
|
|
374
374
|
resolved.trial.active = false;
|
|
375
375
|
}
|
|
376
|
+
console.log('----resolved.resource.id', resolved.resource.id);
|
|
377
|
+
console.log('----resolved.start.timestamp', resolved.start.timestamp);
|
|
378
|
+
console.log('----options.today', options.today);
|
|
379
|
+
console.log('======daysSinceStart', daysSinceStart);
|
|
380
|
+
console.log('======trialLength', trialLength);
|
|
376
381
|
}
|
|
377
382
|
resolved.trial.claimed = trialClaimed;
|
|
378
383
|
|
|
@@ -586,7 +591,7 @@ SubscriptionResolver.prototype.resolve_chargebee = function (profile, resource,
|
|
|
586
591
|
const trialStart = get(resource, 'trial_start', 0) * 1000;
|
|
587
592
|
const trialEnd = get(resource, 'trial_end', 0) * 1000;
|
|
588
593
|
const cancelledAt = get(resource, 'cancelled_at', 0) * 1000;
|
|
589
|
-
const trialDaysDifference = moment(trialEnd).diff(moment(trialStart), 'days');
|
|
594
|
+
const trialDaysDifference = Math.abs(moment(trialEnd).diff(moment(trialStart), 'days'));
|
|
590
595
|
const trialClaimed = !!trialStart && !!trialEnd && trialDaysDifference > 1;
|
|
591
596
|
if (
|
|
592
597
|
resolved.trial.active
|
|
@@ -692,7 +697,7 @@ SubscriptionResolver.prototype.resolve_stripe = function (profile, resource, res
|
|
|
692
697
|
// Get trial
|
|
693
698
|
const trialStart = get(resource, 'trial_start', 0) * 1000;
|
|
694
699
|
const trialEnd = get(resource, 'trial_end', 0) * 1000;
|
|
695
|
-
const trialDaysDifference = moment(trialEnd).diff(moment(trialStart), 'days');
|
|
700
|
+
const trialDaysDifference = Math.abs(moment(trialEnd).diff(moment(trialStart), 'days'));
|
|
696
701
|
const trialClaimed = !!trialStart && !!trialEnd && trialDaysDifference > 1;
|
|
697
702
|
if (resource.status === 'trialing') {
|
|
698
703
|
resolved.trial.active = true;
|