IPN Data Accessibility
Plugin Extensions
Within your hook functions, the IPN data will be available to you in a $post[] array. You may refer to PayPal’s IPN Variables Documentation for details on all of the different parameters you will have available for any IPN type. For example, if you need access to the payer’s email address you can use:
$payer_email = $posted['payer_email'];
If you are using the hook function template provided by the plugin, then each IPN variable will be parsed into a matching PHP variable for you.
WordPress Shortcode - Table View
- paypal_ipn_list – This shortcode displays a basic table of PayPal IPN transactions and accepts the following attributes.
- The fieldx attribute can be used to specify the name of a field/column you would like included in the table, where x is a number beginning with 1.
- The limit attribute can be used to specify the number of records you would like returned (newest first.) If you do not specify a limit then a default of 10 records will be displayed.
- The txn_type attribute can be used to filter the table results by any compatible IPN type.
- The payment_status attribute can be used to filter the table results by any compatible payment status.
Example
[[paypal_ipn_list field1="txn_id" field2="payment_date" field3="first_name" field4="last_name"
field5="mc_gross" limit="20"]]
WordPress Shortcode - Individual Fields from Transaction
[[paypal_ipn_data]]
- This shortcode can be used to display individual field values for a given transaction. It accepts the following attributes.
-
- The txn_id attribute can be used to specify the transaction ID of the IPN record you would like to pull data from.
- The field attribute is used to specify the field name for the data that you would like returned.
Example
[[paypal_ipn_data txn_id="7EY918813N481574L" field="first_name"]] [[paypal_ipn_data txn_id="7EY918813N481574L" field="last_name"]]
If the name on the transaction was “Tester Testerson” then the above would simply output: Tester Testerson
IPN Details / Hook Function Templates
Within the post details for each of the PayPal IPN notifications sent to your site you will find some useful information that can help you quickly extend the plugin and easily customize it.
PayPal IPN Field Data
Hook Function Template
Within the IPN details you will find a hook template you can use as a quick start to hook into that particular IPN type.
To setup a hook function quickly in your own plugin or theme you can simply copy the template provided and paste it into your code. Then you’ll update the “hook_name” and “function_name” placeholders in the template and you’ll be ready to implement your own solution utilizing the data prepared for you by the template.
Note
Take a look at our PayPal IPN WordPress Hooks documentation for details on all of the different hooks that can be used.
Sample
The following example would create a hook into the plugin that is triggered when a “cart” IPN is received.
add_action("hook_name", "function_name", 10, 1); function function_name($posted) { // Parse data from IPN $posted array $mc_gross = isset($posted["mc_gross"]) ? $posted["mc_gross"] : ''; $invoice = isset($posted["invoice"]) ? $posted["invoice"] : ''; $protection_eligibility = isset($posted["protection_eligibility"]) ? $posted["protection_eligibility"] : ''; $address_status = isset($posted["address_status"]) ? $posted["address_status"] : ''; $payer_id = isset($posted["payer_id"]) ? $posted["payer_id"] : ''; $tax = isset($posted["tax"]) ? $posted["tax"] : ''; $address_street = isset($posted["address_street"]) ? $posted["address_street"] : ''; $payment_date = isset($posted["payment_date"]) ? $posted["payment_date"] : ''; $payment_status = isset($posted["payment_status"]) ? $posted["payment_status"] : ''; $charset = isset($posted["charset"]) ? $posted["charset"] : ''; $address_zip = isset($posted["address_zip"]) ? $posted["address_zip"] : ''; $mc_shipping = isset($posted["mc_shipping"]) ? $posted["mc_shipping"] : ''; $mc_handling = isset($posted["mc_handling"]) ? $posted["mc_handling"] : ''; $first_name = isset($posted["first_name"]) ? $posted["first_name"] : ''; $address_country_code = isset($posted["address_country_code"]) ? $posted["address_country_code"] : ''; $address_name = isset($posted["address_name"]) ? $posted["address_name"] : ''; $notify_version = isset($posted["notify_version"]) ? $posted["notify_version"] : ''; $payer_status = isset($posted["payer_status"]) ? $posted["payer_status"] : ''; $business = isset($posted["business"]) ? $posted["business"] : ''; $address_country = isset($posted["address_country"]) ? $posted["address_country"] : ''; $num_cart_items = isset($posted["num_cart_items"]) ? $posted["num_cart_items"] : ''; $mc_handling1 = isset($posted["mc_handling1"]) ? $posted["mc_handling1"] : ''; $address_city = isset($posted["address_city"]) ? $posted["address_city"] : ''; $verify_sign = isset($posted["verify_sign"]) ? $posted["verify_sign"] : ''; $payer_email = isset($posted["payer_email"]) ? $posted["payer_email"] : ''; $mc_shipping1 = isset($posted["mc_shipping1"]) ? $posted["mc_shipping1"] : ''; $tax1 = isset($posted["tax1"]) ? $posted["tax1"] : ''; $txn_id = isset($posted["txn_id"]) ? $posted["txn_id"] : ''; $payment_type = isset($posted["payment_type"]) ? $posted["payment_type"] : ''; $last_name = isset($posted["last_name"]) ? $posted["last_name"] : ''; $address_state = isset($posted["address_state"]) ? $posted["address_state"] : ''; $item_name1 = isset($posted["item_name1"]) ? $posted["item_name1"] : ''; $receiver_email = isset($posted["receiver_email"]) ? $posted["receiver_email"] : ''; $quantity1 = isset($posted["quantity1"]) ? $posted["quantity1"] : ''; $receiver_id = isset($posted["receiver_id"]) ? $posted["receiver_id"] : ''; $pending_reason = isset($posted["pending_reason"]) ? $posted["pending_reason"] : ''; $txn_type = isset($posted["txn_type"]) ? $posted["txn_type"] : ''; $mc_gross_1 = isset($posted["mc_gross_1"]) ? $posted["mc_gross_1"] : ''; $mc_currency = isset($posted["mc_currency"]) ? $posted["mc_currency"] : ''; $residence_country = isset($posted["residence_country"]) ? $posted["residence_country"] : ''; $test_ipn = isset($posted["test_ipn"]) ? $posted["test_ipn"] : ''; $receipt_id = isset($posted["receipt_id"]) ? $posted["receipt_id"] : ''; $ipn_track_id = isset($posted["ipn_track_id"]) ? $posted["ipn_track_id"] : ''; $IPN_status = isset($posted["IPN_status"]) ? $posted["IPN_status"] : ''; $cart_items = isset($posted["cart_items"]) ? $posted["cart_items"] : ''; /** * At this point you can use the data to generate email notifications, * update your local database, hit 3rd party web services, or anything * else you might want to automate based on this type of IPN. */ }
PayPal IPN WordPress Developer Hooks
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.
When a hook retrieves information from IPN messages for a given purchase started by a specific customer, how is the right association customer x transaction secured in an automated back-end solution? If we have two customers with two orders arriving to the listener within a short time lapse, how the listener will pass the right posted info to the right customer? I am working a solution for customized downloads of files, not previously stored but rather created during a customer session, and I was wondering how this match IPN message x customer works
Not sure I’m understanding what you’re doing fully, but the order ID would be available in the IPN data, so you could then pull out any related customer data you need to from WC based on the related order ID.
I might ask a stupid question: exactly where should we write the hook?
The hook would go in your theme’s functions.php file (which is recommended to do through a child theme) or in a simple plugin file of your own.
please i need complete workink example for any hook
This developer guide includes a hook function template, and then our hook guide will provide all the different hooks you can use. Do you have any specific questions about these guides?
Hi, I’ve written the capture-all-hook in my theme’s child fuction.php, but after making payment via paypal no hook is been called, do i redirect back to the main website to capture the hook?
IPN will trigger without any redirect back to the site. Is the IPN data showing up in the general PayPal IPN list in your WP admin panel?
Hello Andrew,
Sorry for a dumb question: is this kind of thing sufficient, in terms of interacting with the plugin, the IPN, and WP ?
function subscription_expired ($posted) {
$payer_email = $posted[‘payer_email’] ;
// etc.
// update my DB, etc.
} add_action(‘paypal_ipn_for_wordpress_txn_type_subscr_eot’, ‘subscription_expired’, 10, 1) ;
Thank you!
Yes, that should do it. However, make sure you’re running the latest version of our plugin, 1.1.1, because we had a bug in subscription IPNs before that release.
Hi ipn tests not showing in admin only in log. Hook is not executing. Does it need to be live?
Any IPN that ever hits your listener provided by our plugin should be showing up in the admin panel list if it’s in the log. Then any hooks you have should trigger and do whatever you’ve done within those functions. If that doesn’t seem to be working as expected please submit a ticket here and we’ll get you taken care of.
I am using the web_accept since I have a buy now button. I get most of the information from a purchase but not the item! I am using your code above. Where should I see the item or is there an error in my button code (generated on Paypal’s site and working fine). Is there a variable I am missing?
You would need to make sure item details are included in the original payment request to PayPal. Can you provide a copy of your button code so I can review it?
Hey!, sorry if this is an dumb question, I need to send an automated email after a payment goes through paypal, how would I go about to do this?
I know that the line $payer_email = $posted [‘payer_email’] to get the payer’s email.
But I’m not able to write the rest of the code as I’m not familiar with this language.
Can you help me please?
We can help you with that, but we would need to ask you to submit an order for premium support. We can do a phone Google Meet where I can show you how this is done, and make it work for you on your site the way you need.
Hi, I’m using the shortcode for displaying all transactions but it does not appear like in your example, with pagination and search etc. I created a separate admin page and just used the shortcode. What am I missing?
What are you seeing when you use the shortcode? Are you sure you have enough records being returned so that pagination would be necessary?
I have had this running on my site for some time but just this morning, a customer made three (successful) attempts to pay for something without it getting back to the website or showing up in my IPN list or making the necessary updates to the database.
After speaking to him, I refunded two of the payments on Paypal and made the adjustments manually. The refunds showed up on the IPN even though the original payment did not, and I’m at a loss to guess why!
Do you have logging enabled in the plugin settings? The raw log file would show any data that was ever sent to it, so we’d need to check that first. Also, the PayPal IPN History would be helpful. It would show any IPNs that were sent which failed, for example.
Your plugin looks like it could help me. I’m using Gravity Forms to capture an “order” from a customer for a service. No need for Woocommerce or any other product system since my needs are so simple. I use PayPal for all payments which include one-time pay-in-full, subscriptions, and deposits (down payments). So while Gravity Forms has all my customer and order info, it does not capture IPN data – at least not for subscriptions. So what I think would work is to use your plugin and store the records in WP – either in a custom post or in a database table. Then I would have a repository or a stream of all transactions that I could view. I might go a step further and tie those transactions back to an order. Just not sure I need to make that effort. Does this seem like a plausible use case for your plugin? Any suggestions?
Hi Tim,
Yes, that’s exactly what our plugin would do. All IPN data sent from PayPal would be saved in the PayPal IPN custom post type that our plugin adds. The plugin provides hooks for you to trigger functions to process the data however you need. I think it will give you exactly what you’re looking for.
Let me know if you have any questions or concerns about that. Thanks!
Hi Drew,
any plans to make this great plugin PHP 8 compatible?
After upgrading to PHP8 and receiving the “PayPal Instant Payment Notification Warning”, we found out it’s because this plugin has problems with PHP8, where some significant backward-incompatible changes (like the implode function) was made.
As a fallback, we switched to PHP 7.4, just wanted to know what’s the status of this upgrade on your side? Anyhow on the backlog maybe?
Best,
Tom
Hi Tom,
I’m creating a ticket for this in our Help Desk and I’ll get you linked to it so that when we have this update completed you’ll be notified. We’ll get it done ASAP based on user demand and priority with our other stuff, but it shouldn’t be too long. Thanks for the feedback!
Drew
Hi,
Once a student pays the exam registration fee (using PayPal), I want to trigger a purchase event and pass the transaction data to the Data Layer that I can send from GTM to GA4.
How can use your plugin to achieve my objective?
First, how is your PayPal payment side integrated? Is it using the new REST API, or is it built with the original HTML or NVP/SOAP integrations that PayPal provides? IPN was built for the original stuff. If you’re using REST you should probably check PayPal Webhooks instead, and we have a separate plugin for that.
In either case, the plugins allow you to set your WP site as a listener/handler for IPN or Webhooks. When those events are triggered it sends all of the event data to the URL you provide. The plugin gives you hooks that make it easy for you to run your own code based on which event was triggered.
Let me know if you have any questions or concerns about that.
Thanks!
Drew