fixing email template
This commit is contained in:
@@ -6,6 +6,7 @@ const sendgrid = require('./sendgrid.controller');
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
Grant,
|
Grant,
|
||||||
|
Donor,
|
||||||
Charge,
|
Charge,
|
||||||
Cause,
|
Cause,
|
||||||
Region,
|
Region,
|
||||||
@@ -82,11 +83,24 @@ exports.createGrant = async (req, res, next) => {
|
|||||||
{ transaction }
|
{ transaction }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const donors = await sequelize.query(
|
||||||
|
`
|
||||||
|
SELECT email, first_name, last_name
|
||||||
|
FROM donors
|
||||||
|
WHERE id = :donor_id
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
type: db.Sequelize.QueryTypes.SELECT,
|
||||||
|
replacements: { donor_id: user.id }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// send email
|
// send email
|
||||||
await sendgrid.paymentReceipt({
|
await sendgrid.paymentReceipt({
|
||||||
|
grant,
|
||||||
organizations,
|
organizations,
|
||||||
total_amount: actual_total,
|
total_amount: actual_total,
|
||||||
receiver: user.email
|
receiver: donors[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ sgMail.setApiKey(process.env.SENDGRID_KEY);
|
|||||||
|
|
||||||
const {} = db;
|
const {} = db;
|
||||||
|
|
||||||
exports.paymentReceipt = async ({ organizations, total_amount, receiver }) => {
|
exports.paymentReceipt = async ({
|
||||||
|
grant,
|
||||||
|
organizations,
|
||||||
|
total_amount,
|
||||||
|
receiver
|
||||||
|
}) => {
|
||||||
try {
|
try {
|
||||||
var charitiesHtml = '';
|
var charitiesHtml = '';
|
||||||
|
|
||||||
@@ -22,17 +27,18 @@ exports.paymentReceipt = async ({ organizations, total_amount, receiver }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const msg = {
|
const msg = {
|
||||||
to: receiver,
|
to: receiver.email,
|
||||||
from: { email: '[email protected]', name: 'Charify Payments' },
|
from: { email: '[email protected]', name: 'Charify Payments' },
|
||||||
template_id: 'd-569f804f5e7749cba66bac1994607280',
|
template_id: 'd-569f804f5e7749cba66bac1994607280',
|
||||||
|
|
||||||
substitutionWrappers: ['{{', '}}'],
|
substitutionWrappers: ['{{', '}}'],
|
||||||
dynamic_template_data: {
|
dynamic_template_data: {
|
||||||
donor_name: 'Arjun Patel',
|
donor_name: receiver.first_name,
|
||||||
|
bundle_id: grant.id,
|
||||||
charities_list: charitiesHtml,
|
charities_list: charitiesHtml,
|
||||||
total_amount,
|
total_amount,
|
||||||
date: 'April 1st, 2018',
|
date: grant.created_at,
|
||||||
subject: 'Your Charity Bundle Payment - Charify'
|
subject: 'Your Charify Bundle Payment - Charify'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const sentRes = await sgMail.send(msg);
|
const sentRes = await sgMail.send(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user