PayPal successful transactions not recorded in dashboard (sandbox) - php

I've just uploaded the PayPal APIs to test my scripts, and so far, they seem to be working properly (all in sandbox mode). Payments are processed, and the transaction details are returned, but for some reason, the transactions are not being recorded on the PayPal dashboard.
I tried the IPN simulator, using the sample script from GitHub, but keep getting this error:
IPN was not sent, and the handshake was not verified.
The script works; at the very least, it writes a log file when called from any browser. But not when called from PayPal's IPN simulator.
Could really use some pointers in the right direction. TIA.

If you are HERE, then yes you "should" see them, however that dashboard is not very reliable. This is why I asked for clarity on 'what' dashboard you're looking at and posted the URL of sandbox.paypal.com.
If you're able to ping your IPN listener but PayPal is uanble to, try defining and enabling the IPN URL in the sandbox account and see what happens. From there you'll notice an IPN history link where you can see the status of the IPN call from that transction. If it failed, it will give you the error and you can troubleshoot from there.
Hope this helps

Related

IPN response with 200 HTTP code but nothing in my database

I really need help because I don't know what to do at this point. I developed a website where the new user need to pay for sign up, I set the correct paypal form button and about the money everything works ok, the problem is that I can't update my database. I'm using these files (they are provided on gitHub and also in the official Paypal guide there's a link to them): "PaypalIPN.php" and "example_usage.php". I also added to my Ubuntu cloud server (where is my website) the cert/cacert.pem, I don't know if I had to do but in the first file seems to be required.
I tried to run a IPN simulator but it doesn't work, I looked for the same problem and I found that there may be a problem with the simulator, so I made some real transactions (I've read that live production test is run correctly with that code).
Therefore:
the transaction money is ok;
in the Instant payment notification history there are all test I made and in message ID I can read the correct data passed in the IPN message, the IPN type is "Transaction executed" and the response code is 200. I noticed that in "example_usage.php" the 200 response code was out of the if ($verified) so, just for my last test, I put that inside the if and yes, the response was again that;
I tried my code for update the mongodb database with fake data and obviously it works.
How is it possible? Please, help me and thank you.
Did you verify the correct URL is showing in the IPN History details? Sometimes people are using a button that uses notify_url to override the PayPal account setting, and then IPNs are working, but they're going to a different place than expected. So check that first.
If the IPN is indeed going to the URL you expect, and it's returning a 200 OK, that means it's receiving and completing the script successfully. If you aren't seeing the expected result in your database then you must have some sort of a logic problem with your code that needs to be addressed. You need to build in some trackers to log files or send yourself emails as it does each step of your script to see if that portion of code is actually getting hit like you think it is.
I put together this article for how to test PayPal IPN a while back that has proven helpful for many people. If you follow the steps there you should be able to track down the problem.

PayPal IPN simulator returning "INVALID" but I've followed the rules

So I have a PHP service that's only job is to accept PayPal IPN connections. I'm using PSR7 $request->getBody()->getContents() to get the following from PayPal IPN simulator request.
payment_type=echeck&payment_date=Tue%20Jun%2007%202016%2012%3A56%3A47%20GMT+0100%20%28BST%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&txn_type=web_accept&txn_id=787223012&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AfBnnvbsi0E9urbgYYn51fFWPj23
So when I post this back using Guzzle 6 POSTing to https://www.sandbox.paypal.com/cgi-bin/webscr using the following body.
cmd=_notify-validate&payment_type=echeck&payment_date=Tue%20Jun%2007%202016%2012%3A56%3A47%20GMT+0100%20%28BST%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&txn_type=web_accept&txn_id=787223012&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AfBnnvbsi0E9urbgYYn51fFWPj23
I get INVALID for a response. I don't know if it coming from a different IP address to the server that handles the SSL termination is the issue or if I'm just going mad.
I've ran a diff on PayPal's simulator request body to the body I send back without the cmd variable and there is no difference.
It would seem the new IPN Simulator interface is using javascript Dates in the payment_date field. If you set this manually to something like today it works OK. Whether this is an encoding/decoding issue on the IPN Simulator side, or in your IPN listener, I am not sure.
We have been using the IPN simulator for the last few days, and are getting intermittent INVALID messages returned on the validation request.
Waiting a few minutes, or just pressing the "Send IPN" message a few times seems to work.
We have seen a request return an INVALID, and moments later the same request returns VERIFIED. Quite annoying.
The PayPal transaction validation always returns INVALID if the IPN comes from the IPN simulator, but I found a workaround. If the IPN will come from a real transaction, it works fine. Here is how I did.
Go to PayPal Developer and Login
Create a sandbox account (if you already have a sandbox account, ignore these 2 steps)
Now go to https://www.sandbox.paypal.com and login
Then visit button management and create a button
Don't forget to set the IPN notification URL for your sandbox acccount
Now make a real tracaction from the button you created in the sandbox account
It works flawlessly
For the record, I have been having this issue with Paypals IPN Simulator, and found that the solution is typical of Paypal:
The Issue: A correctly formatted IPN test run on the Paypal IPN Simulator returns INVALID when all checks show it should be correct.
Solution:
1) The simulator ALWAYS runs on the "sandbox" environment. I was using it to check on a "LIVE" payment sites feedback and took hours to discover that your IPN needs to be set to sandbox mode. This is not mentioned on the Paypal Simulator and appears to be hardcoded and "assumed" by Paypal.
2) the Payment_Date field in the IPN Simulator is invalid and not accepted when returned to Paypal, so clear this field or set this field to null when submitting IPN Simulator runs.
3) Sometimes, strangely, Paypal IPN Simulator will tell you
IPN was not sent, and the handshake was not verified. Please review your information.
Even Though the simulated transaction is fully processed by my IPN listener script and returns VERIFIED. Always Check your own feedback script rather than the crap Paypal decides to tell you.
A combination of the above issues has lost several hours of my life. Stripe is far, far better to code with.

