Skip to content

Instantly share code, notes, and snippets.

@aswinzz
Created January 25, 2019 18:03
Show Gist options
  • Save aswinzz/d4d7ac9fd5ba7892d08054bdb621573d to your computer and use it in GitHub Desktop.
Save aswinzz/d4d7ac9fd5ba7892d08054bdb621573d to your computer and use it in GitHub Desktop.
server.post('/validate-order', async function (req, res) {
// console.log("Validate Order");
try{
var order;
console.log(req);
if(req.body.event) {
order = req.body.event.data.new;
} else {
order = req.body;
}
var result = await validateOrder(order);
res.json(result);
} catch(e) {
console.log(e);
res.status(500).json(e.toString());
}
})
server.post('/payment', async function (req, res) {
// console.log("Payment");
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
try {
if (req.method == "OPTIONS") {
res.json("");
return;
}
var paymentReq = req.body;
var result = await makePayment(paymentReq);
res.json(result);
} catch(e) {
console.log(e);
res.status(500).json(e.toString());
}
})
server.post('/restaurant-approval', async function (req, res) {
// console.log("Approval");
try {
var order;
if(req.body.event) {
order = req.body.event.data.new;
} else {
order = req.body;
}
var result = await restaurantApproval(order);
res.json(result);
} catch(e) {
console.log(e);
res.status(500).json(e.toString());
}
})
server.post('/agent-assignment', async function (req, res) {
// console.log("Agent Assignment");
try {
var order;
if(req.body.event) {
order = req.body.event.data.new;
} else {
order = req.body;
}
var result = await assignAgent(order);
res.json(result);
} catch(e) {
console.log(e);
res.status(500).json(e.toString());
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment