backend-manager 2.5.121 → 2.5.123
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": "2.5.
|
|
3
|
+
"version": "2.5.123",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@google-cloud/storage": "^5.20.5",
|
|
33
33
|
"@sendgrid/mail": "^7.7.0",
|
|
34
34
|
"@sentry/node": "^6.19.7",
|
|
35
|
-
"backend-assistant": "^1.0.
|
|
35
|
+
"backend-assistant": "^1.0.11",
|
|
36
36
|
"busboy": "^1.6.0",
|
|
37
37
|
"chalk": "^4.1.2",
|
|
38
38
|
"cors": "^2.8.5",
|
|
@@ -44,6 +44,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
trial: {
|
|
47
|
+
claimed: false,
|
|
47
48
|
active: false,
|
|
48
49
|
daysLeft: 0,
|
|
49
50
|
}
|
|
@@ -209,6 +210,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
209
210
|
if (resolved.status === 'suspended') {
|
|
210
211
|
resolved.expires.timestamp = moment(0);
|
|
211
212
|
}
|
|
213
|
+
|
|
212
214
|
// console.log('----expires 4', resolved.resource.id, resolved.status, resolved.frequency, resolved.trial.active, resolved.expires.timestamp.toISOString ? resolved.expires.timestamp.toISOString() : resolved.expires.timestamp);
|
|
213
215
|
|
|
214
216
|
// Fix timestamps
|
|
@@ -234,7 +236,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
self.resolved = resolved;
|
|
237
|
-
// console.log('----expires
|
|
239
|
+
// console.log('----expires 6', resolved.resource.id, resolved.status, resolved.frequency, resolved.trial.active, resolved.expires.timestamp.toISOString ? resolved.expires.timestamp.toISOString() : resolved.expires.timestamp);
|
|
238
240
|
|
|
239
241
|
return resolved;
|
|
240
242
|
};
|
|
@@ -340,6 +342,7 @@ SubscriptionResolver.prototype.resolve_paypal = function (profile, resource, res
|
|
|
340
342
|
// Get trial
|
|
341
343
|
const trialTenure = get(resource, 'plan.billing_cycles', []).find((cycle) => cycle.tenure_type === 'TRIAL');
|
|
342
344
|
const regularTenure = get(resource, 'plan.billing_cycles', []).find((cycle) => cycle.tenure_type === 'REGULAR');
|
|
345
|
+
const trialClaimed = !!trialTenure && parseFloat(get(trialTenure, 'pricing_scheme.fixed_price.value', '0.00')) === 0;
|
|
343
346
|
|
|
344
347
|
// Resolve trial
|
|
345
348
|
/*
|
|
@@ -360,6 +363,7 @@ SubscriptionResolver.prototype.resolve_paypal = function (profile, resource, res
|
|
|
360
363
|
get(resource, 'billing_info.next_billing_time', 0)
|
|
361
364
|
)
|
|
362
365
|
}
|
|
366
|
+
resolved.trial.claimed = trialClaimed;
|
|
363
367
|
|
|
364
368
|
// Resolve frequency
|
|
365
369
|
const unit = get(regularTenure, 'frequency.interval_unit');
|
|
@@ -568,8 +572,11 @@ SubscriptionResolver.prototype.resolve_chargebee = function (profile, resource,
|
|
|
568
572
|
|
|
569
573
|
// Special chargebee reset lastPayment
|
|
570
574
|
// If trial is active OR if it was cancelled after the trial has ended
|
|
571
|
-
const
|
|
572
|
-
const
|
|
575
|
+
const trialStart = get(resource, 'trial_start', 0) * 1000;
|
|
576
|
+
const trialEnd = get(resource, 'trial_end', 0) * 1000;
|
|
577
|
+
const cancelledAt = get(resource, 'cancelled_at', 0) * 1000;
|
|
578
|
+
const trialDaysDifference = moment(trialEnd).diff(moment(trialStart), 'days');
|
|
579
|
+
const trialClaimed = !!trialStart && !!trialEnd && trialDaysDifference > 1;
|
|
573
580
|
if (
|
|
574
581
|
resolved.trial.active
|
|
575
582
|
|| (trialEnd > 0 && cancelledAt > 0 && cancelledAt === trialEnd)
|
|
@@ -577,8 +584,7 @@ SubscriptionResolver.prototype.resolve_chargebee = function (profile, resource,
|
|
|
577
584
|
resolved.lastPayment.amount = 0;
|
|
578
585
|
resolved.lastPayment.date.timestamp = moment(0);
|
|
579
586
|
}
|
|
580
|
-
|
|
581
|
-
// console.log('----expires 1', resolved.resource.id, resolved.status, resolved.frequency, resolved.trial.active, resolved.expires.timestamp.toISOString ? resolved.expires.timestamp.toISOString() : resolved.expires.timestamp);
|
|
587
|
+
resolved.trial.claimed = trialClaimed;
|
|
582
588
|
|
|
583
589
|
return resolved;
|
|
584
590
|
}
|
|
@@ -673,16 +679,21 @@ SubscriptionResolver.prototype.resolve_stripe = function (profile, resource, res
|
|
|
673
679
|
}
|
|
674
680
|
|
|
675
681
|
// Get trial
|
|
682
|
+
const trialStart = get(resource, 'trial_start', 0) * 1000;
|
|
683
|
+
const trialEnd = get(resource, 'trial_end', 0) * 1000;
|
|
684
|
+
const trialDaysDifference = moment(trialEnd).diff(moment(trialStart), 'days');
|
|
685
|
+
const trialClaimed = !!trialStart && !!trialEnd && trialDaysDifference > 1;
|
|
676
686
|
if (resource.status === 'trialing') {
|
|
677
687
|
resolved.trial.active = true;
|
|
678
688
|
|
|
679
689
|
// Set expiration
|
|
680
690
|
resolved.expires.timestamp = moment(
|
|
681
691
|
(
|
|
682
|
-
|
|
683
|
-
)
|
|
692
|
+
trialEnd
|
|
693
|
+
)
|
|
684
694
|
)
|
|
685
695
|
}
|
|
696
|
+
resolved.trial.claimed = trialClaimed;
|
|
686
697
|
|
|
687
698
|
// Resolve frequency
|
|
688
699
|
const unit = get(resource, 'plan.interval');
|
|
@@ -753,6 +764,7 @@ SubscriptionResolver.prototype.resolve_coinbase = function (profile, resource, r
|
|
|
753
764
|
if (true) {
|
|
754
765
|
resolved.trial.active = false;
|
|
755
766
|
}
|
|
767
|
+
resolved.trial.claimed = false;
|
|
756
768
|
|
|
757
769
|
// Resolve frequency
|
|
758
770
|
const unit = profile.details.planFrequency;
|