cancel
Showing results for 
Search instead for 
Did you mean: 

Re: User authentication failed due to invalid authentication values.

 

Dear Sir,

 
I'm a  asp.net mvc developer  and i'm deploying Authorize.net to client website. When I'm going to transaction it shows the error "Response Text: User authentication failed due to invalid authentication values." What is this issue. I used my test account credentials so it's working fine but when i change the test credential to merchant API login and transaction key it shows the error.
my code
string res = "";
try
{
String ApiLoginID = "";
String ApiTransactionKey = "";

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION/SENDBOX(both are using in individual);

// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};

var creditCard = new creditCardType
{
cardNumber = objPay.Card_Num,
expirationDate = objPay.Day + (objPay.Year.Substring(objPay.Year.Length - 2)), //objPay.Exp_Date
cardCode = objPay.card_code
};

var billingAddress = new customerAddressType
{
firstName = objPay.First_Name,
lastName = objPay.Last_Name,
address = objPay.Address,
city = objPay.City,
zip = objPay.ZIP
};
//standard api call to retrieve response
var paymentType = new paymentType { Item = creditCard };

var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
amount = objPay.Amount,
payment = paymentType,
billTo = billingAddress
};

var request = new createTransactionRequest { transactionRequest = transactionRequest };

// instantiate the contoller that will call the service
var controller = new createTransactionController(request);
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();

//validate
if (response != null)
{
if (response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactionResponse.messages != null)
{
Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
}
else
{
Console.WriteLine("Failed Transaction.");
if (response.transactionResponse.errors != null)
{
Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
}
}
}
else
{
Console.WriteLine("Failed Transaction.");
if (response.transactionResponse != null && response.transactionResponse.errors != null)
{
Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
}
else
{
Console.WriteLine("Error Code: " + response.messages.message[0].code);
Console.WriteLine("Error message: " + response.messages.message[0].text);
}
}
}
else
{
Console.WriteLine("Null Response.");
}
res = response.ToString();
}
catch (Exception ex)
{
res = ex.Message;
}
//return View(res);
return RedirectToAction("Index2", "Home");
}
 
plz give me solution
biru
Member
1 REPLY 1

Hello @biru

 

You would get this error if you are using invalid credentials or are using credentials with the wrong enviromentment.  For example, sandbox credentials will only work if the environment is set to sandbox, it will not work in production.  The same is true for production credentials not working in the sandbox.

 

You can use authenticateTestRequest to confirm if the credentials are valid.  

 

Richard

RichardH
Administrator Administrator
Administrator