Scenario: We have an order form where a user selects a product, then chooses a shipping method, enters their address and credit card details. If the user has chosen a product and entered their card details, but neglected to enter a shipping method, then the form will fail validation and return the user to the form to select the correct shipping method and resubmit.

The problem is that the authorizenetwebform_process() still make the call to Authorize.net and because all the authorize.net fields are correctly filled out, charges the card. So when the customer resubmits their order, the charge goes through twice.

Filing this as Critical as it can result in customers losing money, which is pretty serious business for an eCommerce module.

Fix is to check to see if there are any errors buffered for the form at the top of authorizenetwebform_process() and bail out if there are. As anwf_process is called as part of the "additional processing" then we have access to any errors that the native FormAPI components have thrown.

Fix:

function authorizenetwebform_process($step, $node, $form, $form_state) {
  module_load_include('inc', 'authorizenetwebform', '/authorizenetwebform_fields');
  $form_values = $form_state['values'];

+  // DO NOT forward to Authorize.net if there are errors in the form validation
+  if(form_get_errors()) {
+   return $form_state;
+  }
...

Comments

obsidiandesign’s picture

garethsprice - thanks for bringing this to my attention - one question about workflow as a result: in your experience, does anwf_process fire BEFORE validation is completed by the webform module? It would seem, to me at least, that 'Additional Validation' and 'Additional Processing' should happen AFTER webform does its thing - or does it happen regardless of what webform does (hence your patch)? This will help me understand the root issue (module weight, possibly?) in addition to implementing your patch.

Bryan O'Shea
Obsidian Design

garethsprice’s picture

Hi Bryan,

You're correct, "Additional Processing" fires *after* the validation is complete, so the form error buffer contains all the FormAPI errors.

"Additional Processing" will always execute, it is NOT stopped from executing if any FormAPI errors were encountered.

As anwf_process currently executes the curl request to authorize.net without doing any error checking beforehand then this is why it is charging the card in a situation where the credit card details are present but there are other errors on the form (then when the user corrects their error and resubmits, they get charged again - oops).

The patch adds a check to the top of anwf_process which prevents it from contacting authorize.net if any of the components on the form have thrown an error condition.

Gareth.

obsidiandesign’s picture

Hi Gareth,

Thanks for clearing this up - I will definitely get it incorporated ASAP.

Bryan O'Shea
Obsidian Design

obsidiandesign’s picture

Status: Active » Fixed

Committed - thanks again for bringing this up!

Bryan O'Shea
Obsidian Design

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.