Setting up Instant Payment Notification with PHP - PayPal - php

I have set up a PayPal Sandbox account and have created a script to take payments using PHP/cURL which basically follows this tutorial. We have already purchased a PayPal Payments Pro account to use it with. Now I need to set up Instant Payment Notification (IPN) In order to show payment details on our confirmation page and keep track of transactions in our own database.
Questions:
How do I set up IPN in the PayPal Sandbox?
How does IPN tie into the NVP API I Used? I've seen several PHP Tutorials with code samples but none of them explain how to set it up with the API.
References:
Here is the NVP API Manual.
Here is the Order Management Integration Manual.
Here's an FAQ type post on PayPal.
Many Thanks.

IPNs should be enabled for you be default. If not, you can enable them from your PayPal account -> Profile -> My Selling Tools -> Instant payment notifications.
IPNs are triggered by API calls such as DoExpressCheckoutPayment, DoDirectPayment, RefundTransaction etc. In general, PayPal generates an IPN message when external events arise that might affect a transaction, such as disputes, chargebacks, eCheck clearing, and various recurring payment and subscription events.
When you setup your IPN listener,
Ensure it is reachable from the internet. You can use the IPN simulator to verify reachability.
Register a global IPN listener URL in the IPN settings page above OR provide a IPN notification URL with every API call. See the API reference to understand how this can be done.

Related

Omnipay callbacks from APIs like IPN and Silent Post?

