Files
digifiMicro-Loan/controller/verifyEmployer.js
T
CHIEFSOFT\ameye 0277c1a100 test transfer
2024-07-11 09:11:37 -04:00

73 lines
3.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import axios from "axios";
import dotenv from "dotenv"
import Bvn from "../model/bvnModel.js";
import nodemailer from "nodemailer";
//import nodemailer from "modemailer"
//const nodemailer = require("modemailer");
export const verifyEmployer = async (req, res)=>{
//const nodemailer = require("modemailer");
const employee_name = req.body.firstname + " " + req.body.lastname; // "EMPLOYEE NAME";
const signatory_name = req.body.signatory_name;
const approve_link = "https://digifi-employer.chiefsoft.net";
const approve_password = req.body.signatory_password; //"1234567890";
const application_uid = req.body.application_uid;
const signatory_email = req.body.signatory_email;
/*
$api_data["signatory_password"] = "1000011";
$api_data["signatory_email"] = "ameye+signatory@chiefsoft.com";
$api_data["signatory_name"] = "Signatory UBA";
$api_data["processing_bank_name"] = "Processing Bank"; req.body.processing_bank_name
$api_data["processing_bank_email"] = "processingbank@email.com"; req.body.processing_bank_email
*/
const mainHtml = signatory_name+ ",\n" +
"<br><br>\n" +
"\n" +
" We hope this email meets you well. " +
"This serves as an employers commitment to notify you that your staff (<b>"+employee_name+"</b>) who holds the position of software engineer in your organization took a loan facility from our bank and has prompted us to notify you so as to confirm his existence as a staff of your organization." +
" Please click on the link below to confirm this before we can approve his loan\n " +
"<br><br>\n" +
"***<a href='"+approve_link+"/"+application_uid+"'>Employer commitment link</a> (You are to login with this email address and default password "+approve_password+" )\n " +
"<br><br>\n" +
"If you have any questions or concerns with respect to this email, please contact our finance department at <b>"+req.body.processing_bank_email+"</b>.\n \n Kind Regards,<br><br>\n" +
"Finance team, <br> "+req.body.processing_bank_name+"<br>\n";
try {
console.log("verifyEmployer REQ-----------------------------------------");
console.log(req.body);
console.log("verifyEmployer REQ=========================================");
const transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
port: 587,
secure: false,
auth: {
user: "message@chiefsoft.com",
pass: "may12002!",
},
});
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// send mail with defined transport object
const info = await transporter.sendMail({
from: '"Support ChiefSoft 👻" <message@chiefsoft.com>', // sender address
to: signatory_email, // list of receivers
bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers
subject: "Verify Loan Application ✔", // Subject line
text: "Hello "+signatory_name+"?", // plain text body
html: mainHtml, // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <d786aa62-4e0a-070a-47ed-0b0666549519@ethereal.email>
}
main().catch(console.error);
return res.json({res : 'sent'});
}
catch(error){
res.status(500).json({error: "Internal Server error"});
}
}