Paypal IPN not firing? - paypal

I have a question about Paypal IPN, I was wondering when does the IPN activate and send it's message to my website.
I currently have my website that has a buy button. When the client buy the service, he is directed to paypal. Once he pay the service, nothing happen. In order for me to receive the IPN notification, the user has to click "Return to merchant website" or whatever the link is, then I receive the IPN notification.
Is it normal, does it work like that for everyone?
Cause right now, most people when they are done with the payment, just close the website and I don't receive any notification.
Thanks for any help !

Your question leaves a lot of missing information so I will go through each option for you:
Read here about how to setup a sandbox account if you don't already have one: https://developer.paypal.com/docs/classic/lifecycle/sb_create-accounts/
Bare in mind that your sandbox account is entirely separate in every way from your live paypal account. All settings will need to be checked and customised as needed.
Set up your IPN URL on your sandbox account Here: https://www.sandbox.paypal.com/uk/cgi-bin/webscr?cmd=_profile-ipn-notify
Once set up, you then need to download and set your code (PHP or something else) to the listener (referenced in the above sandbox profile link). You can find IPN code examples here: https://github.com/paypal/ipn-code-samples
When that's all set you need to set your listener to using the sandbox mode and then log in to your live account and then run the IPN simulator from here: https://developer.paypal.com/developer/ipnSimulator/
Paypal will send messages to your IPN listener and you need to do something with the messages, typically output them into some sort of log file. Any issues, you can read Paypals feedback and IPN data/delivery information here https://www.sandbox.paypal.com/uk/cgi-bin/webscr?cmd=_display-ipns-history&nav=0.3.4 [Found from History->ipnHistory on the Paypal menu] and it should list them out. You can resend any failed or queued or undelivered messages.
Paypal is a terribly documented and terribly structured system for coding with. I hate it. Use Stripe.
I love bullet points.
Paypal claims they will try and resend failed/queued IPNs 16 times over 5 days. I have yet to see this, you need to resend them manually (at least, sandbox ones)
Please remember all the settings and changes you have made to your Sandbox account will need to be also made to your live account before you make your payment system live!
Solution
My return_URL is the location of my IPN.php file which take care of the data sent and received. My problem is that the IPN is only firing when I click the "Return to merchant website" and not when the payment is actually completed
What you have done, from reading your comments, is set your IPN page to being your return from paypal page, this is NOT the way IPN is supposed to work, the IPN page should never be visited by the customer, only ever by Paypal.
Read through my anwser (points 2,3,4) and set up your IPN web link as I have described above, your return_url value should be a basic page to say to the customer "transaction complete". The IPN page is defined on your paypal accounts (sandbox and live) as I stated above.
This will fix your problem.

Related

IPN doesn't seem to work the way it should based on PayPal's docs

We have created a small app to help users manage certain PayPal orders, but the IPN doesn't seem to work as expected. I found this at the note at the bottom of the following URL:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/
"Even though you have not enabled receiving IPN messages in your Profile or
you have reset your preference by turning off IPN messages, PayPal still
sends IPN messages to the notification URL you specify for a specific
payment."
Based on this we instructed our beta testers not to worry about enabling IPN in their account, since we specify the notification URL for the user's transaction via the notify_url field in the button code. But then no IPN is sent.
Next we instructed our beta testers to enable IPN, and since doing so requires you to enter a notification URL and users don't want transaction data for EVERY transaction posted to our system, and we don't want that either, we instructed them to enter a "fake" URL and disable sending messages to that URL in their account. Based on the note at the link above we figured this should work too, but it doesn't. No IPN is sent, although you can now see the message in the IPN history.
So I'm a little stumped here. The way I see it, we only have 2 options, and neither seems ideal ...
Instruct our users to enable IPN and hard-code our IPN notification URL into their profile settings. This means if they're already using IPN for something else they can't do this, and even if they can it means that data for EVERY transaction they do will hit our system and neither the user nor we want that.
Instruct our users to enter a "bogus" notification URL in their account, and leave messages to that URL enabled, since we'll override this with our own notify_url setting. This would work, however it will cause PayPal to attempt to send messages to an invalid notification URL for any transactions NOT processed through our system. I assume PayPal doesn't want this, and it could possibly lead to the user losing IPN access in the future due to constant IPN errors, etc.
Anyone have any ideas for me? Thanks!
In experience, as you're finding, you do need IPN enabled in order for the IPNs to be sent, but then if you specify notify_url it will override the URL in the profile.
Instead of setting up a bogus URL, though, you could put any actual script there. Just make it a script that does absolutely nothing. That way IPNs that get sent here will "do nothing" other than send a 200 OK back to PayPal's server showing that the IPN was received successfully.
If they're already using their own IPN solution and the data needs to go through both then you'll have to setup an IPN forwarder. You can daisy-chain IPN URLs to that a bunch of them get hit with the same data if you need to.
Personally, I like to have some sort of a catch-all IPN setup in my profile that saves any IPNs it gets to my database for logging purposes. Then, again, the notify URL can be used to override this if necessary.

Detecting all parts of a parallel payment with IPN