How can I capture paypal IPN and Authorize.net "Silent Post" messages?
I'm fine with how to make payments with Omnipay but I could not yet figure out how to listen to the callbacks from these APIs to detect changes for my payments.
For example Authorize.net processes it's credit card payments one time per day (late night for me) and then sends out it's messages via their so called "silent post" (its just a http POST) notifications. So the API call might be immediately "accepted" but I won't know for sure if everything is OK with the payment until I receive the callback.
So how do I set up Omnipay to listen to APIs that do these kind of delayed callbacks?
I'm aware that I'll need a callback URL like /payments/callback/ to load the right gateway to do something with the callback. But I could not yet figure out what method(s) from Omnipay I have to use for it.
Omnipay doesn't support notifications for existing payments. It automatically handles the first notification which is made directly after a payment, but doesn't yet have methods to handle notifications if you change the status of a payment (for example by refunding it from PayPal's control panel, it will not update in your database automatically).
Note this isn't needed for the initial payment. Especially with PayPal Express the payment is not confirmed until the customer returns to your site, so there is no chance of them closing the browser window and the payment being lost.
If you want to set up a notification endpoint and listen for events which happen after the payment is processed, you will need to add a new request type to Omnipay.

scripts to update my database after a payment is made using paypal

Im haing a problem iv been researching for weeks now on the paypal API but i just can't figer how to do this.
I need there to be a button on my website which then it goes to paypal.
Once you have paid the chosen amount it goes to a php page which updates the database though php.
You have to turn on paypal ipn in your paypal preferences. Once paypal has the money it sends you a transaction back to your server. In the script that accepts the transaction you can have it update your tables.
Documentation : https://www.x.com/sites/default/files/ipnguide.pdf
generally you pass a notify_url parameter with the request, and set up a page which handles and validates IPN notifications, and PayPal will send requests to that page to notify you when payments/refunds/etc. go through. That IPN handler page would then be the correct place to update the database to mark orders as having been paid.
i found a tutorial here: http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/
I found more suitable the PayPal NVP API instead of tradional IPN (Instant Payment Method)
You can find several code examples for PHP (including very similar to your problem and more advanced) in the library code for NVP samples

How do I get data back from Paypal so I can alter my MySQL database accordingly?

I'm just starting out with Paypal, so this is a newbie question.
I've been going through the instructions for setting up Paypal subscription service, but I think I'm looking at the wrong thing.
What I want to acheive is to get back some kind of response from Paypal so that I can update the database on my web site to mark a registered user as having paid. Basically I have a flag in the database that says if the user is subscribed or not. I want to ensure that the user is marked as paid so long as their Paypal subscription is maintained.
While the instructions linked above do say how to set up a button to receive a payment, there's nothing there about getting any data back from Paypal.
I know there are terms like IPN and sandbox that are related to what I'm trying to do, but I can't find clear instructions for how to get started on this process. I'm just circling around and not getting anywhere.
Where do I start on setting this up? Where is there a clear beginner's tutorial?
Also, I'm using PHP/Javascript/MySQL on my website.
PayPal's IPN service is what you want to use. I've used it myself to do just what you're looking to do.
Instant Payment Notification (IPN) is PayPal's message service that
sends a notification when a transaction is affected. Once IPN is
integrated, sellers can automate their back office so they don’t have
to wait for payments to come in to trigger order fulfillment. IPN can
send notifications for these transactions:
Instant payments, including Express Checkout and direct credit card payments
eCheck payments and pending, completed, or denied status payments
Pending payments
Recurring payments and subscriptions
Authorizations
Disputes, chargebacks, reversals, and refunds
You can also view notifications on PayPal’s IPN History page and
resend them if you need to. As PayPal’s interface for handling
purchase confirmation and server-to-server communications, IPN can
also be used to manage and customize a variety of APIs and
communications, including:
Customize your website's response to customer purchases in seconds
Track customers via IPN "pass-through" variables
Notify sellers who deal mostly in software downloads and other digital, online goods
Track affiliate sales and commissions
Store transaction information in your own database
For more about IPN:
Technical Overview (link to new html version of docs on developer central)
Instant Payment Notification Guide (PDF)
Code Samples
I'm not sure if its the same thing, but I just setup my friends website with Express Checkout, and I wanted to add all paid orders to an orders table in my database.
After I call SetExpressCheckout, and the user is returned to my site after going through the purchase flow on Paypal's side,
I used the information from GetExpressCheckoutDetails.
Then, if DoExpressCheckoutPayment
is successful (also called from the "callback" page) I then do the appropriate work in my database as far as logging the order details. For you in this case, it could be updating a record for the user in the database.
Hope that helps a little.

How do I create an adaptive paypal payment without autorization?

I am using the adaptive paypal payment console here: https://apigee.com/console/paypal to make payments to people. I can't find a way to send money out to individuals without granting them permission (from me). I want to be able to send out payments to people automatically when they request it. How would I do this?
You mean you would be the sole 'sender', sending money to different PayPal recipients?
Simply use the MassPay API. This is not part of Adaptive Payments but rather the normal PayPal API's.
If you use Sandbox, you can request for MassPay to be enabled on your Sandbox account by filing a ticket with PayPal Merchant Technical Services at https://www.paypal.com/ or starting a thread in the appropriate forum at https://www.x.com/ (PayPal's developer community).
If you use the Live PayPal site, you can call / email PayPal Customer Service to get it enabled on your Live account.
For the API documentation, see https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_MassPay

Paypal Integration with PHP

I'm looking to implement a very simple Paypal integration whereby I can enter a valid Paypal Email address (recipient) and a dollar amount, and click "Pay." Ideally, it would send the money from my paypal account automatically via my API key.
I currently have Mass Pay set up with PHP, and it's working fine, except that it charges me 2% on every payment, and doesn't pass back the Transaction ID. It also kinda seems unnecessary since I don't need to pay multiple people at once.
Since I only need to do one transaction at a time, I'm wondering if anyone knows of a simpler Paypal API for single outgoing transactions from my account.
I've been reading the documentation all day and I've yet to find what I'm looking for.
Any advice is greatly appreciated!
PayPal has sample codes for integrating various PayPal features on it's website. This includes PHP take a look at the list of features and I'm sure what you are looking for is there.
Also from the paypal site:
PayPal receives the MassPay request and returns a response indicating
success or failure. If PayPal returns a successful response, then
PayPal processes the payments and, if you have Instant Payment
Notifications (IPN) enabled, PayPal sends a notification to the Notify
URL specified in your account profile. If you do not have IPN enabled,
you can view the details of the MassPay transaction in your PayPal
account.
This implies that in the case of mass pay you need to provide a URL where paypal sends payment notifications. Your program can probably check this url to figure out whether a payment has been made or not, I would suspect this would be the case for all payment integration. That being said I would print_r the the response from paypal, I'm sure something like a transaction id will probably be in there. In the case of DoAuthorization it does return the transaction id
In the case of mass pay it does return the transaction id if IPN is enabled

Categories