Introduction
PayPal IPN for WordPress provides a number of hooks so that you can automate tasks within your own plugins/themes based on the type of IPN that was sent or the payment status of a transaction. This allows you to easily extend the plugin to suit your needs.
Note
Don’t forget to check out our developer guide if you need some guidance on building your own hook functions.
PayPal IPN WordPress Hooks Library
Most of the hooks provided by the plugin will be based on the txn_type or payment_status value sent in the IPN and will always be all lowercase. The following list includes all of the hooks that are currently available.
Catch-All Hook
paypal_ipn_for_wordpress_ipn_response_handler
This is a “catch-all” hook that is triggered with all IPN transactions regardless of the type or payment status.
Verification Hooks
paypal_ipn_for_wordpress_ipn_response_verified
The IPN being processed has been successfully verified by PayPal.
NOTE: Â You can also check the status of the IPN from within any other hook function using $posted[‘IPN_status’].
paypal_ipn_for_wordpress_ipn_response_invalid
The IPN being processed failed verification with PayPal and is considered invalid.
NOTE: Â You can also check the status of the IPN from within any other hook function using $posted[‘IPN_status’].
Transaction Type Hooks
paypal_ipn_for_wordpress_txn_type_adjustment
A dispute has been resolved and closed.
paypal_ipn_for_wordpress_txn_type_cart
Payment received for multiple items; source is Express Checkout or the PayPal Shopping Cart.
paypal_ipn_for_wordpress_txn_type_express_checkout
Payment received for a single item; source is Express Checkout.
paypal_ipn_for_wordpress_txn_type_masspay
Payment sent using MassPay.
paypal_ipn_for_wordpress_txn_type_merch_pmt
Monthly subscription paid for Website Payments Pro.
paypal_ipn_for_wordpress_txn_type_mp_cancel
Billing agreement cancelled.
paypal_ipn_for_wordpress_txn_type_mp_signup
Created a new billing agreement.
paypal_ipn_for_wordpress_txn_type_new_case
A new dispute was filed.
paypal_ipn_for_wordpress_txn_type_payout
A payout related to a global shipping transaction was completed.
paypal_ipn_for_wordpress_txn_type_pro_hosted
Payment received; source is Website Payments Pro Hosted Solution.
paypal_ipn_for_wordpress_txn_type_recurring_payment
Recurring payment received.
paypal_ipn_for_wordpress_txn_type_recurring_payment_expired
Recurring payment expired.
paypal_ipn_for_wordpress_txn_type_recurring_payment_failed
Recurring payment failed.
paypal_ipn_for_wordpress_txn_type_recurring_payment_skipped
Recurring payment skipped.
paypal_ipn_for_wordpress_txn_type_recurring_payment_profile_cancel
Recurring payment profile has been canceled.
paypal_ipn_for_wordpress_txn_type_recurring_payment_profile_created
Recurring payment profile has been created.
paypal_ipn_for_wordpress_txn_type_recurring_payment_suspended
Recurring payment has been suspended. This transaction type is sent if PayPal tried to collect a recurring payment, but the related recurring payments profile has been suspended.
paypal_ipn_for_wordpress_txn_type_recurring_payment_suspended_due_to_max_failed_payment
Recurring payment failed and the related recurring payment profile has been suspendedThis transaction type is sent if:
- PayPal’s attempt to collect a recurring payment failed
- The “max failed payments” setting in the customer’s recurring payment profile is 1 or greater
- The number of attempts to collect payment has exceeded the value specified for “max failed payments” In this case, PayPal suspends the customer’s recurring payment profile.
paypal_ipn_for_wordpress_txn_type_send_money
Payment received; source is the Send Money tab on the PayPal website.
paypal_ipn_for_wordpress_txn_type_subscr_cancel
Subscription canceled.
paypal_ipn_for_wordpress_txn_type_subscr_eot
Subscription expired.
paypal_ipn_for_wordpress_txn_type_subscr_failed
Subscription payment failed.
paypal_ipn_for_wordpress_txn_type_subscr_modify
Subscription profile modified.
paypal_ipn_for_wordpress_txn_type_subscr_payment
Subscription payment received.
paypal_ipn_for_wordpress_txn_type_subscr_signup
Subscription started.
paypal_ipn_for_wordpress_txn_type_virtual_terminal
Payment received; source is the Virtual Terminal
paypal_ipn_for_wordpress_txn_type_web_accept
Payment received; source is any of the following:
- A DoDirectPayment (Pro) credit card transaction
- A Buy Now, Donation or Smart Logo for eBay Auctions button
Payment Status Hooks
paypal_ipn_for_wordpress_payment_status_canceled_reversal
A reversal has been canceled. For example, you won a dispute with the customer, and the funds for the transaction that was reversed have been returned to you.
paypal_ipn_for_wordpress_payment_status_completed
The payment has been completed, and the funds have been added successfully to your account balance.
paypal_ipn_for_wordpress_payment_status_created
A German ELV payment is made using Express Checkout.
paypal_ipn_for_wordpress_payment_status_declined
The payment was declined. This happens only if the payment was previously pending because of one of the reasons listed for the pending_reason variable or the Fraud_Management_Filters_x variable.
paypal_ipn_for_wordpress_payment_status_expired
This authorization has expired and cannot be captured.
paypal_ipn_for_wordpress_payment_status_failed
The payment has failed. This happens only if the payment was made from your customer’s bank account.
paypal_ipn_for_wordpress_payment_status_pending
The payment is pending. See pending_reason for more information.
paypal_ipn_for_wordpress_payment_status_refunded
You refunded the payment.
paypal_ipn_for_wordpress_payment_status_reversed
A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer. The reason for the reversal is specified in the reason_code parameter.
paypal_ipn_for_wordpress_payment_status_processed
A payment has been accepted.
paypal_ipn_for_wordpress_payment_status_voided
This authorization has been voided.
Adaptive Payments Transaction Type Hooks
paypal_ipn_for_wordpress_adaptive_adaptive_payment_preapproval
An Adaptive Payments Preapproval profile has been created.
paypal_ipn_for_wordpress_adaptive_adaptive_payment_pay
An Adaptive Payments payment has been processed.
Adaptive Payments Status Hooks
paypal_ipn_for_wordpress_adaptive_status_canceled
An Adaptive Payments payment has been canceled.
paypal_ipn_for_wordpress_adaptive_status_created
An Adaptive Payments payment has been created.
paypal_ipn_for_wordpress_adaptive_status_completed
An Adaptive Payments payment has completed successfully.
paypal_ipn_for_wordpress_adaptive_status_incomplete
An Adaptive Payments payment is incomplete.
paypal_ipn_for_wordpress_adaptive_status_error
An Adaptive Payments payment failed with an error.
paypal_ipn_for_wordpress_adaptive_status_reversalerror
An Adaptive Payments payment reversal failed with an error.
paypal_ipn_for_wordpress_adaptive_status_processing
An Adaptive Payments payment is processing.
paypal_ipn_for_wordpress_adaptive_status_pending
An Adaptive Payments payment is pending.
Looking for Live Help?
Schedule a live meeting with Drew Angell, PayPal Certified Developer, and get all of your questions or concerns answered.
Featured PayPal Products and Services
-
PayPal Support
$100.00 -
PayPal for WooCommerce
FREE! -
WooCommerce Multiple PayPal Accounts Plugin
FREE! -
PayPal Shipment Tracking for WooCommerce
$49.99 -
Offers for WooCommerce
$59.99 -
WordPress PayPal Invoice Plugin
$20.00 -
PayPal Webhooks for WordPress
$79.99 -
Sale!
PayPal IPN for WordPress
Original price was: $59.99.$49.99Current price is: $49.99.
I’ve contact PayPal, they say I need a plugin that handles “Adaptive Payments”. Currently I have “WP Simple PayPal Shopping Cart” and would like to keep it. I tried Woo Commerce and it’s way over-kill for what I need. Can I use this plugin PayPal IPN with my shopping cart? I am not a developer and need some help with this.
When a purchase is made on my site, lets say $40 hits my PayPal account I want the IPN to send $32 to my vendor along with some of the shipping cost as well as the customer’s name and shipping address. Will this plugin do that? Or do I need Woo Commerce??
You’ve got sort of a 2 part question going on here. If you need to work with Adaptive Payments that will probably need to be built custom. There aren’t many (if any) Adaptive Payments plugins for WordPress yet. That is what would allow you to setup Preapproval profiles and/or split payments.
If you don’t need to split payments then you could integrate PayPal itself using any payment method you want. So your current plugin should work fine for that part. Then, yes, you could use this plugin to setup IPN on your site quickly and easily. You would then need to build in some functions/hooks to trigger payments out to another user using the Pay or MassPay API depending on exactly what the needs are at that point.
Either way it would have to be approved by PayPal, and they’re probably going to tell you that you need to just use a split payment via the Pay API instead of triggering secondary payments in IPN.
Hello,
I would like to design a “Thank you Page” that redirects the user back to my site after they make a donation.
On this page I would like it to include some of the PayPal information.
For Example…
Thank you “JOHN SMITH” for you donation of “$10” on “12/25/2015”
(the items in quotes are what I want to receive from PayPal).
The reason I want to do this because:
I want to send them back to my site
I want to use google tag manager
I would consider myself a moderate developer in PHP.
Thanks,
To get data back to the return URL you would need to use PDT, which is very similar to IPN except that it’s used with a return URL instead of server to server communication. Even with PDT and Auto-Return enabled, though, the user is not guaranteed to make it back to your site, so if you’re doing any post-transaction data processing of any kind that’s always recommended to be done in IPN.
I’m trying to set up a function where if there are no available funds within the customer’s PayPal account, then it will take them to a ‘payment failed’ page or ‘subscription failed’ page and therefore doesn’t create an account on our site. Currently, whether payment is being taken or not, our WordPress site is assuming that payment will take place (but we know this isn’t always the case) and the customer has access to our subscription-only site. I’m new to IPNs so this is a little confusing… Reading through the hook function snippet part within settings, I can see where to add the correct function I want, but I’m not sure where this goes within my WordPress site..?
What’s the best method in telling a customer that their payment has failed and therefore they are unable to proceed with creating an account?
Within various hooks / functions you could build different logic depending on the payment status. For example, for completed payments you could generate an email notification with login details to the subscription area, or whatever detail they need. If the payment is failed, pending, etc. you can a corresponding email notification and simply not activate the account on your site.
In the case of a pending payment, you would get another IPN when the status of that payment updates (hopefully to completed). So you would end up with separate functions for each payment status.
Those functions can go within your own plugin or they can go into your theme’s functions.php file.
Hi Andrew
I want to generate an email notification for a new user with login detail (password and username) only after the paypal payment is successful. I would like this process to be automated with the help of IPN to trigger the email notification. Thank you. Looking forward yo your reply.
Hi Winston,
We’re actually working on a premium extension that will allow you to build this visually inside the WP admin panel, but it won’t be ready for another month or two probably because we’re focused on other things right now. You can do this pretty easily within code, though, if you’re comfortable with that. Do you have any specific questions about how to get it done? We could do it for you but we’d have to do it as a custom project for you. You can submit a quote request if you’re interested in that. Thanks!
Hello, I looked at the ipn for public and ipn loader php files, still not sure where to start in order to make use of the ‘payment_completed’ hook. I’d like to execute a few lines of php code when ‘payment_status’ equals “Completed”. Your help would be appreciated.
I’m sorry for the delay getting back to you on this. If you are still having trouble please submit a ticket here and I’ll be happy to help.
I’m setting up a new WordPress website along with an email campaign to launch a new healing center. The end user will click a PayPal button in the email and will be taken directly to the PayPal payment page. Once the payment is complete I’d like the person to be taken to our website to a successful transaction page where they will be able to print out a receipt as well as a voucher that will have five unique service slips, each with the unique transaction number from PayPal and the date of purchase, as well as the user’s first and last name. Can this plugin be used to accomplish this? Thanks, Thomas
Some of this you can get done with our plugin, but some of it you’ll need to do another way. We can certainly help you get all this working, but we’ll need to give you a bid on custom work. If that’s something you’d be interested in please submit a request here.
I’m forwarding an IPN from my website to external invoicing service so automatic invoice can be created by their API. I’m using the following code:
add_action( ‘valid-paypal-standard-ipn-request’, function( $post ) {
wp_remote_post( ‘https://apiaddresshere’, array( ‘body’ => $post ) );
} );
It works fine for regular orders, however it doesn’t work when an IPN for recurring order is received. What function is fired for recurring orders? Is there one code I can use to forward any kind of IPN received or do I need to add a separate action for recurring IPNs. In that case, what would be the code to forward recurring IPNs?
Not a developer here so be gentle 🙂
Thanks,
krko
Please submit this question to our help desk and I’ll answer it in the order it comes in. Thanks!
HI,
I am using CF7 and paypal add on pro. I want my customers and my self receiving emails only after the payment submitted. Those your plugin with some hook can help me to do so?
Thanks
Yes, you could use the paypal_ipn_for_wordpress_payment_status_completed hook for that. It gets triggered any time a payment is completed on PayPal. You can review our hook documentation for a full list of hook options.
Hi actually i have a problem i hope you can help me i’m using paypal_ipn_for_wordpress_payment_status_completed so any time a IPN reach my site i keep the data on my BD but now with the same IPN the process is making 4 or 5 records on my BD for one trasacction
When that sort of thing is happening it’s typically because the IPN script is not completing successfully and returning a 200 response back to PayPal’s server. It could be getting through the DB update code, so you see that reflected, but then it fails after that resulting in a 500 response to PayPal, and as such, PayPal sends another one.
One way you can check this is by looking at IPN History in your PayPal account. Also looking at your web server logs should help. You should be able to see the actual error happening in the logs.
Hey,
I’m using your PayPal IPN for WordPress plugin alongside WooCommerce. I am using another plugin to add a custom field on checkout in WooCommerce, and I would like to include information from this custom checkout field into the IPN data and use it to insert information in my local database. Here’s the code I have to add to my IPN after the purchase:
mysqli_query($con,”INSERT INTO `users` (sc_username,payment_email,trans_id,forum_uid) VALUES (‘”.$db->escape_string($custom[‘sc_user’]).”‘,'”.$db->escape_string($ipn_data[‘payer_email’]).”‘,'”.$db->escape_string($ipn_data[‘txn_id’]).”‘,'”.intval($loggedinUsersUID).”‘)”) or die(mysqli_error($con));
I would like to know how I can add this to my IPN using your plugin.
The first thing you’ll need to is add your custom value to the CUSTOM parameter in the PayPal requests. We have hooks included in the plugin to get this done, but we don’t yet have the documentation updated. Let me know which gateways you’re working with specifically and I can show you what hook to use for that. Then your value will come back in $posted[‘custom’] within our IPN plugin.
If you are working with Express Checkout the filter hook name is: ae_ppec_custom_parameter
Guys im really stuck – i want to trigger an email whenever a payment status is notified as Completed.
I understand i need a bit of code but i simply dont know where im supposed to place this code!
Any advice??
Hook functions go in your theme’s functions.php file or in your own basic plugin file.
I am looking for a simple way to get the information PayPal sends back upon a successful membership purchase transaction or the e-mail itself sent to our accountant since PayPal will only allow one e-mail address to get that e-mail. Have your PayPal IPN plugin installed and I am not a super technical person and can’t “see” the next step.
The website is a test version as a subdomain of another personal site I have. Am migrating our existing http://www.mwtca.org Joomla site to WordPress for ease of support. We are an all volunteer, not for profit association of antique tool collectors.
Thanks so much in advance for your help!!! Ed
Hi Ed,
The hook functions can go in your theme’s functions.php file or within your own plugin. I would recommend doing it from within your own plugin, which is very simple. Download this plugin template, and you’ll see it’s setup with a single hook function. This sample function sends an email to a given address for all IPNs that hit the site, which is what the “paypal_ipn_for_wordpress_ipn_response_handler” hook is for.
All you need to do is customize the function so that it builds a more complete email that you’d like to send, and then you may want to adjust the hook name, too, so that instead of sending for ALL IPNs, it would only send for completed payments, for example. In that case you would use the “paypal_ipn_for_wordpress_payment_status_completed” hook instead. Of course, you can setup a variety of different hooks to handle different transaction types and payment status differently.
Hope that helps! If you have more questions please submit an order for premium support and then we could schedule a phone/video conference with you to walk you through it.
Hi, thanks for plugin. Is possible not store IPN data?
If you’re not storing the data, what exactly are you doing with the plugin? I suppose you could write a function to delete the post and then call that function after doing whatever processing you’re wanting to do.
Yes, this is my idea 🙂
Because I don’t wont hold all data in WP Database.
How I can delete your post? It is a custom post_type?
Best regards
Yes, the IPN records are store as custom post type called
paypal_ipn
, so you could use wp_delete_post() accordingly.Thanks.
Hi.
I bought “IPN Forwarder”.
Is there a doc about the plugin?
“Enable Smart Forwarding” ?
I tested it with “IPN Field” -> All and with “Payment Status” -> Completed.
In my Php file “PayPal IPN Forwarding URL” I only set a mail function to hook when the page is fired.
I did Orders with Woocommerce. But I didn’t received nothing (only the order emails from Woocommerce)
“Paypal IPN” list transactions are OK (Payment Status : Completed)
Thank you.
We still need to get the info about Smart Forwarding added to our documentation. Sorry for the confusion on that. Basically, that lets you setup triggers to only forward the IPN to the specified URL if the conditions in the trigger you setup are met. Otherwise, that forward rule would be ignored for orders that don’t trigger that condition.
Our plugin has an IPN History under the settings. Can you check to see what it shows for the forwarded data?
hello recently downloaded ipn for wordpress, i was wondering, first, where might one find the predefined hooks defined, and more specifically, how does one utilize the hooks
Take a look at our Developer Guide. Then at the bottom of that it will lead you into the Developer Hooks Guide.
Hello; No mention of event order in the docs: do all these hooks fire before the post is actually inserted?
I’m testing with the ‘catch-all’ and querying for txn_id but not getting a result on a new transaction, whereas a ‘repeat’ IPN succeeds.
The goal is to generate an additional postmeta record so I need to supply post_id.
I am not 100% sure on this. I will check with our lead developer for this plugin and get back to you soon.
Did you try something like this? https://pastebin.com/0sj1EZqt