I am just starting to learn the ins and outs of PERL so I am still confused easily.
I am trying to call the Payment page from Athorize.net so that I may use their secure servers. This is supposed to be the easiest transaction in the world. It’s to let people make a donation to a charity. They plug-in a dollar amount and push the button sending them to the Authorize.net secure payment form. Simple, right?
The sample HTML code they give is this:
<!--#INCLUDE FILE="simlib.asp"-->
<FORM METHOD=POST ACTION="https://certification.authorize.net/gateway/transact.dll">
<% ret = InsertFP (APIloginid, txnkey, amount, sequence) %>
<INPUT TYPE=HIDDEN NAME="x_login" VALUE="your API login ID goes here">
<INPUT TYPE=HIDDEN NAME="x_show_form" VALUE="PAYMENT_FORM">
<INPUT TYPE=HIDDEN NAME="x_amount" VALUE="amount goes here">
<INPUT TYPE=SUBMIT VALUE="Click here for secure payment form">
</FORM>
Now this is for ASP and I want to use PERL, so I include the simlib.pl file into my CGI-BIN. I also put my Login-In the space where it asks.
So here’s where I am confused. For the ASP there is this line:
<% ret = InsertFP (APIloginid, txnkey, amount, sequence) %>
That’s not going to work with the PERL. So I need to switch that out. The code that Authorize.net gives you says this.
# If you just want to calculate the Fingerprint without auto generating the
# hidden fields, call:
# &SimLib::GenerateInspFP($loginid, $x_tran_key, $amount, $sequence, $tstamp,$currency);
#
How do I call that? Don’t I have to bracket that in some way?
Any help would be appreciated. Thank you.
$myFingerPrint = &SimLib::GenerateInspFP($loginid, $x_tran_key, $amount, $sequence, $tstamp,$currency);
Where loginid is the account login id, $x_tran_key is the transaction key that matches the transaction key generated from within the A.N. account (store this in a safe place!,) $amount is of course the transaction amount, $tstamp is your server's timestamp, and $currency is your currency (IE USD).
$sequence is your invoice ID or any other unique number, it may be random. I can't recall exactly how this fingerprint is used because I use a different method and it's been a long time since I worked with SIM. I silently post using AIM, using curl:
$post = $postdata = qq¦curl -d 'key1=value1&key2=value2&x_Test_Request=TRUE&x_Login=$my_login&x_Tran_Key=$my_trans_key' [certification.authorize.net...]
Where key.. and value.. are all the values I post to A.N., including which delimit character to use. In this case I chose ¦.
$result = `$post`;
Which stores the delimited string returned by A.N. in $result, which I parse out like so
@delim = split(/\¦/,$result);
Then reassemble the data returned from A.N. to get at the response.
I know may seem like a diversion to you but I found it easier to implement in the long run and it has two distinct advantages: one, the user never leaves your site, the post is made and results returned in one silent action. Two, in the first implementation you have to link them back to your site to complete any update processes and this allows a place for the user to introduce an error.
The only downside is your silent post must be made FROM a secure server, which you should be doing anyway if you're submitting a form from your site.
Your method is the SIM method, mine uses the AIM method, there are PDF files in the Merchant Interface for both - they used to have a sample file called SIM.pl that you could modify to get the hang of how it works. Sorry that's all I remember.