Using Gravity Forms ‘gform_stripe_webhook’ PHP filter

The gform_stripe_webhook Gravity Forms PHP filter can be used to add support for performing actions on additional Stripe events, beyond the default supported events.


add_filter( 'gform_stripe_webhook', 'your_function_name', 10, 2 );


  • $action (array): An associative array containing the event details or an empty array for unsupported event types.
  • $event (\Stripe\Event): The Stripe event object for the webhook which was received.

More information

See Gravity Forms Docs: gform_stripe_webhook


Add a new event type

The following code shows how you can add support for processing webhooks for other event types than the defaults listed above.

add_filter( 'gform_stripe_webhook', 'stripe_webhook_custom_action', 10, 2 );

function stripe_webhook_custom_action( $action, $event ) {
    $type = rgar( $event, 'type' );

    switch ( $type ) {
        case 'charge.failed':
            $action['transaction_id'] = rgars( $event, 'data/object/id' );
            $entry_id = gf_stripe()->get_entry_by_transaction_id( $action['transaction_id'] );

            if ( ! $entry_id ) {
                return new WP_Error( 'entry_not_found', sprintf( 'Entry for transaction id: %s was not found. Webhook cannot be processed.', $action['transaction_id'] ) );

            $entry = GFAPI::get_entry( $entry_id );

            $action['entry_id'] = $entry_id;
            $action['type'] = 'fail_payment';
            $action['amount'] = gf_stripe()->get_amount_import( rgars( $event, 'data/object/amount' ), $entry['currency'] );
            $action['note'] = 'Payment failed.';

    return $action;

This code adds support for processing ‘charge.failed’ event types. When the webhook for a failed charge is received, it updates the action array with the necessary information and returns it.