backend-manager 2.5.83 → 2.5.85
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
|
@@ -190,9 +190,19 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
190
190
|
} else if (profile.processor === 'chargebee') {
|
|
191
191
|
// Set status
|
|
192
192
|
// subscription: https://apidocs.chargebee.com/docs/api/subscriptions?prod_cat_ver=2#subscription_status
|
|
193
|
-
// future The subscription is scheduled to start at a future date.
|
|
193
|
+
// future The subscription is scheduled to start at a future date.
|
|
194
|
+
// in_trial The subscription is in trial.
|
|
195
|
+
// active The subscription is active and will be charged for automatically based on the items in it.
|
|
196
|
+
// non_renewing The subscription will be canceled at the end of the current term.
|
|
197
|
+
// paused The subscription is paused. The subscription will not renew while in this state.
|
|
198
|
+
// cancelled The subscription has been canceled and is no longer in service.
|
|
194
199
|
if (['in_trial', 'active'].includes(resource.status)) {
|
|
195
200
|
resolved.status = 'active';
|
|
201
|
+
|
|
202
|
+
// If there's a due invoice, it's suspended
|
|
203
|
+
if (resource.total_dues > 0) {
|
|
204
|
+
resolved.status = 'suspended';
|
|
205
|
+
}
|
|
196
206
|
} else if (['paused'].includes(resource.status)) {
|
|
197
207
|
resolved.status = 'suspended';
|
|
198
208
|
} else {
|
|
@@ -217,16 +227,21 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
217
227
|
// Set cancelled
|
|
218
228
|
if (resolved.status === 'cancelled') {
|
|
219
229
|
resolved.cancelled.timestamp = moment(
|
|
220
|
-
get(resource, 'cancelled_at', 0)
|
|
230
|
+
get(resource, 'cancelled_at', 0) * 1000
|
|
221
231
|
)
|
|
222
232
|
}
|
|
223
233
|
|
|
224
234
|
// Set last payment
|
|
225
|
-
if (resource.total_dues) {
|
|
226
|
-
resolved.lastPayment.amount =
|
|
235
|
+
if (resource.total_dues > 0) {
|
|
236
|
+
resolved.lastPayment.amount = 0;
|
|
227
237
|
resolved.lastPayment.date.timestamp = moment(
|
|
228
238
|
(resource.due_since || 0) * 1000
|
|
229
239
|
);
|
|
240
|
+
} else {
|
|
241
|
+
resolved.lastPayment.amount = resource.plan_amount / 100;
|
|
242
|
+
resolved.lastPayment.date.timestamp = moment(
|
|
243
|
+
(resource.current_term_start || 0) * 1000
|
|
244
|
+
);
|
|
230
245
|
}
|
|
231
246
|
|
|
232
247
|
// Get trial
|
|
@@ -291,7 +306,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
|
|
|
291
306
|
// Set cancelled
|
|
292
307
|
if (resolved.status === 'cancelled') {
|
|
293
308
|
resolved.cancelled.timestamp = moment(
|
|
294
|
-
get(resource, 'canceled_at', 0)
|
|
309
|
+
get(resource, 'canceled_at', 0) * 1000
|
|
295
310
|
)
|
|
296
311
|
}
|
|
297
312
|
|