backend-manager 2.5.85 → 2.5.86

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.85",
3
+ "version": "2.5.86",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -222,7 +222,16 @@ SubscriptionResolver.prototype.resolve = function (options) {
222
222
  (
223
223
  get(resource, 'current_term_start', 0)
224
224
  ) * 1000
225
- )
225
+ )
226
+ // if (resource.total_dues > 0) {
227
+ // resolved.expires.timestamp = moment(0);
228
+ // } else {
229
+ // resolved.expires.timestamp = moment(
230
+ // (
231
+ // get(resource, 'current_term_start', 0)
232
+ // ) * 1000
233
+ // )
234
+ // }
226
235
 
227
236
  // Set cancelled
228
237
  if (resolved.status === 'cancelled') {
@@ -311,6 +320,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
311
320
  }
312
321
 
313
322
  // Set last payment
323
+ // TODO: check if suspended payments are handled correctly when using resource.latest_invoice.amount_paid
314
324
  if (resource.latest_invoice) {
315
325
  resolved.lastPayment.amount = resource.latest_invoice.amount_paid / 100;
316
326
  resolved.lastPayment.date.timestamp = moment(
@@ -428,8 +438,11 @@ SubscriptionResolver.prototype.resolve = function (options) {
428
438
  }
429
439
  }
430
440
 
431
- // If there was NEVER any payment sent AND they are not trialing
432
- if (!resolved.payment.completed && !resolved.trial.active) {
441
+ // If they are not trialing AND there was NEVER any payment sent OR the last payment failed, then set the expiration to 0
442
+ if (
443
+ !resolved.trial.active
444
+ && (!resolved.payment.completed || resolved.lastPayment.amount === 0)
445
+ ) {
433
446
  resolved.expires.timestamp = moment(0);
434
447
  }
435
448