Last active
July 25, 2021 05:15
-
-
Save ghaffaru/7e2e1f20269a3bd468c43c9e3b52799e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios') | |
const Payment = require('../models/Payment'); | |
module.exports = | |
{ | |
payInitialize : function (req, res, email, localId) { | |
axios | |
.post( | |
"https://api.paystack.co/transaction/initialize", | |
{ | |
email: email, | |
amount: "1190", | |
currency: "GHS", | |
callback_url: "https://blustream.live/", | |
}, | |
{ | |
headers: { | |
Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`, | |
}, | |
} | |
) | |
.then((response3) => { | |
let payment = new Payment({ | |
eventKey: req.body.eventKey, | |
amount: 11.9, | |
userKey: localId, | |
reference: response3.data.data.reference, | |
}); | |
payment | |
.save() | |
.then(() => { | |
return res.status(200).json({ message: response3.data }); | |
}) | |
.catch((err3) => { | |
return res.status(500).json({ message: "Could not process payment" }); | |
}); | |
}) | |
.catch((err2) => { | |
console.log(err2); | |
return res.status(500).json({ message: "Could not process payment" }); | |
}); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment