The gform_paypal_post_ipn action is triggered after a PayPal IPN (Instant Payment Notification) 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.
More information
See Gravity Forms Docs: gform_paypal_post_ipn
Examples
Update Order Status in a Third-Party Service
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 the order ID from $entry $order_id = $entry['id']; // Use a fictional function to update the order in the fictional third-party application mtp_update_order($order_id, $ipn_post); }
Delete Post When Subscription Term Ends
This 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 the post if this is the end of the 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.