PayPal IPN NodeJS production invalid, sandbox is valid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Our sandbox/testing environment is able to verify IPNs from paypal, they return 'VALID'. However, our production IPN validation, being the same as our sandbox validation just with the production URL to 'https://ipnpb.paypal.com/cgi-bin/webscr', always returns 'INVALID'.
The content of the IPN body is almost identical, just changing a few alphanumeric values and no new special characters. We also made sure the buttons on the front-end pointed to the right URLs/environment.
Is there something we are missing? We went through all the troubleshooting on PayPal developer's site, but we still cannot get an IPN to be valid.
Here is the code:
```
let postreq = 'cmd=_notify-validate'
// Iterate the original request payload object and prepend its keys and values to the post string
Object.keys(req.body).map((key) => {
postreq = `${postreq}&${key}=${req.body[key]}`
return key
})
const options = {
url: 'https://ipnpb.paypal.com/cgi-bin/webscr', // production
// url: 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr', // sandbox
method: 'POST',
headers: {
'Content-Length': postreq.length
},
encoding: 'utf-8',
body: postreq
}
// Request to paypal to verify authenticity of IPN request
request(options, (error, response, resBody) => {
if (error || response.statusCode !== 200) {
reject(new Error(error))
return
}
// Validate the response from PayPal and resolve / reject the promise.
if (resBody.substring(0, 😎 === 'VERIFIED') {
// resolve(true)
isValidIPN = true
console.log('PAYPAL IPN OBJECT: ', resBody)
} else if (resBody.substring(0, 7) === 'INVALID') {
console.log('IPN Message is invalid.')
console.log(resBody)
} else {
console.log('Unexpected response body.')
console.log('URB error: ', new Error(error))
}
// Do database actions
}
```

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- subscription_id has disappeared in REST APIs
- How to Setting up the PayPal Payflow Pro on Shopify in Sandbox & Production mode? in Payflow
- permission_denied response in call to patch order when paying by Card in Braintree Client-side Integration (JS, iOS, Android SDKs)
- Credentials from sandbox to live in NVP/SOAP APIs
- I get always the error: "invalid client_id or redirect_uri" from signin authorize endpoint. in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)