diff --git a/app/controllers/grant.controller.js b/app/controllers/grant.controller.js
index d5985b9..cc12c24 100644
--- a/app/controllers/grant.controller.js
+++ b/app/controllers/grant.controller.js
@@ -48,11 +48,32 @@ exports.createGrant = async (req, res, next) => {
}
);
+ await Promise.all(
+ await organizations.map(async org => {
+ let dbOrgs = await sequelize.query(
+ `
+ SELECT stripe_account_id,
+ ein,
+ charify_credit
+ FROM organizations
+ WHERE id = :org_id
+ `,
+ {
+ type: sequelize.QueryTypes.SELECT,
+ replacements: { org_id: org.id }
+ }
+ );
+
+ org.stripe_account_id = dbOrgs[0].stripe_account_id;
+ org.ein = dbOrgs[0].ein;
+ org.charify_credit = dbOrgs[0].ein;
+ })
+ );
+
// one time charge
const charge = await stripe.grantCharge({
grant,
stripeToken,
- stripeToken,
organizations,
monthly,
amount,
diff --git a/app/controllers/sendgrid.controller.js b/app/controllers/sendgrid.controller.js
index a39bc22..9946761 100644
--- a/app/controllers/sendgrid.controller.js
+++ b/app/controllers/sendgrid.controller.js
@@ -21,7 +21,7 @@ exports.paymentReceipt = async ({
charitiesHtml += `
| ${
charity.name
- } |
+ } (${charity.ein})
$${charity.finalAmountToOrg.toFixed(
2
)} |
@@ -32,7 +32,7 @@ exports.paymentReceipt = async ({
const msg = {
to: receiver.email,
- from: { email: 'no-reply@charify.com', name: 'Charify Payments' },
+ from: { email: 'no-reply@ucharify.com', name: 'UCharify Payments' },
template_id: 'd-569f804f5e7749cba66bac1994607280',
substitutionWrappers: ['{{', '}}'],
@@ -43,7 +43,7 @@ exports.paymentReceipt = async ({
total_amount,
transaction_fees: transaction_fees.toFixed(2),
date: currDate,
- subject: 'Your Charify Bundle Payment - Charify'
+ subject: 'Your UCharify Bundle Payment'
}
};
const sentRes = await sgMail.send(msg);
diff --git a/app/controllers/stripe.controller.js b/app/controllers/stripe.controller.js
index 4ed8378..36168a6 100644
--- a/app/controllers/stripe.controller.js
+++ b/app/controllers/stripe.controller.js
@@ -26,17 +26,22 @@ exports.grantCharge = async ({
amount: stripeAmount,
currency: 'usd',
source: stripeToken,
- description: `Charify Bundle ${grant.id}`,
- statement_descriptor: `Charify Bundle ${grant.id}`,
+ description: `UCharify Bundle ${grant.id}`,
+ statement_descriptor: `UCharify Bundle ${grant.id}`,
receipt_email: donors[0].email
});
+ // splitting the .30 cents per transaction to each org
+ let indivThirtyCentFee =
+ Math.round((0.3 / organizations.length) * 1e2) / 1e2;
+
let updatedOrgs = await Promise.all(
organizations.map(async org => {
const selectedOrgAmount = org.amount;
// this determines how much payment processing is covered
const stripeFee =
- Math.round((selectedOrgAmount * 0.029 + 0.3) * 1e2) / 1e2;
+ Math.round((selectedOrgAmount * 0.029 + indivThirtyCentFee) * 1e2) /
+ 1e2;
// this determines how much Charify takes from each donation
const applicationFee = 0;
//const applicationFee = Math.round(selectedOrgAmount * 0.025 * 1e2) / 1e2;
@@ -45,16 +50,6 @@ exports.grantCharge = async ({
let finalAmountToOrg = 0;
- let currOrg = await sequelize.query(
- `
- SELECT stripe_account_id, charify_credit FROM organizations
- WHERE id = :org_id`,
- {
- type: db.Sequelize.QueryTypes.SELECT,
- replacements: { org_id: org.id }
- }
- );
-
// IMPLEMENTATION FOR CHARIFY CREDIT
// if (currOrg[0].charify_credit) {
// let updated_amt = currOrg[0].charify_credit;
@@ -98,7 +93,7 @@ exports.grantCharge = async ({
amount: finalAmountToOrg * 100,
currency: 'usd',
source_transaction: charge.id,
- destination: currOrg[0].stripe_account_id
+ destination: org.stripe_account_id
});
return org;