4

Paypal Listener Does Not Perform Database Transactions

 3 years ago
source link: https://www.codesd.com/item/paypal-listener-does-not-perform-database-transactions.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Paypal Listener Does Not Perform Database Transactions

advertisements

I have a PayPal listener that gets an HTTP POST request from PayPal (or the PayPal documentation seems to indicate that's what they send), the listener sends back the information for verification by PayPal, and then if the information is verified, it does database transactions. This is the normal PayPal IPN process and the verification part works fine.

One of the values in the POST array that I get from PayPal is something that I am passing through to keep track of the transaction number. So I make a call that looks like: (not actual code; I am fully aware of SQL injection)

UPDATE transactions SET status='paid' WHERE id=$_POST['invoice']

The problem: If I fake the input by pointing a form with some inputs to my listener everything works fine, but if I get a real POST array from PayPal the database doesn't run. I know the $_POST['invoice'] variable is set when I get the real PayPal data, I've tested that, and it has a valid value, like 84, so I don't know why my transaction doesn't execute. The lines above and below the transaction both execute.

Maybe I'll have to post my actual code, but is it possible that PHP could be configured in some way that it wouldn't run transactions when it gets a request from PayPal? Like I said, I think PayPal is sending an HTTP POST request so it should be indistinguishable from my fake form, but something is wrong.


Probably your form input looks different from the actual IPN.

PayPal's IPN's can contain arrays, which are not handled very well by php when reading from the $_POST variable. It's possible that this is tripping up your handler (In this case, you will need to read and manipulate the raw data) .

If possible try to read the raw incoming data and compare against your simulated data, as others have suggested.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK