diff --git a/package.json b/package.json index 45a3909..2355584 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mongoose-subscriptions-braintree", - "version": "1.4.4", + "version": "1.4.5", "description": "Braintree processor for mongoose-subscriptions", "main": "src/index.js", "repository": "git@github.com:enhancv/mongoose-subscriptions-braintree.git", @@ -24,7 +24,7 @@ "istanbul": "^0.4.5", "mocha": "^3.2.0", "mongoose": "^4.8", - "mongoose-subscriptions": "^1.8.5", + "mongoose-subscriptions": "^1.9.3", "prettier": "^1.4.4", "sinon": "^2.1.0" } diff --git a/src/subscriptionProcessor.js b/src/subscriptionProcessor.js index b0c40bc..be698f2 100644 --- a/src/subscriptionProcessor.js +++ b/src/subscriptionProcessor.js @@ -89,6 +89,7 @@ function fieldsDiscounts(originalDiscounts, resultDiscounts) { const mapped = original || newDiscount; mapped.processor = { id: discount.id, state: ProcessorItem.SAVED }; + mapped.currentBillingCycle = discount.currentBillingCycle; return mapped; }); @@ -119,6 +120,12 @@ function fields(customer, originalDiscounts, subscription) { subscription.paymentMethodToken, customer.paymentMethods ), + nextBillingDate: subscription.nextBillingDate, + failureCount: subscription.failureCount, + daysPastDue: subscription.daysPastDue, + billingPeriodEndDate: subscription.billingPeriodEndDate, + billingPeriodStartDate: subscription.billingPeriodStartDate, + billingDayOfMonth: subscription.billingDayOfMonth, }; return pickBy(identity, response); diff --git a/test/integrationTest.js b/test/integrationTest.js index 2d51630..c9edda0 100644 --- a/test/integrationTest.js +++ b/test/integrationTest.js @@ -312,6 +312,7 @@ describe( assert.deepEqual(subscription.discounts, [ { processor: { state: "saved", id: "DiscountAmount" }, + currentBillingCycle: 0, numberOfBillingCycles: 1, group: "General", __t: "DiscountAmount", diff --git a/test/subscriptionProcessorTest.js b/test/subscriptionProcessorTest.js index 5d46fa9..47b099e 100644 --- a/test/subscriptionProcessorTest.js +++ b/test/subscriptionProcessorTest.js @@ -394,6 +394,7 @@ describe( __t: "DiscountAmount", amount: 20, numberOfBillingCycles: 2, + currentBillingCycle: 1, name: "Test", }, { @@ -402,6 +403,7 @@ describe( amount: 20, coupon: "test", numberOfBillingCycles: 1, + currentBillingCycle: 1, name: "Test", }, { @@ -409,6 +411,7 @@ describe( __t: "DiscountAmount", amount: "2.00", numberOfBillingCycles: 1, + currentBillingCycle: 1, }, ]; @@ -445,6 +448,7 @@ describe( __t: "DiscountAmount", amount: 20, numberOfBillingCycles: 2, + currentBillingCycle: 1, name: "Test", }, ], @@ -473,6 +477,10 @@ describe( }, ], firstBillingDate: "2016-09-29", + nextBillingDate: "2016-10-29", + billingDayOfMonth: 29, + billingPeriodEndDate: "2016-10-28", + billingPeriodStartDate: "2016-09-29", }; assert.deepEqual(fields, expected); diff --git a/yarn.lock b/yarn.lock index 2d0665c..cf8fa87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -434,9 +434,9 @@ mongoose-originals@^1.3.1: dependencies: lodash "^4.17.4" -mongoose-subscriptions@^1.8.5: - version "1.8.5" - resolved "https://registry.yarnpkg.com/mongoose-subscriptions/-/mongoose-subscriptions-1.8.5.tgz#75a230de71de9451ed0048227286c30e384fd4ef" +mongoose-subscriptions@^1.9.3: + version "1.9.3" + resolved "https://registry.yarnpkg.com/mongoose-subscriptions/-/mongoose-subscriptions-1.9.3.tgz#b7abf09796f51d5369fec3f5d9a96af969ae9837" dependencies: addmonths "^0.2.0" mongoose-originals "^1.3.1"