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

1. Apply to all product and service feeds

add_filter( 'gform_stripe_payment_element_authorization_only', '__return_true' );

2. Apply to a specific form

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 );

3. Apply to a specific feed

add_filter( 'gform_stripe_payment_element_authorization_only', 'stripe_charge_authorization_only', 10, 3 );
function stripe_charge_authorization_only( $result, $form, $feed ) {
	gf_stripe()->log_debug( __METHOD__ . '(): Running... ');
	$feed_name  = rgars( $feed, 'meta/feedName' );
	if ( $feed_name == 'your feed name here' ) { // Replace your feed name here with the actual feed name.
		gf_stripe()->log_debug( __METHOD__ . '(): Authorization only charge for feed ' . $feed_name );
		return true;
	}
 
	return $result;
}

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.