-
-
Save acquahsamuel/07ded1eff9abb0f5abe1908af22142e0 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