Skip to content

Commit

Permalink
Add support to new date and discount attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivank committed Jul 12, 2017
1 parent a0fd40b commit 587c42d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]:enhancv/mongoose-subscriptions-braintree.git",
Expand All @@ -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"
}
Expand Down
7 changes: 7 additions & 0 deletions src/subscriptionProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/integrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ describe(
assert.deepEqual(subscription.discounts, [
{
processor: { state: "saved", id: "DiscountAmount" },
currentBillingCycle: 0,
numberOfBillingCycles: 1,
group: "General",
__t: "DiscountAmount",
Expand Down
8 changes: 8 additions & 0 deletions test/subscriptionProcessorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ describe(
__t: "DiscountAmount",
amount: 20,
numberOfBillingCycles: 2,
currentBillingCycle: 1,
name: "Test",
},
{
Expand All @@ -402,13 +403,15 @@ describe(
amount: 20,
coupon: "test",
numberOfBillingCycles: 1,
currentBillingCycle: 1,
name: "Test",
},
{
processor: { id: "DiscountPercent", state: "saved" },
__t: "DiscountAmount",
amount: "2.00",
numberOfBillingCycles: 1,
currentBillingCycle: 1,
},
];

Expand Down Expand Up @@ -445,6 +448,7 @@ describe(
__t: "DiscountAmount",
amount: 20,
numberOfBillingCycles: 2,
currentBillingCycle: 1,
name: "Test",
},
],
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 587c42d

Please sign in to comment.