backend-manager 2.5.78 → 2.5.80

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": "2.5.78",
3
+ "version": "2.5.80",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -62,4 +62,4 @@
62
62
  "wonderful-fetch": "^0.0.17",
63
63
  "yargs": "^17.7.1"
64
64
  }
65
- }
65
+ }
@@ -194,11 +194,13 @@ SubscriptionResolver.prototype.resolve = function (options) {
194
194
  ) * 1000
195
195
  )
196
196
 
197
- // Set last payment @@@ TODO
198
- // if (resource.billing_info && resource.billing_info.last_payment) {
199
- // resolved.lastPayment.amount = parseFloat(resource.billing_info.last_payment.amount.value);
200
- // resolved.lastPayment.date.timestamp = moment(resource.billing_info.last_payment.time);
201
- // }
197
+ // Set last payment
198
+ if (resource.total_dues) {
199
+ resolved.lastPayment.amount = resource.total_dues / 100;
200
+ resolved.lastPayment.date.timestamp = moment(
201
+ (resource.due_since || 0) * 1000
202
+ );
203
+ }
202
204
 
203
205
  // Get trial
204
206
  if (resource.status === 'in_trial') {
@@ -317,11 +319,14 @@ SubscriptionResolver.prototype.resolve = function (options) {
317
319
  get(resource, 'created_at', 0)
318
320
  );
319
321
 
322
+ // Retrieve last payment
323
+ const lastPayment = resource.payments.find(p => p.status === 'CONFIRMED');
324
+
320
325
  // Set last payment
321
326
  if (lastPayment) {
322
327
  resolved.lastPayment.amount = parseFloat(lastPayment.value.local.amount);
323
328
  resolved.lastPayment.date.timestamp = moment(lastPayment.detected_at);
324
- }
329
+ }
325
330
 
326
331
  // Get trial
327
332
  if (true) {
@@ -337,7 +342,6 @@ SubscriptionResolver.prototype.resolve = function (options) {
337
342
  }
338
343
 
339
344
  // Set completed
340
- const lastPayment = resource.payments.find(p => p.status === 'CONFIRMED');
341
345
  if (true) {
342
346
  resolved.payment.completed = !!lastPayment;
343
347
  }