Skip to content

Commit d4eed9b

Browse files
authored
Merge pull request #462 from arpitchaudhari/roles-checkout
Updating deposit amount calculation logic
2 parents 41d3a6f + 619902e commit d4eed9b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/services/TeamService.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,11 +1165,12 @@ suggestMembers.schema = Joi.object().keys({
11651165

11661166
/**
11671167
* Calculates total amount
1168-
* @param {Object} body
1168+
* @param {Object} amount
11691169
* @returns {int} totalAmount
11701170
*/
1171-
async function calculateAmount(body) {
1172-
const totalAmount = body.numberOfResources * body.rates * body.durationWeeks;
1171+
async function calculateAmount(amount) {
1172+
let totalAmount = 0;
1173+
_.forEach(amount, amt => totalAmount += amt.numberOfResources * amt.rate * amt.durationWeeks)
11731174
return { totalAmount };
11741175
}
11751176

@@ -1179,8 +1180,9 @@ suggestMembers.schema = Joi.object().keys({
11791180
* @returns {string} paymentIntentToken
11801181
*/
11811182
async function createPayment(totalAmount) {
1183+
const dollarToCents = (totalAmount*100);
11821184
const paymentIntent = await stripe.paymentIntents.create({
1183-
amount: totalAmount,
1185+
amount: dollarToCents,
11841186
currency: process.env.CURRENCY,
11851187
});
11861188
return { paymentIntentToken: paymentIntent.client_secret };

0 commit comments

Comments
 (0)