Created
November 26, 2018 08:17
-
-
Save dekzitfz/7b4c8923b510bd695ce8ce0ba65c659b to your computer and use it in GitHub Desktop.
This file contains 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 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