cancel
Showing results for 
Search instead for 
Did you mean: 

SIM Process

I am getting error 103 when running the below code.  I took out sensitive information.  Response Reason Text: A valid fingerprint, or transaction key is required for this transaction.  I believe my transaction key is fine.  I am not sure how to do the fingerprint in the below code.  Can anyone help?

 

<form METHOD=post ACTION=
https://secure.authorize.net/gateway/transact.dll>
<% ret = InsertFP (apiloginid, sequence, amount, txnkey) %>
<input TYPE=hidden NAME="x_login" VALUE="">
<input TYPE=hidden NAME="transactionKey" VALUE="">
<input TYPE=hidden NAME="x_fp_hash" >
<input TYPE=hidden NAME="x_fp_sequence" >
<input TYPE=hidden NAME="x_fp_timestamp" >
<input TYPE=hidden NAME="x_version" VALUE="3.1">
<input TYPE=hidden NAME="x_method" VALUE="CC">
<input TYPE=hidden NAME="x_show_form" VALUE="PAYMENT_FORM">
<input TYPE=hidden NAME="x_invoice_num" VALUE="ORDER-002450">
<input TYPE=hidden NAME="x_description" VALUE="Product or order description.">
<input TYPE=hidden NAME="x_cust_id" VALUE="Doe-John 001">
<input TYPE=hidden NAME="x_amount" VALUE="3.00">
<input TYPE=hidden NAME="x_receipt_link_method" VALUE="LINK">
<input TYPE=hidden NAME="x_receipt_link_text" VALUE="Click here to return to our home page">
<input TYPE=hidden NAME="x_receipt_link_URL" VALUE="">
<input TYPE=submit VALUE="Click here for the secure payment form">
</form>

swest
Contributor
24 REPLIES 24

I am still having trouble with this.  I called authorize.net support and they seem to say that I could just put a button on my website to redirect to their payment site if I need to.  I dont understand how that would work, where would they get the login name and transaction key from?  How would I redirect back to my website once the customer is finished paying for the item?

Did you try the java SIM sample code to see how it work? Once you get that to work then start looking at "relay response" or "receipt page" link to redirect back to your site.

I tried the Java code some more and I cant get it to work.  On my site when they click a button, it is suppose to called the Java code.  My development software will let you call Java functions.  Again, I cant seem to get it to run, it is saying it is expecting values at certain lines in the code.

What the exact error message?

Here is the code I am using.  The first error I am getting is in line 3 which is String loginID = "";  I do put in my loginID, just took it out to post so that is not the issue. 

 

// the parameters for the payment can be configured here
// the API Login ID and Transaction Key must be replaced with valid values
String loginID   = "";
String transactionKey = "";
String amount   = "5.00";
String description  = "Sample Transaction";
String label    = "Submit Payment"; // The is the label on the 'submit' button
String testMode   = "false";

// By default, this sample code is designed to post to our test server for
// developer accounts: https://test.authorize.net/gateway/transact.dll
// for real accounts (even in test mode), please make sure that you are
// posting to: https://secure.authorize.net/gateway/transact.dll
String url   = "https://secure.authorize.net/gateway/transact.dll";

// If an amount or description were posted to this page, the defaults are overidden
if ( request.getParameter("amount") != null )
 { amount = request.getParameter("amount"); }
if ( request.getParameter("description") != null )
 { description = request.getParameter("description"); }

// an invoice is generated using the date and time
Date myDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String invoice = dateFormat.format(myDate);
// a sequence number is randomly generated
Random generator = new Random();
int sequence = generator.nextInt(1000);
// a timestamp is generated
long timeStamp = System.currentTimeMillis()/1000;

//This section uses Java Cryptography functions to generate a fingerprint
 // First, the Transaction key is converted to a "SecretKey" object
 KeyGenerator kg = KeyGenerator.getInstance("HmacMD5");
 SecretKey key = new SecretKeySpec(transactionKey.getBytes(), "HmacMD5");
 // A MAC object is created to generate the hash using the HmacMD5 algorithm
 Mac mac = Mac.getInstance("HmacMD5");
 mac.init(key);
 String inputstring = loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^";
 byte[] result = mac.doFinal(inputstring.getBytes());
 // Convert the result from byte[] to hexadecimal format
 StringBuffer strbuf = new StringBuffer(result.length * 2);
 for(int i=0; i< result.length; i++)
 {
  if(((int) result[i] & 0xff) < 0x10)
   strbuf.append("0");
  strbuf.append(Long.toString((int) result[i] & 0xff, 16));
 }
 String fingerprint = strbuf.toString();
// end of fingerprint generation

// Print the Amount and Description to the screen.
out.println ("Amount: " + amount + " <br />");
out.println ("Description: " + description + "<br />");

// Create the HTML form containing necessary SIM post values
out.println ("<FORM method='post' action='" + url + "' >");

Which IDE are you using for this?

Not sure what you are asking.  I downloaded the Java sample code and edited that.  I have a button on my webpage page when the user clicks it should call that Java code.  It seems to be calling it but doesnt seem to like the code.

Ok. What your development software?

It is called Alpha Five.

I downloaded the Java sample code and edited that.  I have a button on my webpage page when the user clicks it should call that Java code.  It seems to be calling it but doesnt seem to like the code.

 

What did you change other than the adding the loginID and transactionKey.

And what do you mean having a button on your webpage with a button that call the java code? you didn't just run the sample.jsp?