Using Gravity Forms ‘ gform_paypal_ipn_{transaction_type}’ PHP action

The gform_paypal_ipn_{transaction_type} action hook allows you to perform actions for a specific PayPal Instant Payment Notification (IPN) transaction type.

Usage

add_action('gform_paypal_ipn_{transaction_type_to_use}', 'your_function_name', 10, 10);

Parameters

  • $entry (Entry Object) – The current entry.
  • $feed (Feed Object) – The current feed.
  • $status (string) – The status of the transaction (e.g., completed, reversed, processed, pending, refunded).
  • $txn_type (string) – The transaction type (e.g., cart, subscr_payment, subscr_cancel).
  • $transaction_id (int) – The transaction ID.
  • $parent_txn_id (int) – The parent transaction ID (for transactions like refunds).
  • $subscriber_id (int) – The subscriber ID.
  • $amount (string) – The payment amount.
  • $pending_reason (string) – The pending reason if the payment status is “Pending.”
  • $reason (string) – The reason code.

More information

See Gravity Forms Docs: gform_paypal_ipn_{transaction_type}

Examples

Add a note for cart transactions

This example adds a note to the entry when a cart transaction occurs.

add_action('gform_paypal_ipn_cart', 'create_note', 10, 10);

function create_note($entry, $feed, $status, $txn_type, $transaction_id, $parent_txn_id, $subscriber_id, $amount, $pending_reason, $reason) {
    GFFormsModel::add_note($entry['id'], 0, 'PayPal', 'Cart transaction occurred.', '');
}

Change entry status for subscription cancellations

This example changes the entry status to “Cancelled” when a subscription is cancelled.

add_action('gform_paypal_ipn_subscr_cancel', 'update_entry_status', 10, 10);

function update_entry_status($entry, $feed, $status, $txn_type, $transaction_id, $parent_txn_id, $subscriber_id, $amount, $pending_reason, $reason) {
    GFAPI::update_entry_property($entry['id'], 'status', 'Cancelled');
}

Send an email when a subscription payment is processed

This example sends an email to the site administrator when a subscription payment is processed.

add_action('gform_paypal_ipn_subscr_payment', 'send_subscription_email', 10, 10);

function send_subscription_email($entry, $feed, $status, $txn_type, $transaction_id, $parent_txn_id, $subscriber_id, $amount, $pending_reason, $reason) {
    $subject = 'Subscription Payment Processed';
    $message = 'A subscription payment has been processed. Transaction ID: ' . $transaction_id;
    wp_mail(get_option('admin_email'), $subject, $message);
}