Description
The gform/stripe/elements/config/ filter allows for filtering the Stripe Elements configuration object before it is used to create Stripe Elements without a Payment Intent or Setup Intent.
Usage
Asynchronous
Use this method when the function handling this event is asynchronous. This is useful when performing tasks that involve async operations, such as AJAX requests.
gform.utils.addAsyncFilter( 'gform/stripe/elements/config/', async ( elementsConfig ) => {
// Custom logic here.
return elementsConfig;
} );
Parameters
| Name | Type | Description |
|---|---|---|
| elementsConfig | Object | The Stripe Elements configuration object used to create Elements without an Intent. |
Examples
Log the elements config object to the console
gform.utils.addAsyncFilter( 'gform/stripe/elements/config/', async ( elementsConfig ) => {
console.log( 'Elements Config:', elementsConfig ); // Logs the elements configuration object.
// Your custom logic.
return elementsConfig; // Return the modified elements configuration object.
} );
Attach payment method to the customer
gform.utils.addAsyncFilter( 'gform/stripe/elements/config/', async ( elementsConfig ) => {
// Set setup_future_usage parameter to off_session to save the payment method.
elementsConfig['setupFutureUsage'] = 'off_session';
return elementsConfig; // Return the modified elements configuration object.
} );
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in assets/js/src/theme/elements/stripe-api.js.
Since
This filter was added in Gravity Forms Stripe Add-On 7.0.0