Using Gravity Forms ‘gform_stripe_webhook_signing_secret’ PHP filter

The gform_stripe_webhook_signing_secret Gravity Forms PHP filter allows you to modify the webhook signing secret for the specified API mode in the Gravity Forms Stripe Add-On.

Usage

add_filter('gform_stripe_webhook_signing_secret', 'your_function_name', 10, 3);

Parameters

  • $signing_secret (string): The signing secret to be used when validating received webhooks.
  • $mode (string): The API mode; live or test.
  • $gfstripe (object): GFStripe class object.

More information

See Gravity Forms Docs: gform_stripe_webhook_signing_secret

Examples

Change signing secret based on API mode

This example demonstrates how to change the webhook signing secret based on the API mode (live or test).

add_filter('gform_stripe_webhook_signing_secret', 'change_secret', 10, 3);

function change_secret($signing_secret, $mode, $gfstripe){
    if ($mode == 'test'){
        return '1234567890';
    } else {
        return '222222222';
    }
}

Update signing secret using an option

This example demonstrates how to update the webhook signing secret using a WordPress option.

add_filter('gform_stripe_webhook_signing_secret', 'update_secret_from_option', 10, 3);

function update_secret_from_option($signing_secret, $mode, $gfstripe){
    $new_secret = get_option('my_custom_stripe_secret');
    return $new_secret;
}

Modify signing secret for live mode only

This example demonstrates how to modify the webhook signing secret only for the live API mode.

add_filter('gform_stripe_webhook_signing_secret', 'modify_live_secret', 10, 3);

function modify_live_secret($signing_secret, $mode, $gfstripe){
    if ($mode == 'live'){
        return 'new_live_secret';
    }
    return $signing_secret;
}

Add a prefix to the signing secret

This example demonstrates how to add a prefix to the webhook signing secret.

add_filter('gform_stripe_webhook_signing_secret', 'add_secret_prefix', 10, 3);

function add_secret_prefix($signing_secret, $mode, $gfstripe){
    return 'prefix_' . $signing_secret;
}

Modify signing secret using a custom function

This example demonstrates how to modify the webhook signing secret using a custom function.

add_filter('gform_stripe_webhook_signing_secret', 'custom_function_modify_secret', 10, 3);

function custom_function_modify_secret($signing_secret, $mode, $gfstripe){
    // your custom code here
    $modified_secret = your_custom_function($signing_secret);
    return $modified_secret;
}