backend-manager 3.0.13 → 3.0.14
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
|
@@ -47,6 +47,9 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
47
47
|
claimed: false,
|
|
48
48
|
active: false,
|
|
49
49
|
daysLeft: 0,
|
|
50
|
+
},
|
|
51
|
+
details: {
|
|
52
|
+
message: '',
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -58,6 +61,8 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
58
61
|
profile.type = profile.type || null;
|
|
59
62
|
profile.details = profile.details || {};
|
|
60
63
|
profile.details.planFrequency = profile.details.planFrequency || null;
|
|
64
|
+
profile.authorization = profile.authorization || {};
|
|
65
|
+
profile.authorization.status = profile.authorization.status || 'pending';
|
|
61
66
|
|
|
62
67
|
// Set
|
|
63
68
|
options = options || {};
|
|
@@ -65,6 +70,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
65
70
|
options.resolveProcessor = typeof options.resolveProcessor === 'undefined' ? false : options.resolveProcessor;
|
|
66
71
|
options.resolveType = typeof options.resolveType === 'undefined' ? false : options.resolveType;
|
|
67
72
|
options.today = typeof options.today === 'undefined' ? moment() : moment(options.today);
|
|
73
|
+
options.message = typeof options.message === 'undefined' ? true : options.message;
|
|
68
74
|
|
|
69
75
|
// Set provider if not set
|
|
70
76
|
if (!profile.processor) {
|
|
@@ -199,11 +205,22 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
199
205
|
) {
|
|
200
206
|
resolved.expires.timestamp = moment(0);
|
|
201
207
|
// resolved.cancelled.timestamp = moment(0);
|
|
208
|
+
resolved.details.message = 'Most recent payment failed because there is no working payment method on file.'
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// If they are trialing and the authorization charge is failed, set to suspended
|
|
212
|
+
if (
|
|
213
|
+
resolved.trial.active
|
|
214
|
+
&& profile.authorization.status === 'failed'
|
|
215
|
+
) {
|
|
216
|
+
resolved.status = 'suspended';
|
|
217
|
+
resolved.details.message = 'Pre-payment authorization failed because there is no working payment method on file.'
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
// If they got a refund, set the expiration to 0
|
|
205
221
|
if (resolved.payment.refunded) {
|
|
206
222
|
resolved.expires.timestamp = moment(0);
|
|
223
|
+
resolved.details.message = 'Refund was issued so subscription is inactive.'
|
|
207
224
|
}
|
|
208
225
|
|
|
209
226
|
// If they are suspended, set the expiration to 0
|
|
@@ -235,6 +252,10 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
235
252
|
console.log('resolved', resolved);
|
|
236
253
|
}
|
|
237
254
|
|
|
255
|
+
if (!options.message) {
|
|
256
|
+
resolved.details.message = '[REDACTED]';
|
|
257
|
+
}
|
|
258
|
+
|
|
238
259
|
self.resolved = resolved;
|
|
239
260
|
// 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);
|
|
240
261
|
|