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
add_filter( 'gform_stripe_payment_element_initial_payment_information', 'your_function_name', 10, 3 );
Parameter | Type | Description |
---|---|---|
$intent_information | array | The initial payment information. Reference Stripe documentation for Create a PaymentIntent. |
$feed | array | The Feed Object. |
$form | array | The Form Object. |
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.
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
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This hook was added in Stripe version 5.2.
Source Code
$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.