bookmark_bordergform_authorizenet_subscription_pre_create

Description

This filter can be used to modify the subscription object before it is sent to Authorize.net.

Usage

The filter which would run for all ‘subscription’ type Authorize.net feeds can be used like so:

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

Parameters

  • $subscription object

    The Authorize.net subscription object.

  • $form_data Form Data

    An associative array containing the form title, billing address, payment amount, setup fee amount, line items created using the submitted pricing field values and any discounts from coupons.

  • $config Authorize.net Config

    The feed which is currently being processed.

  • $form

    The form which is currently being processed.

  • $entry Entry Object

    The entry which is currently being processed. Since version 2.1.8.

Examples

1. Change startDate

The following example shows how you can set the start date. Please note Authorize.net requires the startDate be in the YYYY-MM-DD format.

add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $form_data, $config, $form, $entry ) {
    $subscription->startDate = rgar( $entry, '10' );

    return $subscription;
}, 10, 5 );

Placement

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

Source Code

This filter is located in GFAuthorizeNet::subscribe() in class-gf-authorizenet.php