Mobile Monay Payments Not Working


#1

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’ });

    }

   

}


#2

Hi there
Can you please confirm that your key and id are live ?


#3

Please make sure your Integration ID and key are correct.


#4

Yes they are live and well set because they are the same I am using for Billing and everything is working well on bill but as long as I use sendMobile function then it stops working.

Additionally I am using the official testing numbers provided on your platform


#5

If its JS you are using can you add the following line before getting keys from your env…

require(“dotenv”).config()

Ive encountered an issue where the keys are not picked.
Also make sure the .env file is in the root dir


#6

Ok thanks for the suggestions but I have set up everything and when I console.log the IDs and the key they are all coming out

Show quoted text


#7

Can you try use this

Its a Paynow Extension


#8

I have all these in my code and even if I log the keys and id everything coming out


#9

Its a different one, that package exports one method “pay” … you can check it out, you specify your keys in your .env using the specified env variable names and pass arguments to the pay method


#10

Thanks let me check it


#11

I have noticed where I the error was comings from… It was because when I created The keys I haven’t included ecocash and netone