Gravity Form notification on stripe authorization event

Does someone have custom php code that causes gravity form to send a notification on a stripe authorization only event?

The “problem” we have right now is that we’re using stripe checkout with “form completed” notification event but we have the add_filter(
‘gform_stripe_charge_authorization_only’, ‘__return_true’ ) filter enabled. If someone completes the form and submits payment properly all is good! BUT if someone completes the form and then clicks the ‘back’ button in the stripe checkout the notification event will still fire even though the payment wasn’t authorized. And because we have the authorization only event enabled if we switch to the “payment completed” event a notification this will solve the ‘back’ button issue but it will only fire once we manually accept a payment (which we don’t want). So we are really looking for a filter that causes gravity form to send a notification only once stripe authorization event is successful.

Hello. You can create your own custom notification event. See the documentation here:

Because Gravity Forms Stripe does not listen for the authorization event specifically, you will need to add that using the gform_stripe_webhook filter:

Then, you will need to determine which event to listen for from Stripe. I belive it is issuing_authorization.created but you will want to verify that with Stripe, or by enabling Gravity Forms logging for the Stripe add-on, and testing a submission with authorization only.

Documentation for enabling logging:

Here’s a screenshot of the Stripe webhook event I believe it should be:

When you receive that authorization event, send your custom notification. That way, the notification won’t be sent on form submission, and it won’t be sent on payment received either.

I wrote this code after reading the mentioned articles, but it didn’t work. Can you please tell me what I am doing wrong?

add_filter( 'gform_notification_events', function ( $notification_events, $form ) {
    $has_stripe_feed            = function_exists( 'gf_stripe' ) ? gf_stripe()->get_feeds( $form['id'] ) : false;
    if ( $has_stripe_feed ) {
        $payment_events = array(
            'complete_payment'          => __( 'Payment Completed', 'gravityforms' ),
            'complete_authorization'     => __( 'Payment Authorized', 'gravityforms' ),
            'refund_payment'            => __( 'Payment Refunded', 'gravityforms' ),
            'fail_payment'              => __( 'Payment Failed', 'gravityforms' ),
            'add_pending_payment'       => __( 'Payment Pending', 'gravityforms' ),
            'void_authorization'        => __( 'Authorization Voided', 'gravityforms' ),
            'create_subscription'       => __( 'Subscription Created', 'gravityforms' ),
            'cancel_subscription'       => __( 'Subscription Canceled', 'gravityforms' ),
            'expire_subscription'       => __( 'Subscription Expired', 'gravityforms' ),
            'add_subscription_payment'  => __( 'Subscription Payment Added', 'gravityforms' ),
            'fail_subscription_payment' => __( 'Subscription Payment Failed', 'gravityforms' ),
        );
 
        return array_merge( $notification_events, $payment_events );
    }
    return $notification_events;
}, 10, 2 );
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 'issuing_authorization.created':
 
            $action['type']     = 'complete_authorization';
 
            break;
    }
 
    return $action;
}
add_action( 'gform_post_payment_callback', function ( $entry, $action ) {
    $form = GFAPI::get_form( $entry['form_id'] );
    GFAPI::send_notifications( $form, $entry, rgar( $action, 'type' ) );
}, 10, 3 );