Skip to content

Instantly share code, notes, and snippets.

@ramisalem
Last active January 13, 2020 13:49
Show Gist options
  • Save ramisalem/2352965879bd0f0bab56aab821f8cefd to your computer and use it in GitHub Desktop.
Save ramisalem/2352965879bd0f0bab56aab821f8cefd to your computer and use it in GitHub Desktop.
Payfort APIs
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
app.post('/', (req, res) => {
console.log(req, 'body');
console.log(req.body.token_name);
try {
req.body.token_name ? res.status(200).send(req.body.token_name) : res.status(401).send("");
} catch (err) {
return res.status(422).send(" no body provided ");
}
});
app.post('/proceed', (req, res) => {
console.log(req.body.status , 'status ');
try {
res.status(200).send(req.body.status);
} catch (err) {
return res.status(422).send("no body provided");
}
});
app.listen(process.env.PORT || 3000, () => {
console.log('Listening on port 3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment