Update database after paypal payment successful - paypal

i want get transaction id from paypal after customer already paid by paypal account to update my database Please Help.

if you want to get the transaction ID from your PayPal account just login into your PayPal account and go to the "Transaction History", now next to each transaction you can click on details and you can see the transaction ID. If you mean to get this detail through customized code please explain in details your request, Thanks, Andre.

IPN is a message service that notifies you of events related to PayPal transactions. You can use it to automate your back-office and administrative functions and get information on transactions.
In order to use this feature you need first to activate it on your account.
1) Access your PayPal account (www.paypal.com)
2) Click on Profile
3) Click on Instant Payment Notification Preferences
**Please note that if you have new Layout on your PayPal account you need to click on My selling preferences and then on Update just beside Instant payments notifications
4) Click on Choose IPN Settings
5) Add a Notification URL (you must have a listener ready, examples below)
6) Make sure to check IPN messages on Receive IPN messages (Enabled)
7) Click on Save
Make sure also to check every value of the variable notify_url (if you use WPS) in every PayPal button or PAYMENTREQUEST_n_NOTIFYURL (if you use Express Checkout). Their value can overwrite the value you wrote on your PayPal profile for Notification URL.
Please find below some useful links:
Instant Payment Notification:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/
Setting up IPN:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/

Related

PayPal subscription API onApprove

I'm trying to implement the PayPal Subscription API but I'm not sure about the process flow.
I use the react-paypal-js package to generate the subscription button.
The way the users are created on my website is only through the Paypal subscription.
The process is as follow:
The user choose a plan and click on the subscribe button
The PayPal window open and the user follows the subscription process on Paypal
The user is redirected to my website
Using webhooks or with the onApprove callback, I receive the newly created subscription, create a user on my website with the Paypal email address associated with the subscription.
It all works. My problem is that I need to check, before accepting the subscription, if I already have a local user with given email and in this case, I don't want to accept the subscription (as I would then have 2 subscriptions for the same user) and display a message saying that their is already an active (or suspended) subscription associated with the given email.
As far as I can tell, when the onApprove is called or the webhook is called, the subscription has already been processed and activated.
Thanks!
You don't have to design a system in which the PayPal email used to make the payment, and the email of the user used to log into your site, have a 1:1 relationship. Instead you can have the user log and create their account with you first (as they will always need that to manage something subscription-based) and then you will know there is no subscription associated with that user before displaying the PayPal Subscribe button. Then they can pay with any PayPal account (might be the same email, might be different)
As far as I can tell, when the onApprove is called or the webhook is called, the subscription has already been processed and activated.
That is the default behavior, yes. Per the above it shouldn't be ncessary, but you can change the subscription to start in an inactive state, and show a final review step on your site that will activate it via API. This is controlled by setting application_context -> user_action -> CONTINUE (vs default SUBSCRIBE_NOW). See the API reference for subscription create, and you would of course need to use the subscription activate API call as a final step after confirmation.

Where is the 'IPN History' on the new PayPal website?

Just been trying to find the new IPN History link on the new PayPal website and I can't see it anywhere.
Are they still supporting this?
The current PayPal for Business interface only provides a way to access IPN History if you have manually configured IPN in your PayPal account settings. In this case, you'd go to [your name] > Account Settings > Notifications > Instant Payment Notifications (click Update here), then the explanatory text there will include a link to the IPN History page.
However, that link would not appear if you have not manually configured IPN -- e.g., when your ecommerce platform automatically transmits IPN parameters to PayPal for each checkout. While you could manually enable IPN with a dummy Notification URL in order to get the IPN History link, this could result in PayPal completely disabling IPN for your PayPal account if they try sending any actual notifications to that dummy URL.
In that case, you can use this link to access IPN History directly once you're already logged into PayPal:
https://www.paypal.com/cgi-bin/webscr?cmd=_display-ipns-history
Note that if you have not manually configured IPN in PayPal, you will see a notice in IPN History saying, "The IPN feature is turned off. You must turn on IPN in order to create history data." That notice is irrelevant if your ecommerce platform specs IPN dynamically for each checkout; in that scenario, you can still view/search your IPN History without manually turning on IPN there.
More menu -> Site map -> Transactions -> IPN History
2020
Sitemap (Footer) -> Instant Payment Notification (IPN) history (under "Transactions")
It's still available in the same place. If you want to navigate to it
Log in
Profile link (white bar up top)
IPN settings
History link on this page
Currently it's directly at https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-ipn-notify (provided you're logged in)
In the latest UI: Settings > My Selling Tools > Instant Payment Notifications click "Update". You will see a link there called "IPN History page".
As of May 2022, it's still convoluted.
TL;DR:
For IPN History, try https://www.paypal.com/us/cgi-bin/webscr?cmd=_display-ipns-history
For IPN Settings, try https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
Also, a few reminders:
PayPal IPN is a completely separate feature from PayPal Webhooks.
Even though it's the exact same concept (argh!).
PayPal IPN is associated with your normal/business PaypPal account. It is is not a part of the PayPal Developer experience.
Also, PayPal IPN is now clearly deprecated, if not effectively obsolete, so if your application code is still reliant on PayPal IPN you really should update it to use PayPal Developer APIs and the Webhook service instead.
Anyway, here's the steps I took to find it today on 1st May, 20222:
Start off on your PayPal Business Account Dashboard page:
https://www.paypal.com/mep/dashboard
It should look like this:
Don't confuse this with the Developer Not
Use the top-left menu to go to Account Settings:
https://www.paypal.com/businessmanage/account/accountAccess
On the Account Settings page, look for "Notifications" in the left-side menu:
https://www.paypal.com/businessmanage/account/notifications
Then you'll see the link to PayPal Instant Payment Notifications.
Annoyingly, they don't use the term "IPN" so Ctrl+Fing for that won't work.
Click the "Update" link (even though we aren't updating anything: we just want to see IPN History), and you'll be taken to a page belonging to Olde PayPal just with a new header:
https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
And the link to the History page is disguised in the page's text:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_display-ipns-history
And you'll be welcomed back-in-time to 2005 with a page that looks like this:

Paypal response slow

This is the process flow of a customer buying our service:
Create campaign
Select a payment method (credit card or paypal). User selects paypal
User is redirected to www.paypal.com and makes the payment
User is redirected to www.mywebsite.com/dashboard (return_url)
User sees his new campaign on the dashboard
When using the sandbox everything is working fine. When using the real service, when the user is redirected to www.mywebsite.com/dashboard, then the new campaign doesn't show up among the records.
I made extensive testing and found that with the live service PayPal gives me the response about 5-10 seconds later than when I am using the sandbox. So when the user is redirected to the his dashboard, the new purchase is not yet inserted into the database that's why it doesn't show up! They need to manually hit F5 after a couple of seconds to display the new record.
What can I do about it?
EDIT
I managed to bring up this delay problem with the sandbox as well. I found that there is a difference between the demo and the live payment:
In the sandbox, after the payment I see a window with the title Your payment is complete saying that I completed the payment, this is the transaction code, and the details will be sent to my email address soon, with two options: Back to the seller account (Back to [sandbox seller account]) and go to the paypal account overview. When I click the first one, it opens another window with the title Thanks for your order saying
Your payment of $0.99 USD is complete
If you are not redirected within 10 seconds, click here.
In the live system after I click Pay Now and the payment is complete, then the first screen does not show up, meaning right after the payment the Thanks for your order page is seen then I am redirected to my website (dashboard) within a few seconds.
How could I generate this delay problem in the sandbox?
In the sandbox when the screen shows up about the completed payment when I click quickly the Back to the seller account link, then I click quickly the click here link on the next screen in order to skip the redirection time, the new purchase does not show up on my dashboard on my website, because the data is not yet written into the database.
So the loading of the Your payment is complete window in the sandbox plus the time I click the Back to the seller account link is enough for paypal to give me the necessary data and for me to insert it into the database.
I guess the solution could be to activate that first screen in the live system, but how? What do you think?
I thought the solution would be to turn off Auto return but I can't. When I turn it off and click Save, I receive an error You have not turned on Auto Return. You must turn on Auto Return in order for Payment Data Transfer to work properly.
Start with adding Payment Data Transfer and Auto Return to PayPal Payment Data Transfer Information.
This is from the official PayPal Documentation:
Payment Data Transfer allows you to receive notification of successful payments as they are made. To use Payment Data Transfer, you need to turn on Auto Return. Here's how:
Log in to your PayPal account.
Click Profile.
Click My selling tools.
Click Update near "Website preferences".
Select On under "Auto Return for Website Payments", and enter your Return URL below.
Select On under "Payment Data Transfer".
Click Save.
The identity token will then appear in the Website Payment Preferences page of your PayPal account under the "Payment Data Transfer" section. For security purposes, we do not email you the identity token.
You'll need to pass this identity token along with the transaction token to us so you can receive confirmation that the payment is complete.
The slow load can be caused be a number of factors. One of which may be code related. Can you please post some code if you have already enabled Payment Data Transfer, and Auto return?

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.