PayPal WooCommerce Hooks Library

PayPal for WooCommerce provides a number of hooks so that you can interact with the plugin.  The following list displays the names of the hooks available as well as a simple sample of how to set it up.

PayPal Complete Payments Gateway Hooks

woocommerce_available_payment_gateways

Sort the PayPal Complete Payments gateway options on your checkout page.

add_filter('woocommerce_available_payment_gateways', 'sort_gateway_on_checkout_page', 10000);
function sort_gateway_on_checkout_page($gateways) { 
	if (is_checkout()) {
		$gateway_sort_order_list = ['angelleye_ppcp_cc', 'angelleye_ppcp', 'angelleye_ppcp_apple_pay', 'angelleye_ppcp_google_pay'];
		$sorted_gateways = [];
		foreach ($gateway_sort_order_list as $gateway_id) {
			if (isset($gateways[$gateway_id])) {
				$bottom_last_gateway = $gateways[$gateway_id]; 
				unset($gateways[$gateway_id]); 
				$sorted_gateways[$gateway_id] = $bottom_last_gateway;			
			}		
		}

		if (count($sorted_gateways)) {
			$gateways = array_merge($sorted_gateways, $gateways);
		}
	}
	return $gateways; 
}

PayPal Classic Gateway Hooks

PayPal Express Checkout Filter Hooks

ae_ppec_error_email_subject

Set a custom subject for the email notification that is sent to site admin when a PayPal Express Checkout API error occurs.

add_filter( 'ae_ppec_error_email_subject', 'my_subject_function', 10, 1);
function my_subject_function($subject) {
    $subject = 'This is my custom subject line.';
    return $subject;
}
ae_ppec_error_email_message

Set a custom message in the email notification that is sent to site admin when a PayPal Express Checkout API error occurs.

add_filter( 'ae_ppec_error_email_message', 'my_function', 10, 5 );
function my_function($message, $ErrorCode, $ErrorSeverityCode, $ErrorShortMsg, $ErrorLongMsg) {
    $message = "$ErrorCode - $ErrorLongMsg";
    return $message;
}
ae_ppec_error_user_display_message

Set a custom error message to be displayed back to the user when a PayPal Express Checkout API error occurs.

add_filter( 'ae_ppec_error_user_display_message', 'my_function', 10, 3 );
function my_function($error_display_type_message, $ErrorCode, $ErrorLongMsg) {
    $error_display_type_message = "Please contact us and let us know you received error code ". $ErrorCode;
    return $error_display_type_message;
}
ae_ppec_refund_error_message

Display a custom message if a PayPal Express Checkout API error occurs when refunding an order.

add_filter( 'ae_ppec_refund_error_message', 'my_error_message', 10, 3 );
function my_error_message($L_LONGMESSAGE, $L_ERRORCODE, $PayPalResult) {
    $message = "A refund error occured:". $L_ERRORCODE ."-". $L_LONGMESSAGE;
    return $message;
}
angelleye_ec_checkout_icon

Replace the logo used for Express Checkout on the WooCommerce checkout page.

add_filter('angelleye_ec_checkout_icon', 'angelleye_change_express_checkout_icon', 10, 1);
function angelleye_change_express_checkout_icon($icon_url) {
    $icon_url = '<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/cc-badges-ppmcvdam.png"
                     alt="Credit Card Badges">';
    return $icon_url;
}
ae_ppec_custom_parameter

Pass your own custom data into the PayPal CUSTOM parameter.  You can pass any value you want up to 256 characters.

add_filter('ae_ppec_custom_parameter', 'ae_ppec_custom_parameter', 10, 1);
functionae_ppec_custom_parameter($icon_url) {
    $custom_data = 'My custom data';
return $custom_data; }

PayPal Payments Pro DoDirectPayment Filter Hooks

ae_ppddp_error_email_subject

Display a custom subject for the email sent to the site admin if a PayPal Pro DoDirectPayment API error occurs.

add_filter( 'ae_ppddp_error_email_subject', 'my_custom_subject', 10, 3 );
function my_custom_subject($subject, $error_code, $long_message) {
    $subject = "This is my custom email subject for error ".$error_code;
    return $subject;
}
ae_ppddp_error_email_message

Display a custom message in the email sent to the site admin if a PayPal Pro DoDirectPayment API error occurs.

add_filter( 'ae_ppddp_error_email_message', 'my_custom_message', 10, 3 );
function angelleye_pc_error_email_notify_message_own($message, $error_code, $long_message) {
    $message = "The error was". $error_code ."-". $long_message;
    return $message;
}
ae_ppddp_error_user_display_message

Display a custom message to the user when a PayPal Payments Pro DoDirectPayment API error occurs.

add_filter( 'ae_ppddp_error_user_display_message', 'my_custom_message', 10, 3 );
function angelleye_pc_display_type_notice_own($pc_display_type_notice, $error_code, $long_message) {
    $my_custom_message = "Please contact us and let us know you received error ". $error_code;
    return $my_custom_message;
}
ae_ppddp_refund_error_message

Display a custom message if a PayPal Payments Pro DoDirectPayment API error occurs when refunding an order.

add_filter( 'ae_ppddp_refund_error_message', 'my_custom_error_message', 10, 3 );
function my_custom_error_message($L_LONGMESSAGE, $L_ERRORCODE, $PayPalResult) {
    $message = "When refunding, the error ". $L_ERRORCODE ." occurred.";
    return $message;
}

PayPal Payments Pro PayFlow Filter Hooks

ae_pppf_custom_parameter

Add data into the COMMENT1 field available in the PayPal Manager (PayFlow) account transaction details.

add_filter( 'ae_pppf_custom_parameter', 'own_ae_pppf_custom_parameter', 10, 2);
function own_ae_pppf_custom_parameter($customer_note , $order) {
    return $order->get_order_number();
}
ae_pppf_comment2_parameter

Add data into the COMMENT2 field available in the PayPal Manager (PayFlow) account transaction details.

add_filter( 'ae_pppf_comment2_parameter', 'own_ae_pppf_comment2_parameter', 10, 2);
function own_ae_pppf_comment2_parameter($empty, $order) {
    return 'My Website';
}