Description
The gform_stripe_api_mode
filter in the Gravity Forms Stripe Add-On allows the API mode to be set to “live” or “test”.
Usage
add_filter( 'gform_stripe_api_mode', 'your_function_name', 10, 2);
Parameters
- $api_mode string
The API mode. Possible values areÂlive
 orÂtest
. - $feed_id int
Determines the context in which the API mode is applied. WhenÂnull
, the global connection settings apply. When specified, the API mode applies to the feed-specific connection.
Examples
Set Live mode globally.
add_filter( 'gform_stripe_api_mode', function ( $api_mode, $feed_id ) {
return 'live';
}, 10, 2 );
Set Live mode for a specific feed_id.
add_filter( 'gform_stripe_api_mode', function ( $api_mode, $feed_id ) {
if ( $feed_id === 521 ) {
return 'live';
}
return $api_mode;
}, 10, 2 );
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 filter was added in Stripe version 2.0.
Source Code
This filter is located in GFStripe::get_api_mode() in gravityformsstripe/class-gf-stripe.php.