It took me a little bit of frustrating time to figure this out yesterday, so I thought I'd post it in case other people ran into the same issue.

I set up PayPal Instant Payment Notification (IPN) and thoroughly tested it in the sandbox environment. Everything worked fine. However, when switching over to real PayPal, it stopped working and I couldn't figure out what was wrong with my code.

PayPal actually has IPN disabled by default while the Sandbox environment has IPN enabled by default. Be sure to change this setting in your profile.

Dani AI

Generated

Good catch, — and thanks for the follow-up, . After the obvious account-level checks are done, the next fastest way to get IPN working is a short, focused checklist that covers delivery, validation, and idempotency. The items below are practical steps that have fixed the same symptom for many live sites.

  • Check the IPN History in your PayPal account to see delivery status and to re-send messages PayPal attempted to deliver. This will show whether PayPal thinks your listener received the POST. (developer.paypal.com)
  • Make sure your listener immediately returns an HTTP 200 and then posts the exact raw message back to PayPal prefixed with cmd=_notify-validate (use the sandbox endpoint for testing and the live ipnpb endpoint in production). The verification round‑trip must use the original encoding and field order. (developer.paypal.com)

Quick validation example (replace [raw_post_data] with the raw body you receive):

curl -X POST "https://ipnpb.paypal.com/cgi-bin/webscr" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "cmd=_notify-validate&[raw_post_data]"

Beyond that, log the raw POST so you can replay it; verify PayPal returns VERIFIED before you act; then check payment_status == "Completed", receiver_email matches your account, mc_gross/mc_currency match the order, and filter out duplicate txn_id values before fulfilling anything. Also use the IPN Simulator for early testing (it adds test_ipn so you can distinguish test messages). (developer.paypal.com)

If starting new work today, consider using PayPal Webhooks (REST) for modern integrations — PayPal’s upgrade guidance points teams toward webhooks for new projects while keeping IPN supported for legacy flows. Also check common server issues: TLS/HTTPS cert validity, firewall blocking, and framework CSRF protections that can block raw POSTs. (developer.paypal.com)

Member Avatar for Member #949455

However, when switching over to real PayPal, it stopped working and I couldn't figure out what was wrong with my code.

When you switch over from demo Paypal to the real Paypal. There shouldn't be an issue.

When you submit the payment and it didn't go through.

It will tell you the message on the website and also it will email and tell you why it didn't go through.

You have to test the real Paypay before it's active.

You can cancel the real transaction in your PayPal account.

Since you got it working and everything is fine.

Thanks for sharing the IPN enable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.