UNPKG

@lomray/microservice-payment-stripe

Version:

Stripe payment microservice based on NodeJS & inverted json.

23 lines (20 loc) 496 B
'use strict'; /** * Compose balance according currency */ const composeBalance = (balances) => { const totalBalances = { usd: 0, eur: 0, }; for (const balance of balances) { if (totalBalances.hasOwnProperty(balance.currency)) { totalBalances[balance.currency] += balance.amount; } else { totalBalances[balance.currency] = balance.amount; } } return totalBalances; }; module.exports = composeBalance;