Skip to content

Instantly share code, notes, and snippets.

@dekzitfz
Created November 26, 2018 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekzitfz/7b4c8923b510bd695ce8ce0ba65c659b to your computer and use it in GitHub Desktop.
Save dekzitfz/7b4c8923b510bd695ce8ce0ba65c659b to your computer and use it in GitHub Desktop.
const express = require('express');
const bodyParser = require('body-parser');
const app = express().use(bodyParser.json());
var request = require('request');
app.post('/paypal-webhooks', (req, res) => {
var summary = req.body.summary;
var fee = req.body.resource.transaction_fee.value;
var id = req.body.resource.parent_payment;
setTimeout(function() {
console.log('sum', summary);
request.get({
url: "https://maker.ifttt.com/trigger/payment/with/key/dEQXDEumxgdTwqQ_3E7yN_",
method: 'GET',
form: {
value1:summary,
value2:fee,
value3:id
},
}, function (error, response, body) {
if(response.statusCode==200){
//console.log(summary + ", with fee " +fee+". id: "+id);
res.sendStatus(200);
}else{
console.log(error);
res.sendStatus(500);
}
});
}, 2000);
});
app.listen(3000, () => console.log('webhook is listening'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment