The gform_authorizenet_transaction_pre_authorize filter allows you to modify the transaction before authorization occurs in Gravity Forms.
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.
More information
See Gravity Forms Docs: gform_authorizenet_transaction_pre_authorize
Examples
Modify the transaction before authorization
This example demonstrates how to modify the transaction details before authorization.
add_filter('gform_authorizenet_transaction_pre_authorize', 'change_authorization', 10, 4); function change_authorization($original_transaction, $form_data, $config, $form) { // Modify the transaction details here return $original_transaction; }
Update the transaction amount
This example shows how to update the transaction amount before authorization.
add_filter('gform_authorizenet_transaction_pre_authorize', 'update_transaction_amount', 10, 4); function update_transaction_amount($original_transaction, $form_data, $config, $form) { $new_amount = 50; $original_transaction->amount = $new_amount; return $original_transaction; }
Add a custom invoice number
This example demonstrates how to add a custom invoice number to the transaction before authorization.
add_filter('gform_authorizenet_transaction_pre_authorize', 'add_custom_invoice_number', 10, 4); function add_custom_invoice_number($original_transaction, $form_data, $config, $form) { $custom_invoice_number = 'INV-' . time(); $original_transaction->invoice_num = $custom_invoice_number; return $original_transaction; }
Set a custom description
This example shows how to set a custom description for the transaction before authorization.
add_filter('gform_authorizenet_transaction_pre_authorize', 'set_custom_description', 10, 4); function set_custom_description($original_transaction, $form_data, $config, $form) { $custom_description = 'Custom Product Description'; $original_transaction->description = $custom_description; return $original_transaction; }
Modify the customer’s billing information
This example demonstrates how to modify the customer’s billing information before authorization.
add_filter('gform_authorizenet_transaction_pre_authorize', 'modify_billing_information', 10, 4); function modify_billing_information($original_transaction, $form_data, $config, $form) { $original_transaction->first_name = 'John'; $original_transaction->last_name = 'Doe'; $original_transaction->address = '123 New Street'; $original_transaction->city = 'New York'; return $original_transaction; }