backend-manager 3.2.68 → 3.2.69

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.2.68",
3
+ "version": "3.2.69",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -1,5 +1,6 @@
1
1
  const moment = require('moment');
2
2
  const { get } = require('lodash');
3
+ const { arrayify } = require('node-powertools');
3
4
 
4
5
  function SubscriptionResolver(Manager, profile, resource) {
5
6
  const self = this;
@@ -426,19 +427,19 @@ SubscriptionResolver.prototype.resolve_paypal = function (profile, resource, res
426
427
  }
427
428
 
428
429
  // Set completed
429
- if (!resource.plan) {
430
- resolved.payment.completed = !['CREATED', 'SAVED', 'APPROVED', 'VOIDED', 'PAYER_ACTION_REQUIRED'].includes(resource.status);
431
- } else {
430
+ if (resource.plan) {
432
431
  resolved.payment.completed = !['APPROVAL_PENDING', 'APPROVED'].includes(resource.status);
432
+ } else {
433
+ resolved.payment.completed = !['CREATED', 'SAVED', 'APPROVED', 'VOIDED', 'PAYER_ACTION_REQUIRED'].includes(resource.status);
433
434
  }
434
435
 
435
436
  // Check if refunded
436
- if (!resource.plan) {
437
- // resolved.payment.refunded = false; // @@@ TODO: check if this is correct
438
- } else {
439
- const transactions = get(resource, 'transactions', []);
437
+ if (resource.plan) {
438
+ const transactions = arrayify(get(resource, 'transactions', []));
440
439
 
441
440
  resolved.payment.refunded = transactions.some(t => t.status === 'REFUNDED');
441
+ } else {
442
+ // resolved.payment.refunded = false; // @@@ TODO: check if this is correct
442
443
  }
443
444
 
444
445
  return resolved;