We have a client that wanted to be able to process donations when the Credit Card’s CVV numbers were not available. I had thought this field was mandatory, and indeed, CiviCRM’s AuthorizeNet payment processor package requires it. But after talking with AuthorizeNet (the company) we discovered that the field is optional.

This is a useful trick that fellow CivicActions team member and CiviCRM wizard Matt Chapman showed me. Basically, the hook_civicrm_validate() function can be used to reset an error caused by a missing field. Here’s the entirety of the civicrm_cvv module:

/**
* This removes the requirement for the CVV field in the credit card
* Requires Matt's patch to v3.1.6 CiviCRM core (now in 3.2.x core)
* See: http://issues.civicrm.org/jira/browse/CRM-6393
*/
function civicrm_cvv_civicrm_validate( $formName, &$fields, &$files, &$form )
return true;
}

If running CiviCRM v3.1.x (we were running v3.1.6) you’ll need to hack core to get this to work. Fortunately, the hack is small (and it’s included in CiviCRM v3.2+). See the link in the code for the patch.

The better way to do this would be to add a setting to the AuthorizNet.php package in CiviCRM that can turn the requirements of this field on or off for each place it appears. Such a patch would likely be accepted by the CiviCRM team as there’s a strong argument to be made that if the provider considers the field optional, then the interface package should not require it. But that’s for another day.

For now, the client is happy and I learned a good use of hook_civicrm_vlaidate() that may well come in handy again.