cancel
Showing results for 
Search instead for 
Did you mean: 

getting connect time out to apitest.authorize.net:443?

hello community

we have a grails app. you can consider it a java app. we have integrated authorize.net for accepting payments via credit card. I have used accept.js library.

the part of code that sends request to authorize.net to charge credit card is as follows

 

def descriptor = params['dataDescriptor']
def value = params['dataValue']


String firstName = params[AuthNetField.X_FIRST_NAME.fieldName]
String lastName = params[AuthNetField.X_LAST_NAME.fieldName]
String address = params[AuthNetField.X_ADDRESS.fieldName]
String city = params[AuthNetField.X_CITY.fieldName]
String state = params[AuthNetField.X_STATE.fieldName]
String zip = params[AuthNetField.X_ZIP.fieldName]
String country = params[AuthNetField.X_COUNTRY.fieldName]
String phone = params[AuthNetField.X_PHONE.fieldName]
String email = params[AuthNetField.X_EMAIL.fieldName]

String apiLoginId = grailsApplication.config.net.authorize.apiLoginId


if (grailsApplication.config.net.authorize.environment == net.authorize.Environment.PRODUCTION){
ApiOperationBase.setEnvironment(Environment.PRODUCTION);
}
else{
ApiOperationBase.setEnvironment(Environment.SANDBOX);
}

String transactionKey = grailsApplication.config.net.authorize.transactionKey


MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

// Populate the payment data
PaymentType paymentType = new PaymentType();
OpaqueDataType OpaqueData = new OpaqueDataType();
OpaqueData.setDataDescriptor(descriptor);
OpaqueData.setDataValue(value);
paymentType.setOpaqueData(OpaqueData);


CustomerDataType cdt = new CustomerDataType()
cdt.setEmail(email)

CustomerAddressType customerType = new CustomerAddressType()
customerType.setFirstName(firstName)
customerType.setLastName(lastName)
customerType.setAddress(address)
customerType.setCity(city)
customerType.setState(state)
customerType.setZip(zip)
customerType.setCountry(country)
customerType.setPhoneNumber(phone)

// Create the payment transaction request
TransactionRequestType txnRequest = new TransactionRequestType();
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
txnRequest.setPayment(paymentType);
txnRequest.setBillTo(customerType)
txnRequest.setCustomer(cdt)

ArrayOfLineItem aol = new ArrayOfLineItem()


itemizedOrderEntries.each { io ->

def parts = io.split("<\\|>")

LineItemType lit = new LineItemType()
lit.setItemId(parts[0])
lit.setName(parts[1])
lit.setDescription(parts[2])
lit.setQuantity(parts[3].toBigDecimal())
lit.setUnitPrice(parts[4].toBigDecimal())
lit.setTaxable(parts[5].toBoolean())


aol.lineItem.add(lit)


}


txnRequest.setLineItems(aol)


txnRequest.setAmount(total.setScale(2, RoundingMode.CEILING));


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


CreateTransactionResponse tresponse = controller.getApiResponse();

When the execute() method is called the app sends request to test api but i am getting connect time out

 I have pasted the error below.

2023-01-28 23:53:17.082 ERROR --- [pool-4-thread-1] net.authorize.util.HttpCallTask : Http request execute failed: 'Connect to apitest.authorize.net:443 [apitest.authorize.net/198.241.206.22] failed: connect timed out'
2023-01-28 23:53:17.082 WARN --- [pool-4-thread-1] net.authorize.util.HttpCallTask : Adding ErrorMessage: Code: 'org.apache.http.conn.ConnectTimeoutException', Text: 'Connect to apitest.authorize.net:443 [apitest.authorize.net/198.241.206.22] failed: connect timed out'
2023-01-28 23:53:17.083 ERROR --- [nio-8443-exec-3] n.a.a.controller.base.ApiOperationBase : Invalid response:'net.authorize.api.contract.v1.ANetApiResponse@6744ad91'
2023-01-28 23:53:17.091 ERROR --- [nio-8443-exec-3] StackTrace : Full Stack Trace:

When i run the app locally in my system it can successfully connect to the api link but when i run it remotely i.e our web app is hosted at Hetzner server, it gives connect time out error.

do you know what is causing this connect timeout?

i appreciate any guide.

Thanks

sanjaygir
Member
1 ACCEPTED SOLUTION

Accepted Solutions

i got it to work after switching to another server location. it seems like authorize.net blocked ips at oregon location.

View solution in original post

2 REPLIES 2
sanjaygir
Member

i got it to work after switching to another server location. it seems like authorize.net blocked ips at oregon location.