backend-manager 3.2.67 → 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
|
@@ -355,7 +355,8 @@ BackendAssistant.prototype.errorify = function (e, options) {
|
|
|
355
355
|
options = options || {};
|
|
356
356
|
|
|
357
357
|
// Code: default to 500, or else use the user's option
|
|
358
|
-
|
|
358
|
+
const isCodeSet = typeof options.code !== 'undefined';
|
|
359
|
+
options.code = !isCodeSet
|
|
359
360
|
? 500
|
|
360
361
|
: options.code;
|
|
361
362
|
|
|
@@ -385,7 +386,8 @@ BackendAssistant.prototype.errorify = function (e, options) {
|
|
|
385
386
|
: new Error(stringify(e));
|
|
386
387
|
|
|
387
388
|
// Fix code
|
|
388
|
-
options.code = newError.code || options.code;
|
|
389
|
+
// options.code = newError.code || options.code;
|
|
390
|
+
options.code = isCodeSet ? options.code : newError.code || options.code;
|
|
389
391
|
options.code = parseInt(options.code);
|
|
390
392
|
options.code = isBetween(options.code, 400, 599) ? options.code : 500;
|
|
391
393
|
|
|
@@ -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 (
|
|
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 (
|
|
437
|
-
|
|
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;
|