Reply
Highlighted
Member
Posts: 6
Registered: ‎10-25-2016

Transaction Declined in SIM API

 I am new in autorize.net. I found a sample a code of SIM API and tested it. It works perefectly fine. But when I implement the same in Live mode, it generate error by by saying Transaction Declined(General Error). AVS not processed(P).

 

this is my code

 

 

$loginID = "My_login_id";
$transactionKey = "my_transaction_id";
$amount = $price_gbp;
$description = "Item Description";
$label = "Authorize.net"; // The is the label on the 'submit' button
$testMode = "false";
$url = "https://secure.authorize.net/gateway/transact.dll";
 
if (array_key_exists("amount",$_REQUEST))
{ $amount = $_REQUEST["amount"]; }
if (array_key_exists("description",$_REQUEST))
{ $description = $_REQUEST["description"]; }
 
$invoice = date('YmdHis');
$sequence = rand(1, 1000);
$timeStamp = time();
 
if( phpversion() >= '5.1.2' )
{ $fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey); }
else 
{ $fingerprint = bin2hex(mhash(MHASH_MD5, $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey)); }
 
<form method='post' name='autorizenet' action='$url' >
<input type='hidden' name='x_login' value='$loginID' />
<input type='hidden' name='x_amount' value='$amount' />
<!--input type='hidden' name='x_currency_code' value='USD' /-->

<input type='hidden' name='x_description' value='$description' />
<input type='hidden' name='x_invoice_num' value='$invoice' />
<input type='hidden' name='x_fp_sequence' value='$sequence' />
<input type='hidden' name='x_fp_timestamp' value='$timeStamp' />
<input type='hidden' name='x_fp_hash' value='$fingerprint' />
<input type='hidden' name='x_test_request' value='$testMode' />";
$i_sl=1;
foreach ($_SESSION["cart_products"] as $cart_itm)
{
echo "<INPUT TYPE='HIDDEN' name='x_line_item' VALUE='item $i_sl<|>Item Name:<|>".$cart_itm['product_name']."<|>1<|>".round(currency('USD', 'GBP',$cart_itm["product_price"]),2)."<|>N'>";
$i_sl++;
} 
echo "<input type='hidden' name='x_cust_id' value='$c_id' />
<input type='hidden' name='x_first_name' value='$fname' />
<input type='hidden' name='x_last_name' value='$lname' />
<input type='hidden' name='x_address' value='$address' />
<input type='hidden' name='x_city' value='$city' />
<input type='hidden' name='x_state' value='$state' />
<input type='hidden' name='x_zip' value='$zip' />
<input type='hidden' name='x_country' value='$country' />
<input type='hidden' name='x_phone' value='$phone' />
<input type='hidden' name='x_email' value='$email' />

<input type='hidden' name='x_show_form' value='PAYMENT_FORM' />
<input type='submit' class='btn btn-lg btn-danger' value='$label' style='width:305px !important' />
</form>

 

and i also configure the request/Response URL on merchant website and add a url link with GET method to reach back to my website.

Why my transaction are declined. There is not credit card bank issue. Please help

Thanks

Highlighted
Member
Posts: 3
Registered: ‎10-25-2016

Re: Transaction Declined in SIM API

I see that at some point you used to have x_currency_code among the sent fields, which you are supposed to include in the generated fingerprint.

 

This field is commented out now, so no longer need in the print but you still have a traling . "^" which is not supposed to be there. Your fingerprint is almost certainly wrong because of this and doesn't check out properly with Authorize.

Highlighted
Member
Posts: 6
Registered: ‎10-25-2016

Re: Transaction Declined in SIM API

[ Edited ]

Should i remove the x_currency_code ? will it solve my problem?

I din't get you about the fingerprint part and the traling . "^". 
can you please be more specific where or what I need to change.

 

I actually should change the currency code and accept payment in USD but merchant account allows only GBP so when I use the c_currency_code line it generate an error. So I remove it and accepting payment in GBP.

 

Please tell me how to solve the problem.

Highlighted
Member
Posts: 3
Registered: ‎10-25-2016

Re: Transaction Declined in SIM API

$fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey);

See above.

 

I placed a line over the part that you need to lose. The "^" is used as a "glue" token to concatenate the different segments of the fingerprint material. Since you don't have anything after amount (this is where you would normally put the currency code) you don't need the last "glue" element.

 

Regarding the currency, if you are sending x_currency_code as part of the payload you have to add it in the fingerprint as well.

 

Something like this:

 

$fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^" . $currencyCode, $transactionKey);

 

Highlighted
Member
Posts: 6
Registered: ‎10-25-2016

Re: Transaction Declined in SIM API

I have done what and as you said.

But same error has occured as prevous

 

Transaction Declined

An error occurred during processing. Call Merchant Service Provider.

 

Highlighted
Posts: 2,765
Topics: 57
Kudos: 247
Blog Posts: 67
Registered: ‎12-05-2011

Re: Transaction Declined in SIM API

Hello,
 
We are experiencing an issue in the sandbox which may be affecting your transaction.
 
 
Richard
Developer Community Manager​​
Highlighted
Member
Posts: 6
Registered: ‎10-25-2016

Re: Transaction Declined in SIM API

But I am working on Live Envirnoment.

with the url

 

$url = "https://secure.authorize.net/gateway/transact.dll";