backend-manager 2.5.85 → 2.5.87
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
|
@@ -99,8 +99,9 @@ Module.prototype.signUp = function (payload) {
|
|
|
99
99
|
result.referrerUid = payload.affiliate.referrer;
|
|
100
100
|
})
|
|
101
101
|
.catch((e) => {
|
|
102
|
-
payload.affiliate.referrer =
|
|
103
|
-
|
|
102
|
+
payload.affiliate.referrer = null;
|
|
103
|
+
|
|
104
|
+
assistant.error('Failed to update affiliate code', e)
|
|
104
105
|
})
|
|
105
106
|
|
|
106
107
|
// Merge the payload and the default user object
|
|
@@ -144,14 +145,15 @@ Module.prototype.signUp = function (payload) {
|
|
|
144
145
|
|
|
145
146
|
Module.prototype.updateReferral = function (payload) {
|
|
146
147
|
const self = this;
|
|
147
|
-
const result = {
|
|
148
|
-
count: 0,
|
|
149
|
-
updatedReferral: false,
|
|
150
|
-
referrerUid: undefined,
|
|
151
|
-
}
|
|
152
|
-
payload = payload || {};
|
|
153
148
|
|
|
154
149
|
return new Promise(function(resolve, reject) {
|
|
150
|
+
const result = {
|
|
151
|
+
count: 0,
|
|
152
|
+
updatedReferral: false,
|
|
153
|
+
referrerUid: undefined,
|
|
154
|
+
}
|
|
155
|
+
payload = payload || {};
|
|
156
|
+
|
|
155
157
|
self.libraries.admin.firestore().collection('users')
|
|
156
158
|
.where('affiliate.code', '==', payload.affiliateCode)
|
|
157
159
|
.get()
|
|
@@ -183,7 +185,8 @@ Module.prototype.updateReferral = function (payload) {
|
|
|
183
185
|
}
|
|
184
186
|
}, {merge: true})
|
|
185
187
|
.catch(e => {
|
|
186
|
-
|
|
188
|
+
self.assistant.error('Error updating referral', e);
|
|
189
|
+
|
|
187
190
|
error = e;
|
|
188
191
|
})
|
|
189
192
|
|
|
@@ -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
|
|
432
|
-
if (
|
|
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
|
|