Using Gravity Forms ‘gform_stripe_checkout_options’ PHP filter

The gform_stripe_checkout_options Gravity Forms PHP function/filter/action is a JavaScript based filter in the Gravity Forms Stripe add-on that allows for altering the checkout options just before the Stripe checkout modal is loaded. This filter can only be used if you’re using the Stripe Checkout payment method in your Stripe add-on settings.

Note: This filter was removed in version 3.0 of the Stripe add-on. For versions 3.0 or greater, you’ll want to use the gform_stripe_session_data filter.

Usage

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    // your custom code here
    return options;
});

Parameters

  • $options (object): The Stripe Checkout options to be filtered.
  • $formId (int): The form id.

More information

See Gravity Forms Docs: gform_stripe_checkout_options

Examples

Dynamically populate the email field in the Stripe Checkout modal

This example will dynamically populate the email field in the Stripe Checkout modal with the value entered into an email field. In the snippet below, change the number 8 in {:8} to be the field ID of an email field on your form.

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    options.email = GFMergeTag.replaceMergeTags(formId, '{:8}');
    return options;
});

Change the currency for the Stripe Checkout modal

This example will change the currency for the Stripe Checkout modal to Euros (EUR).

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    options.currency = 'eur';
    return options;
});

Modify the Stripe Checkout modal title

This example will change the title displayed in the Stripe Checkout modal.

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    options.name = 'My Custom Title';
    return options;
});

Allow only specific cards

This example will allow only Visa, Mastercard, and American Express cards in the Stripe Checkout modal.

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    options.accepted_cards = ['visa', 'mastercard', 'amex'];
    return options;
});

Set a custom image for the Stripe Checkout modal

This example will set a custom image to be displayed in the Stripe Checkout modal.

gform.addFilter('gform_stripe_checkout_options', function(options, formId) {
    options.image = 'https://example.com/path/to/your/image.png';
    return options;
});

Note: Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.