The gform_authorizenet_post_create_subscription action hook has been deprecated. Use the gform_post_subscription_started hook instead.
Author 诗语
gform_authorizenet_post_expire_subscription
The gform_authorizenet_post_expire_subscription action hook has been deprecated. Use the gform_post_payment_action hook instead.
gform_authorizenet_post_recurring_payment
The gform_authorizenet_post_recurring_payment action hook has been deprecated. Use the gform_post_payment_transaction hook instead.
gform_authorizenet_post_suspend_subscription
The gform_authorizenet_post_suspend_subscription action hook has been deprecated. Use the gform_post_payment_action hook instead.
gform_authorizenet_subscription_canceled
The gform_authorizenet_subscription_canceled action hook has been deprecated. Use the gform_post_payment_action hook instead.
gform_authorizenet_subscription_ended
The gform_authorizenet_subscription_ended action hook has been deprecated. Use the gform_post_payment_action hook instead.
gform_authorizenet_subscription_pre_create
DescriptionUsageParametersExamples1. Change startDate2. Change Trial Period Cycles3. Add a Description4. Set the invoice number4. Use Name field for subscription detailsPlacementSource Code
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 Form Object
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 ) {
if ( $form['id'] != 30 ) { // Update 30 to your form id number
return $subscription;
}
$subscription->startDate = rgar( $entry, '10' );
return $subscription;
}, 10, 5 );
2. Change Trial Period Cycles
The following example shows how you can set the Trial Period Cycles. Please check the following doc page from Authorize.net to understand how they handle Trial periods: What is a Trial Period?
add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $form_data, $config, $form, $entry ) {
if ( $form['id'] != 30 ) { // Update 30 to your form id number
return $subscription;
}
$subscription->trialOccurrences = 15; // This will set a 15 days trial period if Billing Cycle is using Days
return $subscription;
}, 10, 5 );
3. Add a Description
The following example shows how you can set a description (up to 255 characters) for the subscription being created in a form with id 30. According to Authorize.net API documentation the description will be associated with each payment in the subscription.
add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $form_data, $config, $form, $entry ) {
if ( $form['id'] != 30 ) { // Update 30 to your form id number
return $subscription;
}
$subscription->orderDescription = 'This is my custom description...';
return $subscription;
}, 10, 5 );
4. Set the invoice number
This example shows how to pass an entry value as the subscription invoice number.
add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $form_data, $config, $form, $entry ) {
if ( $form['id'] != 1 ) { // Update 1 to your form id number
return $subscription;
}
GFCommon::log_debug( __METHOD__ . '(): Setting custom invoice number.' );
// Update 46 to the id number of the field containing your invoice number
$subscription->orderInvoiceNumber = rgar( $entry, '46' );
return $subscription;
}, 10, 5 );
4. Use Name field for subscription details
This example shows how to use a Name field as source for Authorize.net』s subscription details.
add_filter( 'gform_authorizenet_subscription_pre_create', function ( $subscription, $form_data, $config, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
if ( $form['id'] != 1 ) { // Update 1 to your form id number
GFCommon::log_debug( __METHOD__ . '(): Not our desired form, leaving without changes.' );
return $subscription;
}
// Set values for subscription First Name and Last Name from a name field with ID 1.
$subscription->first_name = rgar( $entry, '1.3' );
$subscription->last_name = rgar( $entry, '1.6' );
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.
gform_authorizenet_subscription_suspended
The gform_authorizenet_subscription_suspended action hook has been deprecated. Use the gform_post_payment_action hook instead.
gform_authorizenet_transaction_pre_authorize
DescriptionUsageParametersExamplesPlacementSource Code
Description
Allows the transaction to be modified before authorization occurs.
Usage
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'your_function_name', 10, 4 );
Parameters
$original_transaction AuthorizeNetAIM Object
The payment transaction.
$form_data array
Form information needed for billing.
$config array
Configuration information including feed setup with billing information.
$form Form Object
The current form object.
Examples
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'change_authorization', 10, 4 );
function change_authorization( $original_transaction, $form_data, $config, $form ){
return $original_transaction;
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAuthorizeNet::authorize() in gravityformsauthorizenet/class-gf-authorizenet.php.
gform_authorizenet_transaction_pre_capture_setup_fee
DescriptionUsageParametersExamples1. Modify the AmountPlacementSource Code
Description
This filter can be used to modify the transaction object for the subscription setup fee before it is sent to Authorize.net.
Usage
The filter which would run for all 『subscription』 type Authorize.net feeds with a setup fee can be used like so:
add_filter( 'gform_authorizenet_transaction_pre_capture_setup_fee', 'your_function_name', 10, 5 );
Parameters
$transaction object
The Authorize.net transaction 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 Form Object
The form which is currently being processed.
$entry Entry Object
The entry which is currently being processed. Since version 2.1.8.
Examples
1. Modify the Amount
The following example shows how you can override the setup fee for a specific form.
add_filter( 'gform_authorizenet_transaction_pre_capture_setup_fee', 'set_fee_amount', 10, 4 );
function set_fee_amount( $transaction, $form_data, $config, $form ) {
if ( $form['id'] == 10 ) {
$transaction->amount = 50;
}
return $transaction;
}
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