Reply
Member
Posts: 1
Registered: ‎12-27-2020

Sandbox Accept Hosted Relay Response not working

I am try to integrate Authorize.net Accept hosted Form redirect method in java using Authorize.net java sdk in spring boot. First thing I have done in my code request for the form token by passing details as suggested in develop api reference for accep hosted form. Below is my code:-

public String getFormToken(String amount) {
		ApiOperationBase.setEnvironment(Environment.SANDBOX);
        MerchantAuthenticationType merchantAuthenticationType  = new MerchantAuthenticationType() ;
        merchantAuthenticationType.setName(ticketComponent.getApiLoginId());
        merchantAuthenticationType.setTransactionKey(ticketComponent.getTransactionKey());
        ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
        
        // Create the payment transaction request
        TransactionRequestType txnRequest = new TransactionRequestType();
        txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
        txnRequest.setAmount(new BigDecimal(amount).setScale(2, RoundingMode.CEILING));
        SettingType setting = new SettingType();
        setting.setSettingName("hostedPaymentReturnOptions");
        setting.setSettingValue("{\"showReceipt\":true, \"url\":\"http://localhost:8080/ticket/receipt\", \"urlText\":\"Return to Merchant website\", \"cancelUrl\": \"http://localhost:8080/ticket/cancel\", \"cancelUrlText\": \"Cancel\"}");
        
        SettingType setting1 = new SettingType();
        setting1.setSettingName("hostedPaymentButtonOptions");
        setting1.setSettingValue("{\"text\": \"Pay\"}");
        
        SettingType setting2 = new SettingType();
        setting2.setSettingName("hostedPaymentOrderOptions");
        setting2.setSettingValue("{\"show\": false}");

        ArrayOfSetting alist = new ArrayOfSetting();
        alist.getSetting().add(setting1);
        alist.getSetting().add(setting2);

        GetHostedPaymentPageRequest apiRequest = new GetHostedPaymentPageRequest();
        apiRequest.setTransactionRequest(txnRequest);
        apiRequest.setHostedPaymentSettings(alist);

        GetHostedPaymentPageController controller = new GetHostedPaymentPageController(apiRequest);
        controller.execute();
       
        GetHostedPaymentPageResponse response = new GetHostedPaymentPageResponse();
		response = controller.getApiResponse();

		if (response!=null) {

             if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
            	 return response.getToken();
            }
            else{
                System.err.println("Failed to get hosted payment page:  " + response.getMessages().getResultCode());
            }
        }
		return "Form token request failed";

	}

I have tested this code on local and then on public ip using ec2 instance. 

I have register the Relay Response url in the sanbox account under the relay and receipt url link as suggested by the developer on authorize.net according to there requirement for relay response.

 

Problem:- 

My relay url is not hit by the Authorize.net server. I am not getting any response from the Authorize.net servers. Payment form show successfully and I received successfull payment request. But not getting resonse in relay url. 

 

My relay response url is hosted on public ip, there no query string, I have try different url 

e.g:- http://<ec2-ip>:8080/response and http://<ec2-dns-name>:8080/response still not getting any response from the Authorize.net server. I have try both GET and POST methods.

 

Any suggestion?