Skip to content

Commit 2a66684

Browse files
committed
routes created
1 parent 074161b commit 2a66684

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

payment gateway/config/paystack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { response } = require("express");
1+
const request=require('request');
22

33
const paystack=function(request){
44
const secretkey='sk_test_adf1b701bf31970a670478a66ca0b2902eb2cfd0';

payment gateway/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const mongoose=require('mongoose');
44
const url=require('./config/mongoose');
55
const pug=require('pug');
66
const path=require('path');
7+
const _=require('lodash');
8+
const donor=require('./models/model');
9+
const { request } = require('express');
10+
const {initializepayment, verifypayment}=require('./config/paystack')(request);
711

812
const app=express();
913

@@ -16,8 +20,28 @@ mongoose.Promise=global.Promise;
1620
mongoose.connect(url.url,{useNewUrlParser: true,useUnifiedTopology: true },function(err){
1721
if(err) console.log(err);
1822
console.log("database is connected");
23+
});
24+
25+
app.get('/',function(req,res){
26+
res.render('index.pug');
1927
})
2028

29+
app.post('/paystack/pay',function(req,res){
30+
const form=_.pick(req.body,['amount','email','name']);
31+
form.metadata={
32+
name : form.name
33+
}
34+
form.amount*=100;
35+
initializepayment(form,(error,body)=>{
36+
if(error) {
37+
console.log(error);
38+
return;
39+
}
40+
response=JSON.parse(body);
41+
res.redirect(response.data.authorization_url);
42+
});
43+
});
44+
2145

2246
const port=process.env.PORT||3000;
2347
app.listen(port,()=>{

payment gateway/node_modules/lodash/package.json

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

payment gateway/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"body-parser": "^1.19.0",
1313
"express": "^4.17.1",
14+
"lodash": "^4.17.17",
1415
"mongoose": "^5.9.22",
1516
"nodemon": "^2.0.4",
1617
"pug": "^3.0.0",

0 commit comments

Comments
 (0)