Skip to content

Instantly share code, notes, and snippets.

@dsternlicht
Created July 24, 2018 09:19
Show Gist options
  • Select an option

  • Save dsternlicht/d1d38e4804b2211df2b804d6154e91a7 to your computer and use it in GitHub Desktop.

Select an option

Save dsternlicht/d1d38e4804b2211df2b804d6154e91a7 to your computer and use it in GitHub Desktop.
Creating a PayPal IPN Endpoint With NodeJS - ipn.ctrl.js - With IPN message validation
class IPNController {
static async index(req, res) {
// Send 200 status back to PayPal
res.status(200).send('OK');
res.end();
const body = req.body || {};
// Validate IPN message with PayPal
try {
const isValidated = await PayPalService.validate(body);
if (!isValidated) {
console.error('Error validating IPN message.');
return;
}
// IPN Message is validated!
} catch(e) {
console.error(e);
}
}
}
export default IPNController;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment