Duplicate Transactions with Authorize Net Plugin for Gravity Forms

Are you having a problem with customers refreshing the form and submitting duplicate transactions with the Authorize Net Gravity Forms plugin?

Several things are going on including the plugin sends a unique invoice number if you don’t supply one. This one feature completely nullifies the built in duplicate transaction check by Authorize.net because a unique invoice number is recognized as a unique transaction regardless of the other fields. So if possible, include a unique invoice number for the transaction.¬†But if not, try this.

Put this in your functions.php file in your theme.

add_filter('gform_authorizenet_before_single_payment','increase_duplicate_window',10,2);
function increase_duplicate_window($transaction,$form_data){
$transaction->duplicate_window = '28800'; // max window of 8 hours
$transaction->invoice_num = date('ymd').'_'.$form_data['email'];// replace unique number
return $transaction;
}
add_filter('gform_authorizenet_validation_message','add_duplicate_transaction_message',10,5);
function add_duplicate_transaction_message($error_message, $validation_result, $post, $response, $type ){
if ($type == 'aim' && $response->response_reason_code == 11){
return 'This looks like a duplicate transaction. If this transaction should be submitted, either try again in 8 hours or contact us for assistance.';
}
}

This creates an 8 hour window for duplicate transaction blocking by Authorize.net (8 hours in seconds). Lower accordingly to suit your needs. This is the max number of seconds allowed.

It also replaces the unique invoice number with one that is only unique for the day and for that customer using a combination of the date and email.

It also adds a duplicate transaction error message to the standard messages returned. (The plugin doesn’t have a specific message for duplicates. Apparently because they never have any… )

Please note there is a 20 character limit to the invoice number so your concatenated data will likely be truncated to 20 characters.