I have created function to handle mobile money payments and it is failing to giving the error
An error occured while initiating transaction Error: Hashes do not match!
at Paynow.parse (C:\Users\LENOVO\Desktop\projects\school_manager\api\node_modules\paynow\dist\paynow.js:123:23)
at C:\Users\LENOVO\Desktop\projects\school_manager\api\node_modules\paynow\dist\paynow.js:104:26
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async exports.schoolFeesEcoCashPayment (C:\Users\LENOVO\Desktop\projects\school_manager\api\main.service\controllers\student.payments.js:185:26)
This is the code
exports.schoolFeesEcoCashPayment = async ( req, res ) => {
const { studentId, amount, phone, method } = req.body;
if (!studentId || !amount || !phone) {
return res.status(400).json({ error: ‘Student ID, amount, and phone number are required.’ });
}
try {
let paynow = new Paynow(process.env.PAYNOW_INTEGRATION_ID, process.env.PAYNOW_INTEGRATION_KEY );
const studentPayment = await StudentPayment.create( {…req.body, status : “transactionPending” } );
paynow.resultUrl = https://${req.get('host')}/v1/school/billing/paynow/callback?id=${studentPayment?.id}
;
paynow.returnUrl = ${req.get('origin')}/teacher-dashboard?id=${studentPayment?.id}
;
let payment = paynow.createPayment( Student Payment #${studentPayment?.id}
, process.env.AUTH_EMAIL );
payment.add(“School Fees”, amount );
const response = await paynow.sendMobile(payment, phone, method );
res.status(200).json(response?.success);
console.log(response)
} catch (error) {
console.log(error)
return res.status(500).json({ error: ‘Internal Server Error’ });
}
}