Authorize.net

Problems installing or using the NOP Design Free Shopping Cart. **ARCHIVE** Please post new topics to one of the groups below.

Moderator: scott

Authorize.net

Postby CBQ » Wed Dec 18, 2002 4:17 pm

Hi,

I'm trying to set up the shopping cart to work with a site I already designed, and the authorize.net merchant account that goes with it.

I used the script suggested, but I keep getting the following message when I try and test it by hitting "proceed to checkout":

The following errors have occurred.
(92) The gateway no longer supports the requested method of integration.


Any idea what could be causing this?

Am I doing something wrong?

Is there anything I can do to fix this?

I've gotten just a wee bit desperate, trying to figure out what Authorize.net needs.
CBQ
 
Posts: 3
Joined: Wed Dec 18, 2002 4:11 pm

Postby scott » Wed Dec 18, 2002 9:15 pm

Hmm... according to authorize.net--

NOTE: Please be aware that WebLink will be discontinued in early 2003, and should be considered a temporary Payment Gateway connection method solution.

It's been around for many years, and they are bringing up (SCC) AIM.

I'll look into it, and see if I can add support for their new gateway.

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Postby CBQ » Thu Dec 19, 2002 9:57 am

Okay, I managed to make it work, by working with the sample Perl file they have at Authorize.Net to use with SIM method. I sent the managecart.html file to the Perl file, (skipping a checkout html file, because it didn't work when sending to the Perl file) which then directed the collected info to the virtual terminal. Since the Perl file as it was collects very little, I also added a formail step to the managecart file, so that every time a purchase was made, there would be a corresponding email to identify what that purchase was.

It's probably a very sloppy way of doing it, but I was really just trying to get it to work.

I'm not sure the way I got it to work is a way others would want to, but if you want to see what I did, you can take a look at http://www.studdmandingo.com

It's not my site, I'm just a webdeveloper who was hired to make a small e commerce site for a sports apparel business.

Thanks for your reply and help, btw. This shopping cart is really very cool, and the instructions are incredibly clear, much better than one would expect for such a sophisticated script. 8)
CBQ
 
Posts: 3
Joined: Wed Dec 18, 2002 4:11 pm

Postby scott » Fri Dec 20, 2002 2:50 am

CBQ, I'm sure others would be very interested in your method. Would you mind posting your perl file sources (minus any sensitive data of course)?

Thanks!!

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Postby CallMeJ » Sun Feb 09, 2003 10:33 pm

Was a work-around ever made available for this?

I'm having the exact same problem, but I haven't found the answer searching the forums.
CallMeJ
 
Posts: 4
Joined: Sun Feb 09, 2003 10:31 pm

Postby CallMeJ » Tue Feb 11, 2003 4:08 pm

Anyone???

So, the script (in its current form) doesn't work with authorize.net??
CallMeJ
 
Posts: 4
Joined: Sun Feb 09, 2003 10:31 pm

Postby scott » Tue Feb 11, 2003 10:19 pm

It works (as released) with authorize.net's WebLink method -- but not SIM method. If your account can do weblink, it will work. Otherwise, you'll have to wait for a later release to get the new authorize.net integration.

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Information on the 92 error for Authorize

Postby rcplan2u » Tue Feb 18, 2003 5:12 am

For those of us who sign up for authorize after 1 Jan 2003
were automatic taken off of the weblink program and to us it you have to back and enable weblink from the setup menu in Authorize, this well only by you some time to april 1 2003,
then you well have to switch over to SIM or AIM or leave.
I don't know if NOP will have this by then . :(
rcplan2u
 
Posts: 1
Joined: Sun Feb 16, 2003 10:11 pm

Postby CBQ » Sat Mar 15, 2003 11:17 pm

