The PayPal IPN WordPress plugin is a foundation for building tools that automate tasks when transactions hit your PayPal account.  It is easily extendable using a wide variety of developer hooks that can be used to trigger functions within your own plugins or themes when PayPal sends an IPN to your WordPress site. If you have not already done so you may want to review our PayPal IPN WordPress Install and Setup Guide.

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"]]

 

PayPal IPN WordPress Shortcodes List

PayPal IPN WordPress Shortcodes List

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
A basic list of the transaction variables that were sent in the PayPal IPN notification is displayed in the IPN post details page.  This gives you a quick reference for what exactly is available in the IPN data. WordPress PayPal IPN Variables
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

Browse our list of hooks to use for extending the PayPal IPN WordPress plugin.

Looking for Live Help?

Schedule a live meeting with Drew Angell, PayPal Certified Developer, and get all of your questions or concerns answered.