I have a parallel payment setup on my dev website, which allows a user to make 2 payments in parallel. Part 1 of the payment goes to the main website, i.e. the site which the user is paying from, i.e. the website which initiates the paypal payment. Part 2 of the payment goes to a completely different paypal account which is unrelated to the main website.
I am using ipn.php on my dev server to detect the status of the payment. When the main sites payment is received (part 1), this is detected by my dev servers ipn.php file. However, the ipn.php file does not seem to detect the other payment (part 2) which goes to the other paypal account which is unrelated to the main website. Is this behavior normal for the ipn system, or is there a way to get my dev servers ipn.php to detect both parts of the parallel payment even though part 2 of the payment is going to someone else?
Each individual payment would trigger an IPN based on the account the payment went to. Sounds like you've got your own IPN configured, but you're only getting an IPN for the payment that comes to you, which would be expected. The other payment would only trigger an IPN for that receiver if they had IPN configured in their own account.
That said, you can set an IPN for the application within your pay request using the NotificationURL parameter. This would send an app specific IPN to the URL specified which is separate from the individual payment IPN's that each receiver may or may not get based on their own settings.
So, it sounds to me like you need to setup the NotificationURL for an app specific IPN, and then you can configure IPN within your PayPal account to get more details about the individual payment that comes to you, and then the 3rd party could configure their own IPN based on their needs for the payment that goes to them.
Make sense?

What if the user doesn't get redirected after PayPal payment?

After adding stuff in shopping cart, clicking some Pay Now with PayPal button, and successful PayPal payment (PP or CC), it is logically possible that a user stays on PayPal website, if for example the Auto Return option isn't activated (or it is but it doesn't work because the user is a guest user without PP account)
The user can return to the site by clicking a link, but doesn't have to. My question is: if he doesn't, how will the site owner be aware that the user paid so that he can now send the items by post? That the site owner gets informed of being paid seems elemental to me, so I find incomprehensible that such elemental thing be left to some obscure Auto-Return option.
Please can somebody explain this to me?
This is a common challenge with any redirected payment gateway, and it's the reason most (if not all) of them implement some sort of asynchronous notification that a payment has been completed. In PayPal, this is the Instant Payment Notification (IPN). You must setup on your site either a generic IPN listener that you link to from your PayPal account profile settings or you can create a more targeted IPN listener specifically for your transactions and use the NOTIFYURL (or related) parameter in the form or API request you use to redirect to PayPal to send IPNs to that listener.
In my integrations, I never perform any order update or transaction logging when the customer returns from the site, preferring instead to wait for the IPN that I can validate and ensure came from PayPal as opposed to a spoofed return from someone trying to hack my checkout process.
For more information, see the IPN documentation: https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro
Paypal provide IPN for this purpose through which we paypal send request asynchronous to your site and you can perform whichever action you want
I think the point may have been missed here. Or a problem does exist. If the purchaser uses CC, even if you have IPN set up and it works, but if the purchaser uses CC and does not click a button on the last page, which is not presented when using PP account, it is possible for the funds to go through, but no IPN, and so your website is unaware of the purchase. This last page, is an extra page that CC user gets after the page with the Pay button on it.
In this state, you can even go into IPN history, and the IPN is there, says it is sent, but it hasn't been. It does not get sent until after the purchaser clicks the button on the extra page and then they are taken to the auto return page.

Checking if paypal payment was successful

I have downloaded sample code from paypal to allow me to use parallel payments via their sandbox accounts. When I run parallel.php, I get redirected to paypal's sandbox login page.
How am I supposed to know "server side" that the payment has been made successfully, so I can update my database records?
I believe you have to work with PayPals IPN system. This will basically send a confirmation to your server that tells you it has gone through.
https://www.paypal.com/ipn
Paypal lets you register a notification url which is part of the IPN (instant payment notification IIRC) system. So if someone pays by a delayed payment (such as a bank transfer) the transaction will update days later. You need to have an application (web page) on your server that can be called by Paypal with transaction details to update a payment.
You'll need to create an initial transaction record in your system when paypal redirects back to you so refer to their documentation for that. I'd also recommend looking at either OSCommerce or Zen cart for an idea of how they do it as they support the same kind of thing.

How do I deal with PayPal customers who can't direct return

PayPal states:
Note: If you have turned on Auto
Return and have chosen to turn on
PayPal Account Optional for new users,
a new user will not be automatically
directed back to your website, but
will be given the option to return.
But if some of the customers don't get "Auto Returned", how do I handle them programmatically?
Paypal does not guarantee autoreturn especially when Paypal Account - optional setting is on.
The right way to handle the integration is with Instant Payment Notification (IPN) option. Using IPN Paypal will make POSTS to your page notifying you of payment events. The following link explains the IPN process pretty well.
To summarize, you will write code that will trap posts from Paypal and then make sure to update your billing data accordingly.
Also, IPN messages might be slightly delayed.
Create a script (cron or what) that does check for such payments at paypal perodically (e.g. every hour).
Is this what you mean?
https://www.paypal.com/cgi-bin/webscr?cmd=p/mer/express_return_summary-outside
If not, you may need to be a little more specific with your question. Like - are you using paypal pro? How are your customers checking out? etc. And now that I read the answer below mine, I wonder if you are even talking about the payment process and not something else.