gform_stripe_charge_authorization_only

gform_stripe_charge_authorization_only

DescriptionUsageParametersExamples1. Apply to all product and service feeds2. Apply to a specific feedPlacementSinceSource Code

Description

The gform_stripe_charge_authorization_only filter allows authorization only transactions by preventing the capture request from being made after the entry has been saved.

Usage

The hook which would run for all Stripe product and service feeds can be used like so:

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

Parameters

$authorization_only bool
Defaults to false; return true to prevent payment being captured.

$feed Feed Object
The feed object currently being processed.

$submission_data Submission Data
Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values and any discounts from coupons.

$form Form Object
The Form which is currently being processed.

$entry Entry Object
The entry from which the subscription was created.

Examples

1. Apply to all product and service feeds

add_filter( 'gform_stripe_charge_authorization_only', '__return_true' );

2. Apply to a specific feed

The following example shows how you can delay the subscription cancellation for a specific feed by checking the feed name.

add_filter( 'gform_stripe_charge_authorization_only', 'stripe_charge_authorization_only', 10, 2 );
function stripe_charge_authorization_only( $authorization_only, $feed ) {
$feed_name = rgars( $feed, 'meta/feedName' );
if ( $feed_name == 'your feed name here' ) {
return true;
}

return $authorization_only;
}

Placement

Your code snippet should be placed in the functions.php file of your active theme.

Since

This hook was added in Stripe version 2.1.

Source Code

$authorization_only = apply_filters( 'gform_stripe_charge_authorization_only', false, $feed, $submission_data, $form, $entry );

This hook is located in GFStripe::capture() in class-gf-stripe.php.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注