Created
July 24, 2018 09:19
-
-
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
This file contains hidden or 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
| 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