home
forum
Enlarging...
both those darned 1-pt. fonts
and sometimes supplying more
detail..
Click here to go [back] from whence you came

[PHP Code] <08-10-2005>
Authorize.net (by default) doesn't work with GoDaddy Hosting
submitted by jason

I helped someone move his website to GoDaddy hosting recently. When I did so, it turned out that his credit card processing didn't work anymore. The reason for the incompatibility of Authorize.net's code is because it 'requires' mhash to work. This is apparently not the case.. After trying to mess with PHP5's hash_hmac function for a while, I noticed an extremely helpful comment on its manual page. The result is a modification in the original Authorize.net code that worked beautifully.

Authorize.net supplied this PHP code with no warranty or "fitness for a particular purpose." Wow. That's a heck of a disclaimer. I'll see if I can top it, but *geez* if you're obviously supplying code for an obvious purpose, how can you flat out deny it? Just because you supply something but don't want someone whining when they have problems with it, you don't deny having given it to them for "a particular purpose." It strikes me as similar to my saying, "You may be reading this document's contained text ("Text"), but neither we nor anyone in our employ typed, pasted, or otherwise supplied Text with the intent to be read--whether by person, machine, or software."
  <grin>

/*
    The following hmac function is based on code originally submitted to
    PHP.net on 2006-05-10 by "eddi" and is presumably supplied under
    license of Public Domain with no implication of warranty or liability.

    Jason Brewer supplies this code with modifications as belonging to the
    Public Domain with no warranty--explicit or implied.  Jason Brewer is
    not liable or responsible for the effects of anyone's use of this code.
    Just because this code worked for Jason Brewer to make Authorize.net's
    simlib.php work with GoDaddy's Economy Hosting doesn't mean it will
    work for anyone else--at GoDaddy or elsewhere.

    SOURCE:  http://www.php.net/manual/en/function.hash-hmac.php#65968
*/
function hmac($passwd, $data)
{
    
$algo = "md5";
    /* md5 and sha1 only */
    
$algo=strtolower($algo);
    
$p=array('md5'=>'H32','sha1'=>'H40');
    if(
strlen($passwd)>64) $passwd=pack($p[$algo],$algo($passwd));
    if(
strlen($passwd)<64) $passwd=str_pad($passwd,64,chr(0));

    
$ipad=substr($passwd,0,64) ^ str_repeat(chr(0x36),64);
    
$opad=substr($passwd,0,64) ^ str_repeat(chr(0x5C),64);

    return(
$algo($opad.pack($p[$algo],$algo($ipad.$data))));
}

It looks like someone else got the same idea:
http://forums.oscommerce.com/lofiversion/index.php/t199381.html

SOURCE:
http://www.google.com/search?q=mhash+godaddy

Click here to go [back] from whence you came