Using Gravity Forms ‘gform_post_payment_status’ PHP filter

The gform_post_payment_status action is triggered after an entry’s payment status has been updated and the payment was made using the PayPal Standard Add-on.

Usage

add_action('gform_post_payment_status', 'your_function_name', 10, 8);

Parameters

  • $feed (Feed Object): The PayPal configuration feed used to generate the transaction.
  • $entry (Entry Object): The entry from which the transaction was originally generated.
  • $status (string): The new payment status for this transaction.
  • $transaction_id (string): The PayPal transaction ID for this transaction.
  • $subscriber_id (integer): The PayPal subscriber ID for this transaction. Will be empty if the transaction is a one-time payment.
  • $amount (float): The amount of the transaction.
  • $pending_reason (string): If the payment status is set to “Pending”, the reason will be passed in this variable.
  • $reason (string): If the payment status is set to “Reversed”, “Refunded”, or “Canceled_Reversal” the reason for this change will be provided in this variable.

More information

See Gravity Forms Docs: gform_post_payment_status

Examples

Notify admin when payment is completed or a special case

This example sends an email notification to the site admin when a payment is completed or there is an issue with the payment (refunded, reversed, or canceled reversal).

add_action('gform_post_payment_status', 'admin_payment_notification', 10, 8);

function admin_payment_notification($feed, $entry, $status, $transaction_id, $subscriber_id, $amount, $pending_reason, $reason) {
    $admin_email = get_bloginfo('admin_email');

    if ($status == 'Completed') {
        wp_mail($admin_email, 'Payment Successful!', 'Message about the successful payment');
    } elseif ($status == 'Refunded' || $status == 'Reversed' || $status == 'Canceled_Reversal') {
        wp_mail($admin_email, "Payment $status", "There was an issue with this payment: $reason");
    }
}

Place this code in the functions.php file of your active theme.