making stripe helper for creating grant a helper and transferring to specific connected accounts

This commit is contained in:
Arjun Patel
2019-04-13 14:43:50 -07:00
parent 7b38620605
commit 9ed96806fb
2 changed files with 45 additions and 35 deletions
+3 -6
View File
@@ -14,15 +14,13 @@ const {
Project,
sequelize
} = db;
// Create a grant for certain donor
exports.createGrant = async (req, res, next) => {
const user = req.user;
var { name, monthly, organizations, amount, stripeToken } = req.body;
const causes = organizations.map(org => org.primary_cause);
const regions = organizations.map(org => org.primary_region);
actual_total = Math.round(amount * 100) / 100;
if (!stripeToken) {
@@ -41,8 +39,8 @@ exports.createGrant = async (req, res, next) => {
name,
amount: actual_total,
monthly,
num_causes: causes.length,
num_regions: regions.length
num_causes: organizations.length,
num_regions: organizations.length
},
{
transaction
@@ -100,7 +98,6 @@ exports.createGrant = async (req, res, next) => {
});
} catch (error) {
if (error) await transaction.rollback();
console.log(error);
next(error);
}
};