File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1165,11 +1165,12 @@ suggestMembers.schema = Joi.object().keys({
1165
1165
1166
1166
/**
1167
1167
* Calculates total amount
1168
- * @param {Object } body
1168
+ * @param {Object } amount
1169
1169
* @returns {int } totalAmount
1170
1170
*/
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 )
1173
1174
return { totalAmount } ;
1174
1175
}
1175
1176
@@ -1179,8 +1180,9 @@ suggestMembers.schema = Joi.object().keys({
1179
1180
* @returns {string } paymentIntentToken
1180
1181
*/
1181
1182
async function createPayment ( totalAmount ) {
1183
+ const dollarToCents = ( totalAmount * 100 ) ;
1182
1184
const paymentIntent = await stripe . paymentIntents . create ( {
1183
- amount : totalAmount ,
1185
+ amount : dollarToCents ,
1184
1186
currency : process . env . CURRENCY ,
1185
1187
} ) ;
1186
1188
return { paymentIntentToken : paymentIntent . client_secret } ;
You can’t perform that action at this time.
0 commit comments