I had some trouble getting Ubercart’s Authorize.net module working with a different gateway named NaviGate, provided by MerchantPlus. The NaviGate gateway supposedly works just like an Authorize.net gateway, with the same variable names and very similar API, so we’d hoped we wouldn’t run into many issues. But there was one that caused a decent amount of frustration.
The issue was related to the credit card’s expiration date every time an order was attempted. The Ubercart error message was:
Payment failed: Credit card payment declined: The credit card expiration date is invalid.
Now I was using my own personal credit card, and I’m a friggin web developer, so I’m pretty sure I had input the damn expiration date correctly! But nonetheless, I kept getting the same error messages.
After a bit of time and as the debug mindset sank deeper in, I checked the logs once again. Noticing an error logged from the uc_payment module, I checked over the string that was cURLed over to the gateway. The expiration date was sent as 1%2F2009. Ok, that seems right. The %2F of course is just a slash, no worries there.
I kept thinking about the issue, and eventually I decided to try something I’d previously written off. I though maybe, just maybe, the expiration month and must be two digits, and the year four digits. The cURL string above was using just one digit for the month.
I found the code that generates the select box in uc_store.module. I didn’t expect it to be there, but oh well. Around line 2276 (in my copy of the file at least) I found the array that’s used to build the expiry date select box.
/**
* Create a month select box for a form.
*/
function uc_select_month($title = NULL, $default = NULL) {
$select = array(
'#type' => 'select',
'#title' => (is_null($title) ? t('Month') : $title),
'#options' => array(1 => t('01 - January'), 2 => t('02 - February'), 3 => t('03 - March'),
4 => t('04 - April'), 5 => t('05 - May'), 6 => t('06 - June'),
7 => t('07 - July'), 8 => t('08 - August'), 9 => t('09 - September'),
10 => t('10 - October'), 11 => t('11 - November'), 12 => t('12 - December')),
'#default_value' => (is_null($default) ? 1 : $default),
);
return $select;
}
So I simply changed the keys to be strings at two digits each:
...
'#options' => array(
'01' => t('01 - January'),
'02' => t('02 - February'),
'03' => t('03 - March'),
'04' => t('04 - April'),
'05' => t('05 - May'),
'06' => t('06 - June'),
'07' => t('07 - July'),
'08' => t('08 - August'),
'09' => t('09 - September'),
'10' => t('10 - October'),
'11' => t('11 - November'),
'12' => t('12 - December')),
'#default_value' => (is_null($default) ? '01' : $default),
...</pre>
I also cleaned up the alignment to make it a bit easier to read, even though I'll probably never look at it again. Guess I'm kind of anal coder, but that's a good thing, right? Notice that the default value also was changed to '01', rather than 1.
This seemed to fix the issue. Live transactions worked right away!


Dillon
2009.07.27
Steve – would you be willing to share your NaviGate Gateway module? Is for UC 1 or 2?
Steve
2009.07.27
I’d be glad to share it, but there’s really no need. Navigate uses the same API as Authorize.net, so the ubercart auth.net module module works just fine, with the exception of the above: the all months need to be two digits.
The other thing you need to change is the post url to go to the correct Navigate url, rather than authorize.net.
This was for ubercart 1.
Dillon
2009.07.27
Awesome. I suspected something like that. I’ll give it a shot with UC 2 and see if what happens.