cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting a failed authorization

We are having some issues handeling the return transactionResponse to detect failed Transactions. At first we were just tesing for a response code of 2, but found that a decline isnt the only return for a failed transaction. So we decided to go with testing if the authcode was all 0s, or null to check for failed transactions. That does not seem to work as a declined transaction came back with a authCode that was neither all zeros or null but a six digit integer. What different scenarios and checks would we need to do to detect a failed authorization? C# sample code:

 

if(response.messages.resultCode == messageTypeEnum.Error) throw new Exception("OrderCreditCardController.CapturePayment: " + GetResponseMessage(response));

 

AuthorizeCode = response.transactionResponse.authCode;

 

//checks for null and All zeros

if (!IsAuthorizeCodeValid(AuthorizeCode)) throw new Exception("OrderCreditCardController.AuthorizePayment:" + response.transactionResponse.responseCode + " " + GetResponseMessage(response));

 

johnnyc
Member
2 REPLIES 2

Why not check if the responseCode is !=1 for a declined transaction or transId > 0 for an approved transaction?

Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

krogerfeedback


@johnnyc wrote:

We are having some issues handeling the return transactionResponse to detect failed Transactions. At first we were just tesing for a response code of 2, but found that a decline isnt the only return for a failed transaction. So we decided to go with testing if the authcode was all 0s, or null to check for failed transactions. That does not seem to work as a declined transaction came back with a authCode that was neither all zeros or null but a six digit integer. What different scenarios and checks would we need to do to detect a failed authorization? C# sample code:

 

if(response.messages.resultCode == messageTypeEnum.Error) throw new Exception("OrderCreditCardController.CapturePayment: " + GetResponseMessage(response));

 

AuthorizeCode = response.transactionResponse.authCode;

 

//checks for null and All zeros

if (!IsAuthorizeCodeValid(AuthorizeCode)) throw new Exception("OrderCreditCardController.AuthorizePayment:" + response.transactionResponse.responseCode + " " + GetResponseMessage(response));

 


Thank goodness i have found someone else experiencing the same problem.

Roelofje975
Member