CBQ wrote:Okay, I managed to make it work, by working with the sample Perl file they have at Authorize.Net to use with SIM method. I sent the managecart.html file to the Perl file, (skipping a checkout html file, because it didn't work when sending to the Perl file) which then directed the collected info to the virtual terminal. Since the Perl file as it was collects very little, I also added a formail step to the managecart file, so that every time a purchase was made, there would be a corresponding email to identify what that purchase was.

It's probably a very sloppy way of doing it, but I was really just trying to get it to work.

I'm not sure the way I got it to work is a way others would want to, but if you want to see what I did, you can take a look at http://www.studdmandingo.com

It's not my site, I'm just a webdeveloper who was hired to make a small e commerce site for a sports apparel business.

Thanks for your reply and help, btw. This shopping cart is really very cool, and the instructions are incredibly clear, much better than one would expect for such a sophisticated script.



Hi, I'm *so* sorry I got caught up with other work and haven't been back here.

Basically, there were alot of things I needed to make work with this shopping cart. I needed to make a formmail send an email to the owner of the site as soon as something was ordered, and I needed to make it work with the AuthorizeNet. Alot of this stuff is probably hideously sloppy (mostly I just messed with AuthorizeNet's example PERL until I made it work), but it works, so what the heck, right?

Anyway, here's the script with the cart itself, a combined manage cart & checkout page:


<HTML>
<HEAD>
<TITLE>Studd Mandingo</TITLE>

<STYLE>
.checkout {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.checkoutinput {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.nopcart {background: #BFBFBF;border-width: thick; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #ffffff;}
.nopheader {background: #808080;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF;}
.nopentry {background: #BFBFBF;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.noptotal {background: #BFBFB;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.nopbutton {background: #BFBFB;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
</STYLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

<SCRIPT SRC="nopcart.js">
//=====================================================================||
// NOP Design JavaScript Shopping Cart ||
//---------------------------------------------------------------------||
// Visit NOP Design at http://www.nopdesign.com or Info@nopdesign.com ||
//=====================================================================||
</SCRIPT>




<CENTER>
<TABLE WIDTH=315 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<CENTER><table WIDTH=315>

<tr>
<td>






<BR>



<!--Shopping Cart ManageCart Begin-->
<FONT FACE= "Verdana, Helvetica, Arial, Times New Roman"><FONT COLOR=#A1A1A1><FONT SIZE=2><B>The items listed below are currently in your shopping cart:
<p>
<FORM METHOD=GET NAME=form1 ACTION="http://www.studdmandingo.com/cgi-bin/formmail.pl">

<input type=hidden name="redirect" value="http://www.studdmandingo.com/managecart.html#checkout">





<input type=hidden name="recipient" value="sm@studdmandingo.com">


<input type=hidden name="subject" value="New Order">

<input type=hidden name="env_report" value="REMOTE_HOST, REMOTE_ADDR, HTTP_USER_AGENT">


<SCRIPT>
ManageCart();
</SCRIPT>



<!--Shopping Cart ManageCart End -->

<BR>
<BR>
Please fill out the information below to continue on to Check Out

<BR>
<BR>

First Name: <BR><INPUT TYPE="text" NAME="first name" SIZE="40">

<BR>
<BR>

Last Name: <BR><INPUT TYPE="text" NAME="last name" SIZE="40">



<BR>
<BR>
Email: <BR><INPUT TYPE="text" NAME="email" SIZE="40">

<BR>
<BR>


Phone: <BR>
<INPUT TYPE="text" NAME="phone" SIZE="40">
<BR>
<BR>


Which Logo would you like to appear on your purchase?: <BR><TEXTAREA NAME="Logo"ROWS=4 COLS=33></TEXTAREA><BR>





<BR>
<BR>
Comments: <BR><TEXTAREA NAME="questions_comments"ROWS=4 COLS=33></TEXTAREA><BR>
<INPUT TYPE="submit" VALUE="Continue---->">
</form>

</TD>
</TR>
</TABLE>







<BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR>





<BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR>












<TABLE WIDTH=315 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<CENTER><table WIDTH=315>

<tr>
<td>






<BR><A NAME="checkout"></A>


<!--Shopping Cart ManageCart Begin-->

<CENTER><FONT FACE= "Verdana, Helvetica, Arial, Times New Roman"><FONT COLOR=#000000><FONT SIZE=4><B>Check Out</CENTER><BR><BR>


<p>
<FORM ACTION="http://www.studdmandingo.com/cgi-bin/sim.pl" METHOD="POST">
<SCRIPT>
ManageCart();
</SCRIPT>


<INPUT type=SUBMIT value=" Check Out ">
</FORM>
<!--Shopping Cart ManageCart End -->


</TD>
</TR>
</TABLE>

</TD>
</TR>
</TABLE>
</CENTER>
</CENTER>
</BODY>
</HTML>




Below is the source code from everything in the CGI-BIN, 'cept the formmail script, which is just a simple script from Matt's Script Archive (and again, was only necessary cause this particular customer wanted an email every time someone purchased something. I'm only including mention of it because it explains why I did some things certain ways).

Again, the PERL scripts are mostly just the example files from AuthorizeNet itself, so most of the stuff in there, including the comment lines, are word for word their example stuff. All I did was mess with some of them a bit to make them work.



Source Code for sim.pl:
#!/usr/local/bin/perl -w
#
#
# DISCLAIMER:
# This code is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Main perl script that demonstrates how to use the SIM library to
# integrate with Authorize.net.
# Input (Form or QueryString):
# x_Amount
# x_Description
#
# If you just want to calculate the Fingerprint without auto generating the
# hidden fields, call:
# &SimLib::GenerateInspFP($loginid, $txnkey, $amount, $sequence, $tstamp,$currency);
#


use strict;

# $Id: sim.pl,v 1.4 2002/11/21 23:31:53 adama Exp $

use SimLib;

# You may want to store this more securely in a DB or Registry or a Encrypted File
# --------------------------------------------------------------------------------
my $loginid = "Howard1";
my $txnkey = "DOmkrSHpQqLPuEAY";

my %ENTRY = &SimLib::get_submission;

my $x_amount = $ENTRY{'x_amount'};

if (index($x_amount,'$') == 0){
$x_amount = substr($x_amount,1);
}


# use the line below to get x_currency code out of the GET/POST or
# set it yourself (my $x_currency_code = "USD";
my $x_currency_code = $ENTRY{'x_currency_code'};

print "content-type: text/html\n\n";
print "<HTML> <HEAD> <TITLE>Order Form</TITLE>\n";

print "</HEAD>\n";
print "<BODY>\n<H3>Final Order</H3>\n";


print "Total Amount : ".$x_amount." <BR /><BR />\n";

print "<FORM action="https://secure.authorize.net/gateway/transact.dll" method="POST">\n";

# If you don't use a currency code variable, you can still use this call to InsertFP,
# it will use it if supplied but works without it. If you do supply it, InsertFP will
# also print out an html hidden field containing the x_currency_code you passed in.

&SimLib::InsertFP($loginid, $txnkey, $x_amount, $x_currency_code);

# Insert other form elements similiar to legacy weblink integration


print "<input type="hidden" name="x_login" value="" . $loginid . "">\n";
print "<input type="hidden" name="x_amount" value="" . $x_amount . "">\n";
print "<input type="hidden" name="x_show_Form" value="PAYMENT_FORM">\n";
print "<input type="submit" value="Accept Order">\n";
print "</FORM> </BODY> </HTML>";

1;












Source Code for SimHMAC.pm:
package SimHMAC;
use strict;
require 5.000;

# $Id: SimHMAC.pm,v 1.1 2002/10/22 21:03:59 adama Exp $

require Exporter;

@SimHMAC::ISA = qw( Exporter );
@SimHMAC::EXPORT = qw( &hmac &hmac_hex );

use integer;

#
# interface routine; returns a digest of a string passed as a parameter
#

sub Digest {
my $context = &MD5Init();

# this should be done always
&MD5Update($context, $_[0], length($_[0]));

return &MD5Final($context);
}

#
# same as Digest but returns digest in a printable (hex) form
#

sub HexDigest {
return unpack("H*", &Digest(@_));
}


#
# MD5 implementation is below
#



# derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm

# Original context structure
# typedef struct {
#
# UINT4 state[4]; /* state (ABCD) */
# UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
# unsigned char buffer[64]; /* input buffer */
#
# } MD5_CTX;

# Constants for MD5Transform routine.

sub S11 { 7 }
sub S12 { 12 }
sub S13 { 17 }
sub S14 { 22 }
sub S21 { 5 }
sub S22 { 9 }
sub S23 { 14 }
sub S24 { 20 }
sub S31 { 4 }
sub S32 { 11 }
sub S33 { 16 }
sub S34 { 23 }
sub S41 { 6 }
sub S42 { 10 }
sub S43 { 15 }
sub S44 { 21 }

my $PADDING = join('', map(chr, (
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
);

# F, G, H and I are basic MD5 functions.

sub F { my ($x, $y, $z) = @_; ((($x) & ($y)) | ((~$x) & ($z))); }
sub G { my ($x, $y, $z) = @_; ((($x) & ($z)) | (($y) & (~$z))); }
sub H { my ($x, $y, $z) = @_; (($x) ^ ($y) ^ ($z)); }
sub I { my ($x, $y, $z) = @_; (($y) ^ (($x) | (~$z))); }


# ROTATE_LEFT rotates x left n bits.
# Note: "& ~(-1 << $n)" is not in C version
#
sub ROTATE_LEFT { my ($x, $n) = @_; ($x << $n) | (($x >> (32-$n) & ~(-1 << $n))); }

# FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
# Rotation is separate from addition to prevent recomputation.

sub FF {
my ($a, $b, $c, $d, $x, $s, $ac) = @_;

$a += &F($b, $c, $d) + $x + $ac;
$a = &ROTATE_LEFT($a, $s);
$a += $b;

return $a;
}

sub GG {
my ($a, $b, $c, $d, $x, $s, $ac) = @_;

$a += &G ($b, $c, $d) + $x + $ac;
$a = &ROTATE_LEFT ($a, $s);
$a += $b;

return $a;
}

sub HH {
my ($a, $b, $c, $d, $x, $s, $ac) = @_;
$a += &H ($b, $c, $d) + $x + $ac;
$a = &ROTATE_LEFT ($a, $s);
$a += $b;

return $a;
}

sub II {
my ($a, $b, $c, $d, $x, $s, $ac) = @_;

$a += &I ($b, $c, $d) + $x + $ac;
$a = &ROTATE_LEFT ($a, $s);
$a += $b;

return $a;
}

# MD5 initialization. Begins an MD5 operation, writing a new context.

sub MD5Init {
my $context = {};

@{$context-> {count}} = 2;
$context-> {count}[0] = $context-> {count}[1] = 0;
$context-> {buffer} = '';

# Load magic initialization constants.

@{$context-> {state}} = 4;
$context-> {state}[0] = 0x67452301;
$context-> {state}[1] = 0xefcdab89;
$context-> {state}[2] = 0x98badcfe;
$context-> {state}[3] = 0x10325476;

return $context;
}

# MD5 block update operation. Continues an MD5 message-digest
# operation, processing another message block, and updating the context.

sub MD5Update {
my ($context, $input, $inputLen) = @_;

# Compute number of bytes mod 64
my $index = (($context->{count}[0] >> 3) & 0x3F);

# Update number of bits
if (($context->{count}[0] += ($inputLen << 3)) <
($inputLen << 3))
{
$context->{count}[1]++;
$context->{count}[1] += ($inputLen >> 29);
}

my $partLen = 64 - $index;

# Transform as many times as possible.

my $i;
if ($inputLen >= $partLen) {

substr($context -> {buffer}, $index, $partLen) = substr($input, 0, $partLen);

&MD5Transform(\@{$context -> {state}}, $context -> {buffer});

for ($i = $partLen; $i + 63 < $inputLen; $i += 64) {
&MD5Transform ($context-> {state}, substr($input,$i));
}

$index = 0;
} else {
$i = 0;
}

# Buffer remaining input
substr($context->{buffer}, $index, $inputLen-$i) = substr($input, $i, $inputLen-$i);
}

# MD5 finalization. Ends an MD5 message-digest operation, writing the
# the message digest and zeroizing the context.

sub MD5Final {
my $context = shift;

# Save number of bits
my $bits = &Encode (\@{$context->{count}}, 8);

# Pad out to 56 mod 64.
my ($index, $padLen);
$index = ($context->{count}[0] >> 3) & 0x3f;
$padLen = ($index < 56) ? (56 - $index) : (120 - $index);

&MD5Update ($context, $PADDING, $padLen);

# Append length (before padding)
MD5Update ($context, $bits, 8);

# Store state in digest
my $digest = &Encode(\@{$context-> {state}}, 16);

# &MD5_memset ($context, 0);

return $digest;
}

# MD5 basic transformation. Transforms state based on block.

sub MD5Transform {
my ($state, $block) = @_;

my ($a,$b,$c,$d) = @{$state};
my @x = 16;

&Decode (\@x, $block, 64);

# Round 1
$a = &FF ($a, $b, $c, $d, $x[ 0], S11, 0xd76aa478); # 1
$d = &FF ($d, $a, $b, $c, $x[ 1], S12, 0xe8c7b756); # 2
$c = &FF ($c, $d, $a, $b, $x[ 2], S13, 0x242070db); # 3
$b = &FF ($b, $c, $d, $a, $x[ 3], S14, 0xc1bdceee); # 4
$a = &FF ($a, $b, $c, $d, $x[ 4], S11, 0xf57c0faf); # 5
$d = &FF ($d, $a, $b, $c, $x[ 5], S12, 0x4787c62a); # 6
$c = &FF ($c, $d, $a, $b, $x[ 6], S13, 0xa8304613); # 7
$b = &FF ($b, $c, $d, $a, $x[ 7], S14, 0xfd469501); # 8
$a = &FF ($a, $b, $c, $d, $x[ 8], S11, 0x698098d8); # 9
$d = &FF ($d, $a, $b, $c, $x[ 9], S12, 0x8b44f7af); # 10
$c = &FF ($c, $d, $a, $b, $x[10], S13, 0xffff5bb1); # 11
$b = &FF ($b, $c, $d, $a, $x[11], S14, 0x895cd7be); # 12
$a = &FF ($a, $b, $c, $d, $x[12], S11, 0x6b901122); # 13
$d = &FF ($d, $a, $b, $c, $x[13], S12, 0xfd987193); # 14
$c = &FF ($c, $d, $a, $b, $x[14], S13, 0xa679438e); # 15
$b = &FF ($b, $c, $d, $a, $x[15], S14, 0x49b40821); # 16

# Round 2
$a = &GG ($a, $b, $c, $d, $x[ 1], S21, 0xf61e2562); # 17
$d = &GG ($d, $a, $b, $c, $x[ 6], S22, 0xc040b340); # 18
$c = &GG ($c, $d, $a, $b, $x[11], S23, 0x265e5a51); # 19
$b = &GG ($b, $c, $d, $a, $x[ 0], S24, 0xe9b6c7aa); # 20
$a = &GG ($a, $b, $c, $d, $x[ 5], S21, 0xd62f105d); # 21
$d = &GG ($d, $a, $b, $c, $x[10], S22, 0x2441453); # 22
$c = &GG ($c, $d, $a, $b, $x[15], S23, 0xd8a1e681); # 23
$b = &GG ($b, $c, $d, $a, $x[ 4], S24, 0xe7d3fbc8); # 24
$a = &GG ($a, $b, $c, $d, $x[ 9], S21, 0x21e1cde6); # 25
$d = &GG ($d, $a, $b, $c, $x[14], S22, 0xc33707d6); # 26
$c = &GG ($c, $d, $a, $b, $x[ 3], S23, 0xf4d50d87); # 27
$b = &GG ($b, $c, $d, $a, $x[ 8], S24, 0x455a14ed); # 28
$a = &GG ($a, $b, $c, $d, $x[13], S21, 0xa9e3e905); # 29
$d = &GG ($d, $a, $b, $c, $x[ 2], S22, 0xfcefa3f8); # 30
$c = &GG ($c, $d, $a, $b, $x[ 7], S23, 0x676f02d9); # 31
$b = &GG ($b, $c, $d, $a, $x[12], S24, 0x8d2a4c8a); # 32

# Round 3
$a = &HH ($a, $b, $c, $d, $x[ 5], S31, 0xfffa3942); # 33
$d = &HH ($d, $a, $b, $c, $x[ 8], S32, 0x8771f681); # 34
$c = &HH ($c, $d, $a, $b, $x[11], S33, 0x6d9d6122); # 35
$b = &HH ($b, $c, $d, $a, $x[14], S34, 0xfde5380c); # 36
$a = &HH ($a, $b, $c, $d, $x[ 1], S31, 0xa4beea44); # 37
$d = &HH ($d, $a, $b, $c, $x[ 4], S32, 0x4bdecfa9); # 38
$c = &HH ($c, $d, $a, $b, $x[ 7], S33, 0xf6bb4b60); # 39
$b = &HH ($b, $c, $d, $a, $x[10], S34, 0xbebfbc70); # 40
$a = &HH ($a, $b, $c, $d, $x[13], S31, 0x289b7ec6); # 41
$d = &HH ($d, $a, $b, $c, $x[ 0], S32, 0xeaa127fa); # 42
$c = &HH ($c, $d, $a, $b, $x[ 3], S33, 0xd4ef3085); # 43
$b = &HH ($b, $c, $d, $a, $x[ 6], S34, 0x4881d05); # 44
$a = &HH ($a, $b, $c, $d, $x[ 9], S31, 0xd9d4d039); # 45
$d = &HH ($d, $a, $b, $c, $x[12], S32, 0xe6db99e5); # 46
$c = &HH ($c, $d, $a, $b, $x[15], S33, 0x1fa27cf8); # 47
$b = &HH ($b, $c, $d, $a, $x[ 2], S34, 0xc4ac5665); # 48

# Round 4
$a = &II ($a, $b, $c, $d, $x[ 0], S41, 0xf4292244); # 49
$d = &II ($d, $a, $b, $c, $x[ 7], S42, 0x432aff97); # 50
$c = &II ($c, $d, $a, $b, $x[14], S43, 0xab9423a7); # 51
$b = &II ($b, $c, $d, $a, $x[ 5], S44, 0xfc93a039); # 52
$a = &II ($a, $b, $c, $d, $x[12], S41, 0x655b59c3); # 53
$d = &II ($d, $a, $b, $c, $x[ 3], S42, 0x8f0ccc92); # 54
$c = &II ($c, $d, $a, $b, $x[10], S43, 0xffeff47d); # 55
$b = &II ($b, $c, $d, $a, $x[ 1], S44, 0x85845dd1); # 56
$a = &II ($a, $b, $c, $d, $x[ 8], S41, 0x6fa87e4f); # 57
$d = &II ($d, $a, $b, $c, $x[15], S42, 0xfe2ce6e0); # 58
$c = &II ($c, $d, $a, $b, $x[ 6], S43, 0xa3014314); # 59
$b = &II ($b, $c, $d, $a, $x[13], S44, 0x4e0811a1); # 60
$a = &II ($a, $b, $c, $d, $x[ 4], S41, 0xf7537e82); # 61
$d = &II ($d, $a, $b, $c, $x[11], S42, 0xbd3af235); # 62
$c = &II ($c, $d, $a, $b, $x[ 2], S43, 0x2ad7d2bb); # 63
$b = &II ($b, $c, $d, $a, $x[ 9], S44, 0xeb86d391); # 64

$state -> [0] += $a;
$state -> [1] += $b;
$state -> [2] += $c;
$state -> [3] += $d;

# Zeroize sensitive information.
# MD5_memset ((POINTER)x, 0, sizeof (x));
}

# Encodes input (UINT4) into output (unsigned char). Assumes len is
# a multiple of 4.

sub Encode {
my ($input, $len) = @_;

my $output = '';
my ($i, $j);
for ($i = 0, $j = 0; $j < $len; $i++, $j += 4) {
substr($output, $j+0, 1) = chr($input -> [$i] & 0xff);
substr($output, $j+1, 1) = chr(($input -> [$i] >> 8) & 0xff);
substr($output, $j+2, 1) = chr(($input -> [$i] >> 16) & 0xff);
substr($output, $j+3, 1) = chr(($input -> [$i] >> 24) & 0xff);
}

return $output;
}

# Decodes input (unsigned char) into output (UINT4). Assumes len is
# a multiple of 4.

sub Decode {
my ($output, $input, $len) = @_;

my ($i, $j);

for ($i = 0, $j = 0; $j < $len; $i++, $j += 4) {
$output -> [$i] =
(ord(substr($input, $j+0, 1))) |
(ord(substr($input, $j+1, 1)) << 8) |
(ord(substr($input, $j+2, 1)) << 16) |
(ord(substr($input, $j+3, 1)) << 24);
}
}

sub hmac
{
my($data, $key) = @_;
my $block_size = 64;

$key = &Digest($key) if length($key) > $block_size;

my $k_ipad = $key ^ (chr(0x36) x $block_size) . $data;

my $k_opad = $key ^ (chr(0x5c) x $block_size) . &Digest($k_ipad);

&Digest($k_opad);
}

sub hmac_hex { unpack("H*", &hmac); }


1;





Source Code for SimLib.pm:

package SimLib;

use strict;
use SimHMAC;

# $Id: SimLib.pm,v 1.6 2002/11/15 17:07:06 adama Exp $

require Exporter;

@SimLib::ISA = qw( Exporter );
@SimLib::EXPORT = qw( &GenerateInspFP &InsertFP &get_submission );

sub GenerateInspFP
{
my ($loginid, $txnkey, $amount, $sequence, $tstamp, $currency) = @_;

&SimHMAC::hmac_hex($loginid ."^".$sequence."^".$tstamp."^".$amount."^".$currency,$txnkey);
}

sub InsertFP
{
my ($loginid, $txnkey, $amount, $currency) = @_;
my $tstamp = time;
my $sequence = int(rand 1000);

my $fp = &GenerateInspFP($loginid, $txnkey, $amount, $sequence,$tstamp, $currency);

print("<INPUT TYPE="HIDDEN" NAME="x_fp_sequence" VALUE="".$sequence."">\n");
print("<INPUT TYPE="HIDDEN" NAME="x_fp_timestamp" VALUE="".$tstamp."">\n");
print("<INPUT TYPE="HIDDEN" NAME="x_fp_hash" VALUE="".$fp."">\n");

if ( defined $currency ) {
print("<INPUT TYPE="HIDDEN" NAME="x_currency_code" VALUE="".$currency."">\n");
}
}


sub get_submission {
my %ENTRY = ();
my $GetPost = '';
my $GetGet = $ENV{'QUERY_STRING'};

my $cl = $ENV{'CONTENT_LENGTH'};
if (defined{$cl}) {
binmode(STDIN);
while ($cl > 0 && read(STDIN, $_, $cl) > 0) {
$GetPost .= $_;
$cl -= length($_);
}
close STDIN;
}

my $submission = $GetGet . $GetPost;
chomp $submission;

# Split the name-value pairs
foreach my $pair (split(/[&;]/, $submission)) {
# Convert plus to space
$pair =~ y/+/ /;

# Split into key and value.
my ($name, $value) = split(/=/, $pair, 2); # splits on the first =.

# Convert %XX from hex numbers to character
$name =~ s/%([A-Fa-f0-9]{2})/pack("c", hex($1))/ge;
$value =~ s/%([A-Fa-f0-9]{2})/pack("c", hex($1))/ge;

# Associate key and value
$ENTRY{$name} .= "\0" if (defined($ENTRY{$name}));
$ENTRY{$name} .= $value;
}
return %ENTRY;
}




1;
CBQ
 
Posts: 3
Joined: Wed Dec 18, 2002 4:11 pm

Postby CallMeJ » Mon Mar 31, 2003 9:08 pm

I'm working on setting this up, but I keep getting a "(97) This transaction cannot be accepted." error.


The sim documentation for this error says

Applicable only to SIM API.Fingerprints are only valid for a short period of time. This code indicates that the transaction fingerprint has expired.


Anyone have any ideas?

Actually, this problem has become stranger. If I hit the sim.pl and immediately press the "Accept Order" button, I get the error. If I let that page sit there for a few minutes and then hit the button, it goes through. :?:
CallMeJ
 
Posts: 4
Joined: Sun Feb 09, 2003 10:31 pm


Return to Installation and Setup Problems

Who is online

Users browsing this forum: No registered users and 0 guests

cron