bookmark_bordergform_post_payment_action

Description

This action hook can be used to perform custom actions after processing of the following payment events has occurred:

  • complete_payment
  • refund_payment
  • fail_payment
  • add_pending_payment
  • void_authorization
  • create_subscription
  • cancel_subscription
  • expire_subscription
  • add_subscription_payment
  • fail_subscription_payment
  • fail_create_subscription

Usage

This action hook which would run for all payment add-on feeds can be used like so:

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

Parameters

  • $entry Entry Object

    The entry for which the payment event occurred.

  • $action array

    An associative array containing the event details.

        $action = array(
            'type'             => '',
            'amount'           => '',
            'transaction_type' => '',
            'transaction_id'   => '',
            'subscription_id'  => '',
            'entry_id'         => '',
            'payment_status'   => '',
            'note'             => '',
        );
    

Examples

1. Send Event Notification

The following example shows how you can trigger the sending of form notifications registered for the event. See the Send notifications on payment events article for a more detailed tutorial.

add_action( 'gform_post_payment_action', function ( $entry, $action ) {
    $form = GFAPI::get_form( $entry['form_id'] );
    GFAPI::send_notifications( $form, $entry, rgar( $action, 'type' ) );
}, 10, 2 );

Placement

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

Source Code

do_action( 'gform_post_payment_action', $entry, $action );

This action hook is located in GFPaymentAddOn::post_payment_action() in includes/addon/class-gf-payment-addon.php

Since

This filter was added in Gravity Forms 1.9.10.21