cancel
Showing results for 
Search instead for 
Did you mean: 

NULL RESPONSE ISSUE

I HAVE CONFIGURED API LOGIN ID AND TRANSACTION KEY IN MY APPLICATION. I AM TRYING TO USE CHARGECREDITCARD FUNCTIONALITY. I HAVE USED THE CREDIT CARD NUMBERS PROVIDED IN TESTING GUIDE. I LOGGED INTO MY ACCOUNT AND DID THE SAME FROM VIRTUAL TERMINAL WITH THE SAME INPUTS AND IS WORKING IN CORRECT WAY. BUT WHEN I DO THE SAME FROM MY JAVA APPLICATION IT IS SHOWING AS "NULL RESPONSE". CAN YOU PLEASE CLEARLY PROVIDE ME WITH THE REASON BEHIND THE ISSUE AND WHAT CORRECTIONS SHOULD I DO IN ORDER TO SOLVE IT. I AM PASTING MY CODE BELOW.

 

 try {

//Common code to set for all requests
ApiOperationBase.setEnvironment(Environment.SANDBOX);

MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName("23xqS4PE");
merchantAuthenticationType.setTransactionKey("XXXXXXXXXXXX");
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

// Populate the payment data
PaymentType paymentType = new PaymentType();
CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber("5424000000000015");
creditCard.setExpirationDate("0822");
paymentType.setCreditCard(creditCard);

// Create the payment transaction request
TransactionRequestType txnRequest = new TransactionRequestType();
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
txnRequest.setPayment(paymentType);
txnRequest.setAmount(new BigDecimal(10.00));

// Make the API Request
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
apiRequest.setTransactionRequest(txnRequest);
CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute();


CreateTransactionResponse response = controller.getApiResponse();

if (response!=null) {
// If API Response is ok, go ahead and check the transaction response
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
TransactionResponse result = response.getTransactionResponse();
if(result.getMessages() != null){
System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId());
System.out.println("Response Code: " + result.getResponseCode());
System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode());
System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription());
System.out.println("Auth Code: " + result.getAuthCode());
}
else {
System.out.println("Failed Transaction.");
if(response.getTransactionResponse().getErrors() != null){
System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode());
System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
}
}
}
else {
System.out.println("Failed Transaction.");
if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){
System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode());
System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
}
else {
System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode());
System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText());
}
}
}
else {
System.out.println("Null Response.");
}



} catch(Exception e) {
e.printStackTrace();
}

5 REPLIES 5

 

Hi S2ndeepN2mbiarK,

 

Authorize.Net will always send a response even in the event of an error. A null response indicates that there was no successful connection when you attempt to connect to our gateway.

 

Thanks,

Joy

Joy
Administrator Administrator
Administrator

I realize this is over a month old, but I'm having the same issue. My sandbox account and the sample code was working just fine till the other day. Now it doesn't matter what I try to do I get a null response coming back.

 

 

"Authorize.Net will always send a response even in the event of an error. A null response indicates that there was no successful connection when you attempt to connect to our gateway."

 

I don't think this is true. We have many many instances where we get a null pointer back from the Java API call on the execute method. 

 

Even in the Authorize.net example code there's logic around this. The problem is, what are we supposed to do about it? I have baffled customers who have nothing to go on but a cryptic error message in our logs that says: "No response from Authorize.net" That's all we can say.

 

So what is the solution here? Retry? is there better example code (Java hopefully)? because this shouldn't ever happen:

 

CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute();
CreateTransactionResponse response = controller.getApiResponse();

if (response != null) {
// do things
} else {
// log this with a "No response from Authorize.net"
}

 

any guidance would be most appreciated

 

Thanks!

I also am confirming that I am getting null response from Java SDK. It seems to happen when the request is invalid, but it doesn't return the error back in the response. I had to put response != null everywhere in my code, as well as the resultCode, messages, getErrors(), etc.

 

I had to copy the xml request into a separate REST POST to receive the error. It did not return in the JAXB response object.

 

I was getting an error code E00003 - cardCode element is invalid - The value XX is invalid according to its datatype. In that case, <cardCode> was empty. We don't always have the security code available to process a transaction, so I am making it clear not to set the value if it is missing.

kschaller1979
Member

We are using the java sdk version 1.9.2

When we set description text on OrderType (net.authorize.api.contract.v1.OrderType), and the description happens to include the > (greater than) character, we ultimately get a null-pointer exception on CreateTransactionResponse.  e.g, the response object below will be null:

 

CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute(this.environment);

CreateTransactionResponse response = controller.getApiResponse();