how to validate payment was made - paypal

I have read about paypal IPN but that has delays in notification.
I watched this video on setting up a paypal subscription button
http://www.youtube.com/watch?v=jHC9BoRDEOY
but the thing I am missing is that I add a url that paypal will go to after payment. When this url is hit, I need to immediately verify that payment was made(ie. I want it so if a user goes to that url without paying, we don't accidentally continue the process since he has not paid yet).
so, how can I
1. have paypal feed me some kind of unique id when it brings up my url
2. call back to paypal to verify that payment as been made.
Lastly, how can I test this all out on the paypal sandbox to make sure everything is working together?
thanks,
Dean

I did find this but this is not using the buttons at all. Is there not a way to use the buttons?
https://developer.paypal.com/docs/classic/express-checkout/ht_ec-recurringPaymentProfile-curl-etc/
thanks,
Dean

Related

Paypal IPN not firing?

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.

How to integrate with Paypal suggested solution: "Add payment buttons to your website"

I hope to integrate Paypal using "Add payment buttons to your website" https://developer.paypal.com/webapps/developer/docs/integration/web/ since my site only needs one time purchase so this solution is perfect.
But it requires an IPN implemented as an async solution at the merchant side to receive the transaction result. While the button redirects user to paypal.com to finish the payment process. But after that is done. User is not automatically redirected back to merchant site.
I found on the forum that I can add an "data-return" attribute in the script element so when user is done paying there is an additional link that points to the merchant site. Now since IPN is asynchronous, once user views the "data-return" page, IPN may not have been called yet. My questions are:
1. So what's the suggested solution of synchronizing between return page and IPN?
2. When testing, I found a lot of query strings are appended to the "data-return" URL, looks related to transaction result. Can I use them to replace IPN so I have a SYNCHRONOUS way of verifying the transaction result?
Thanks!
Use Payment Data Transfer (PDT, for short). https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/paymentdatatransfer/

PayPal Subscription Cancellation from Merchant Website

we have a paypal payment system integrated into our website so people can register and choose a subscription. The subscription part works fine as the payment goes through and the IPN hits our website and updates our systems. Now we want users to be able to cancel their subscription from within our website so we have a custom cancellation button which when clients click, should send a request to paypal and cancel their subscription. We managed to get this going on sandbox test system however since we have brought the system into live testing we can not get the cancellation feature to work. So currently when the user clicks on cancel button, i think paypal is not being notified and hence no IPN received from PayPal.
Do you know what all info we need in order to cancel the subscription from our website. I know there is a way where users can log into paypal and cancel their subscription or we can log into our paypal and cancel their subscription but we want it to work from our website.
Please help!
Thanks.
When you say you have it working on the sandbox but not live, what exactly is going wrong when you try it live?
I'm actually a little confused by that, because my initial answer was going to be that you can't kill subscriptions via the API unless you're using Recurring Payments. Standard subscriptions aren't accessible via the API.
If you're saying you're doing that in the sandbox, though, then there must be something I'm unaware of..??
On that note, I know the PayPal system pretty well, so I'm thinking maybe you did Recurring Payments on the sandbox, but live you're using Standard Subscriptions..?? If that's accurate then you'll need to move to recurring payments instead of standard subscriptions on the live site.

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.

Change the IPN url on existing subscription

we plan to change the domain name for our service. Therefore we need to update the IPN-url for our existing customers. I have tried googling a solution on how to change the IPN-url for current subscriptions, but I haven't been able to find anything.
Any help is appreciated.
best regards
Thomas
I ran into this problem today.
Folks who are saying that you can change the IPN URL on an existing Paypal recurring payment are incorrect; you can't, you can only change the IPN URL for future notifications.
To resolve this, I used an Apache rewrite:
RewriteRule ^sites/all/modules/civicrm/extern/ipn.php$ https://example.org/wp-content/plugins/civicrm/civicrm/extern/ipn.php [R=307,L]
The magic is the R=307. A 307 redirect indicates that a POST request must be resent as a POST. Otherwise you lose the IPN data.
I had exactly the same problem .... I had to move servers which meant my IPN url changed.
I have spoken to 3 different paypal reps and even had a meeting with a tech support guy from there.
Unfortunately, there is NO WAY to change the IPN url for existing customers/subscriptions.
I have been advised that all existing customers/subscriptions would need to be setup again, your customers would then need to start a new subscription based on the new IPN url.
This is a right PITA ... I have just over 1500 customers I need to do this for, and I can guarantee I will lose some due to the hassle of this.
Sorry this wasn't the answer you were looking for :(
If you need to chnage IPN Url make sure that it is still turned on check from History>IPN History and turn it on.
IPN can be enabled in one of 2 ways.
In the PayPal account Profile
Passing an IPN URL as a parameter in an API call or button code.
To enable IPN in your account profile follow these steps:
Log into your account at https://www.paypal.com
Click on the Profile
subtab In "My selling tools" click Update in the Instant Payment Notifications section.
Click the Edit button or Choose IPN settings
Enter your IPN URL in the Notification URL field Make sure the radio button for 'Receive IPN messages (Enabled)' is selected
Click Save
IPN can be enabled directly in this section of the account: https://www.paypal.com/ie/cgi-bin/webscr?cmd=_profile-ipn-notify-edit (access requires login)
To pass an IPN URL as a code-level parameter you should refer to the documentation of the feature you are implementing. Typically the API variable you would pass is 'NotifyURL' but it can differ based on the API call, if the API is Name-Value-Pair (NVP) or SOAP format or if you are using non-hosted PayPal Standard button code. For standard buttons the variable is "notify_url".
This profile setting is frequently overridden by shopping carts. Still, IPN should be enabled in the account.
It's 1 May 2013 & PayPal has changed the location for the IPN.
Login, go to Profile -> My selling tools ->Instant Payment Notifications...(Update)
This shows your current IPN URL, and there is an EDIT button.
In the absence of a solution from Paypal, I would encourage anyone to submit a support ticket requesting a manual change. If enough of us do this, they will have to provide this option eventually.
Contact Paypal Technical Support here.
EDIT: I managed to successfully change all my prior IPN URLs via a ticket with Paypal Support. They told me it has to be done manually, but obliged my request. It took about a week. They were very helpful. Hope this helps someone.
Dec 2022 update:
There is IPN URL settings at https://www.paypal.com/merchantnotification/ipn/preference . I changed the IPN URL and since then all IPN notifications are coming to the new IPN URL. I do not know if super old subscription notifications will also come to this URL or not, but I can confirm that 1.5 year old subscriptions are going to this new URL now.
I have just done it.
Login, go to Profile -> My Account Settings ->Instant Payment Notifications...(Update)
This shows your current IPN URL, and there is an EDIT button, which works.
This is April 2013, so PayPal might have changed since this question was posted