gform_{$short_slug}_is_valid_payment_amount

Description

This filter allows custom logic to be used to determine if a payment add-on which extends GFPaymentAddOn should process the submission for the given amount.

Short Slug Values

The Gravity Forms Add-On Slugs article lists the available short slugs to use with this hook.

Usage

The base filter which would run for all forms and all fields would be used like so:

add_filter( 'gform_stripe_is_valid_payment_amount', 'your_function_name', 10, 5 );

To target a specific form append the form id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID)

add_filter( 'gform_stripe_is_valid_payment_amount_10', 'your_function_name', 10, 5 );

Parameters

ParameterTypeDescription
$is_validboolIndicates if the amount is valid for processing. Default is true when the amount is greater than zero.
$submission_dataObjectContains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values, and any discounts from coupons.
$feedFeed ObjectThe feed to be processed.
$formForm ObjectThe form currently being processed.
$entryEntry ObjectThe temporary entry containing the submitted values.

Examples

1. PayPal custom minimum amount

This example shows how you can prevent the add-on proccessing submissions where the amount is less than $1.

add_filter( 'gform_stripe_is_valid_payment_amount', function( $is_valid, $submission_data ) {
    return floatval( $submission_data['payment_amount'] ) > 1;
}, 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 Gravity Forms 2.4.18.

Source Code

$tag_args = array( sprintf( 'gform_%s_is_valid_payment_amount', $this->get_short_slug() ), $form_id );
$is_valid = (bool) gf_apply_filters( $tag_args, $is_valid, $submission_data, $feed, $form, $entry );

This filter is located in GFPaymentAddOn::is_valid_payment_amount() in includes/addon/class-gf-payment-addon.php.