gform_stripe_payment_element_authorization_only

Description

This filter allows authorization-only transactions by preventing the capture request from being made after the entry has been saved. The payment can be captured later from the entry details page.

This filter acts like gform_stripe_charge_authorization_only, which is used for the Stripe field. Use gform_stripe_payment_element_authorization_only when enabling the payment element.

Usage

The hook, which would run for all Stripe product and service feeds, can be used like so:

add_filter( 'gform_stripe_payment_element_authorization_only', 'your_function_name', 10, 3 );

Parameters

  • $result boolean
    Indicates if the charge should be authorized rather than captured. Default is false
  • $form Form Object
    The form currently being processed.
  • $feed Feed Object
    The feed which is currently being processed.

Example

add_filter( 'gform_stripe_payment_element_authorization_only', function ( $result, $form, $feed ) {

    if( $form['id'] === 1 ) {
       return true; // This will enable authorization only.
   }

   return false; // This will automatically try to capture the payment.
}, 10, 3 );

Placement

Your code snippet should be placed in the functions.php file of your active theme, or in a custom functionality plugin.

Since

This hook was added in Stripe version 5.0.

Source Code

$authorization_only = apply_filters( 'gform_stripe_payment_element_authorization_only', false, $form, $feed );

This hook is located in GFStripe::capture() in class-gf-stripe.php.