PayPal client for IPN (Instant Payment Notification) and PDT (Payment Data Transfer) notifications.
-
Get package:
npm i paypal-notifications -S
-
Import it in your code:
const Paypal = require('paypal-notifications')
TODO
- Go to Website Payment Preferences
- Set the Return URL
- Turn the Payment Data Transfer on
- Get the Identity Token
- Save
See the PayPal documentation for more details.
Make a client with the environment (true
for live, false
for sandbox) and your token.
const paypalToken = 'G-ddvHQfRB2wqzrHCgdkbx0uXEcgKTcWbG2GjlI581zbPbGxKekGXgyVwU0'
const paypalClient = new Paypal(false, paypalToken)
TODO
Use the pdt
method to retrive a transaction by its ID.
The callback receives an eventual error and, if all goes well, the whole transaction object.
paypalClient.pdt('EPC66XON1D4EE27M9', (err, tx) => {
if (err) throw err
console.log(tx['payer_email'])
})