gform_paypal_post_ipn

Description

This hook is fired after a PayPal IPN response has been processed.

Usage

add_action( 'gform_paypal_post_ipn', 'your_function_name', 10, 4) ;

Parameters

  • $_POST array

    The $_POST array posted by the PayPal IPN.

  • $entry Entry Object

    The entry from which the transaction the IPN is responding to was submitted.

  • $feed Feed Object

    The PayPal feed configuration data used to process the entry the IPN is responding to.

  • $cancel boolean

    Defaults to false. Indicates whether the IPN processing was canceled by the gform_paypal_pre_ipn hook.

Examples

This example shows how to update your order on a fictional third party order fulfillment service.

add_action( 'gform_paypal_post_ipn', 'update_order_status', 10, 4 );
function update_order_status( $ipn_post, $entry, $feed, $cancel ) {

// if the IPN was canceled, don't process
if ( $cancel )
return;

// get first and last name from $entry
$order_id = $entry['id'];

// use fictional function to add order to fictional My Third Party application
mtp_update_order( $order_id, $ipn_post );
}

The following example deletes the post associated with the entry when the subscription term ends.

add_action( 'gform_paypal_post_ipn', 'delete_post', 10, 4 );
function delete_post( $ipn_post, $entry, $feed, $cancel ) {

// if the IPN was canceled, don't process
if ( $cancel )
return;

$transaction_type = $ipn_post['txn_type'];

//delete post if this is the end of term
if ( strtolower( $transaction_type ) == 'subscr_eot' ) {
wp_delete_post( $entry['post_id'] );
}
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

do_action( 'gform_paypal_post_ipn', $_POST, $entry, $feed, true )

This hook is located in GFPayPal::can_process_ipn() in class-gf-paypal.php.