Paypal ION different servers

so I got a guy to code this IPN feature for my website.
Basically a user pays thought the main site then it forwards the ipn stuff to another server and that server sends ipn payment to paypal. For some reason it keeps saying "retrying" under the paypal IPN history. Is paypal blocking this and does the payment have to be made from the same server? Thanks hopefully this makes sense!
IPN does not happen until after any transaction has occurred, so what you're saying here doesn't really make sense. There's no way IPN would be sending any payment to PayPal. PayPal simply POSTs transaction data to your IPN URL after the transaction has taken place.
That said, if you're seeing "retrying" in your IPN History that means your IPN script is not completing successfully, and as such, is not returning a 200 result code back to PayPal's server. You need to troubleshoot your IPN script to figure out what's failing and get it fixed.
Your web server logs should provide the information you need. If you look there you should see a log of when your IPN URL was hit and it should also provide the result including any errors that were generated from the request to that script.
I like to create a simple HTML form with the action set to my IPN URL and then include hidden fields that match the fields/values that I would expect to get from IPN. This way you can load that in a browser and submit it directly so that you can see the result on screen which can help with troubleshooting and debugging.
Keep in mind that when testing that way, though, the data is not coming from PayPal's servers, so it will not verify. You'll need to make sure your script is setup to handle this accordingly for testing purposes.

paypal sandbox completed the payment successfully, but my script didn't receive the ipn post call

I am developing with paypal sandbox, all the payment flow can go successfully without any error. I set up 'notify_url' in my form and this url can be successfully tested by Instant Payment Notification (IPN) Simulator.
Paypal sandbox told me the payment completed successfully but my ipn handler could not receive any requests.
by the way I am using this ipn library: https://github.com/Quixotix/PHP-PayPal-IPN
Can you confirm your IPN History is / keeps blank?
For me, it seems like Paypal is having Problems with their Sandbox IPN again.
They had similar problems till about 2 weeks ago:
https://www.x.com/developers/paypal/forums/instant-payment-notifications-ipn-payment-data-transfer-pdt/ipn-failing-hasn-t-been-changed
I can confirm it was working again as the thread at x.com tells but for about 2 or 3 days (I guess) I do not get any IPN anymore although the payment itself is processed fine.
There is already a new thread at x.com that may cover our problem, but unfortunately there are no answers so far: https://www.x.com/developers/paypal/forums/instant-payment-notifications-ipn-payment-data-transfer-pdt/ipn-message-not-sent-url-mentioned-under-notify-_url-sandbox
Btw: I'm pretty sure this is not related to PHP or the library you use since I have the same problems using Ruby and the guy asking at x.com is using Java.

Test Paypal IPN in the Sandbox

I am writing a script to handle the paypal IPN, so when someone buys something via paypal it will send them an email and write some info into a database.
I am using the Instant Payment Notification simulator, and it is sending my email ok but i would like it to actually re-direct to my php page, so i can test my error checking etc. When you submit it does call the page but i would like to actually be re-directed to it.
Anyone know if this is possible, or if there is anything i can do to 'fake' this process
Cheers
Luke
Well, you can just test your IPN by using a temporary Payment Data Transfer page. Read this page for more information about this.
So basically after your payment has been done it redirects you to that success page and does everything. So you can use the success page as a test version of your future IPN page. After your script is working exactly the way you want, you can use the code on that page by simply copy-pasting it into your IPN page and deleting that test PDT page.
Another way is to catch the entire output of your IPN page and mail it to you. Or store it somewhere. To do this, make use of PHP's output buffering.
I hope that makes sense to you...
I usually use micahcarrick Paypal IPN class for Paypal IPN.In this class you can see
success case in switch case statement, There you can redirect to your success page.
Actually, Paypal IPN will return response to us. you can see the action parameter in return url. using this you can find is payment is success or cancel or any error during payment.
Hope it helps,Thanks
Paypal IPN messages are Server to Server Messages for asynchronously receiving messages from Paypal regarding transactions. The HTTP Client used by Paypal to deliver IPN message to your server may not support redirect requests. As these HTTP requests are not coming from users browsers' output from your Php script is irrelevant. If you want to do any extended processing you have to incorporate that into your IPN Handler.

Categories