Description
The gform_stripe_payment_element_initial_payment_information filter allows the initial payment information used to render the payment element to be overridden.
Usage
1 | add_filter( 'gform_stripe_payment_element_initial_payment_information' , 'your_function_name' , 10, 3 ); |
Parameters
- $charge_meta array
The initial payment information.
- $feed Feed Object
The feed object currently being processed.
- $form Form Object
The Form which is currently being processed.
Examples
1. Allow setup_future_usage for products and services.
The following example shows how you can attach a payment method to a customer by setting setup_future_usage to off_session while rendering the stripe payment element field, note that you also need to use the gform_stripe_charge_pre_create filter along with this filter to accomplish that.
1 2 3 4 5 6 7 8 | add_filter( 'gform_stripe_payment_element_initial_payment_information' , function ( $intent_information , $feed , $form ) { gf_stripe()->log_debug( __METHOD__ . '(): Adding setup_future_usage payment intent for feed ' . rgars( $feed , 'meta/feedName' ) ); $intent_information [ 'setup_future_usage' ] = 'off_session' ; return $intent_information ; }, 10, 3 ); |
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This hook was added in Stripe version 5.2.
Source Code
1 | $intent_information = apply_filters( 'gform_stripe_payment_element_initial_payment_information' , $intent_information , $feed , $form ); |
This hook is located in GF_Stripe_Payment_Element::get_initial_payment_information() in class-gf-payment-element.php.