cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Accept Hosted Authorize Net Integration issue. No redirection to my localhost after payment

Hi,

 

I am integrating Authorize net  for my website. I am able to generate Token. After getting token i am posting request  on my sandbox account. I am able to make test payment. But after making payment it does not return me back on my website. The Continue button does nothing.

 

 

 

Here is my settings and form request.  Please let me know if there is anything i am missing.

 

 

 

 

<form method="POST" action="https://test.authorize.net/payment/payment" id="DemoCheckoutForm" name="DemoCheckoutForm">
    <input type="hidden" name="token" value="<%=token%>" >
    <input type="submit" name="submit_b" value="Buy now" >
</form>
 
 
public static GetHostedPaymentPageResponse run(String apiLoginId, String transactionKey, Double amount) {
    ApiOperationBase.setEnvironment(Environment.SANDBOX);
    MerchantAuthenticationType merchantAuthenticationType  = new MerchantAuthenticationType() ;
    merchantAuthenticationType.setName(apiLoginId);
    merchantAuthenticationType.setTransactionKey(transactionKey);
    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 setting2 = new SettingType();
    setting2.setSettingName("hostedPaymentOrderOptions");
    setting2.setSettingValue("{\"show\": true}"); 
    setting2.setSettingValue("{\"merchantName\": \"Questions Inc.\"}"); 
    
    SettingType setting1 = new SettingType();
    setting1.setSettingName("hostedPaymentButtonOptions");
    setting1.setSettingValue("{\"text\": \"Pay Now\"}");
    
    
    SettingType setting3 = new SettingType();
    setting3.setSettingName("hostedPaymentReturnOptions");
    setting3.setSettingValue("{\"showReceipt\": true}");
    setting3.setSettingValue("{\"url\": \"http://localhost:8070/wap-adaptor/response.jsp\"}");
    setting3.setSettingValue("{\"urlText\": \"Return\"}");
    setting3.setSettingValue("{\"cancelUrl\": \"http://localhost:8070/wap-adaptor/response.jsp\"}");
    setting3.setSettingValue("{\"cancelUrlText\": \"Cancel\"}");
    
    ArrayOfSetting alist = new ArrayOfSetting();
    alist.getSetting().add(setting1);
    alist.getSetting().add(setting2);
    alist.getSetting().add(setting3);
 
    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) {
System.out.println(response.getMessages().getMessage().get(0).getCode());
            System.out.println(response.getMessages().getMessage().get(0).getText());
            System.out.println(response.getToken());
        }
        else
        {
            System.out.println("Failed to get hosted payment page:  " + response.getMessages().getResultCode()+"  "+response.getMessages().getMessage());
             System.out.println(response.getMessages().getMessage().get(0).getText());
        }
    }
token = response.getToken();
return response;
}
 
 
Any Help would be appeciated.
devenderkumar
Member
6 REPLIES 6

Hi @devenderkumar,

 

When I try a token request using the same settings, I get back a token that pulls up a form with a working "Continue" button, so I'm not sure what might be failing for you.

 

Check the receipt page as rendered in the browser first. If you inspect the "Continue" button, it should reference a cancelContinueBtnHandler on click, which in turn should direct the browser to the url you sent. If you view the source of the receipt page (or frame), there should be a var declared - "g_pageOptions" - with the options you sent. Make sure the url you sent shows correctly there. If so, there's something likely going on at the browser/javascript level. If not, it may be more a problem with your request.

Aaron
All Star

Hi @Aaron,

 

Thanks a lot for looking into my problem.

As per your suggestion i have inspected the recipt page. and looked into g_pageOptions . But surprisingly it is not the same that i am sending into my request. This is what i see in inspection. 

 

var g_merchantData = {
"totalAmount": "10.50"
};
var g_pageOptions = {
"hostedPaymentButtonOptions": {
"text": "Pay Now"
},
"hostedPaymentOrderOptions": {
"show": false
},
"hostedPaymentReturnOptions": {
"cancelUrlText": "Cancel"
}
};
var g_iframeCommunicatorUrl = (!!(typeof g_pageOptions !== 'undefined' && g_pageOptions !== null && g_pageOptions.hostedPaymentIFrameCommunicatorUrl && g_pageOptions.hostedPaymentIFrameCommunicatorUrl.url)) ? g_pageOptions.hostedPaymentIFrameCommunicatorUrl.url : "";

And this is what i sent.

 

 SettingType setting2 = new SettingType();
    setting2.setSettingName("hostedPaymentOrderOptions");
    setting2.setSettingValue("{\"show\": false}"); 
    //setting2.setSettingValue("{\"merchantName\": \"Questions Inc.\"}"); 
    
    SettingType setting1 = new SettingType();
    setting1.setSettingName("hostedPaymentButtonOptions");
    setting1.setSettingValue("{\"text\": \"Pay Now\"}");
    
    
    SettingType setting3 = new SettingType();
    setting3.setSettingName("hostedPaymentReturnOptions");
    setting2.setSettingValue("{\"showReceipt\": false}"); 
    setting3.setSettingValue("{\"url\": \"http://lccse-tomcat.com:8070/authorizenet/response.jsp\"}");
    setting3.setSettingValue("{\"urlText\": \"Continue to site\"}");
    setting3.setSettingValue("{\"cancelUrl\": \"http://lccse-tomcat.com:8070/authorizenet/response.jsp\"}");
    setting3.setSettingValue("{\"cancelUrlText\": \"Cancel\"}");

 

Could you please tell me what could be possible reasons.

Is there any posibility that i am not using HTTPS that why it is removing URLs from my request without giving any error.  Or is there it because i am not using public IP . I am using local system IP i.e localhost.

 

Thanks 

Devender Kumar

Hi @Aaron,

 

I have tried with HTTPS as well but nothing changing in issue. Please also let me know if there is any setting need to done in sendbox account for the same.

 

It appears as if what you're sending is not what the system is getting. Do you have any logging of the actual API request to getHostedPaymentPage to verify what's being sent to the system (meaning the actual XML or JSON formatted string that's posted to our server)?

@Aaron Thanks you so much . I was sending wrong data.

 

 

SettingType setting3 = new SettingType();
    setting3.setSettingName("hostedPaymentReturnOptions");
    setting3.setSettingValue("{\"showReceipt\": true}");
    setting3.setSettingValue("{\"url\": \"http://localhost:8070/wap-adaptor/response.jsp\"}");
    setting3.setSettingValue("{\"urlText\": \"Return\"}");
    setting3.setSettingValue("{\"cancelUrl\": \"http://localhost:8070/wap-adaptor/response.jsp\"}");
    setting3.setSettingValue("{\"cancelUrlText\": \"Cancel\

Here i am doing every thing wrong. I have overrited setting value so only last setting value will be sent to authorize net. I should have done something like below. 

 

 

 

SettingType setting3 = new SettingType();
    setting3.setSettingName("hostedPaymentReturnOptions");
    setting3.setSettingValue("{\"showReceipt\": true,\"url\": \"https://lccse-tomcat.com:8443/authorizenet/response.jsp\","+
    	"\"urlText\": \"Continue to site\",\"cancelUrl\": \"https://lccse-tomcat.com:8443/authorizenet/response.jsp\","+
    	"\"cancelUrlText\": \"Cancel Request\"}");
    	
    SettingType setting4 = new SettingType();
    setting4.setSettingName("hostedPaymentIFrameCommunicatorUrl");
    setting4.setSettingValue("{\"url\": \"https://lccse-tomcat.com:8443/authorizenet/response.jsp\"}");

 

 

Now i am getting response page in my Iframe.  Could you please let me know how to get tranaction data. I can see tranaction data in network option of browser like below.

 

 

{"resultCode":"Ok","messageCode":"Ok","transactionData":{"accountType":"Discover","accountNumber":"XXXX0012","transId":"40004666129","responseCode":"1","authorization":"XCPQAB","merchantName":"Questions Inc.","billTo":{"phoneNumber":"2132133432","firstName":"add","lastName":"asda","address":"asdsa","city":"asda","state":"asd","zip":"23212","country":"USA"},"shipTo":{},"totalAmount":"10.50","dateTime":"6/4/2017 11:36:54 AM"}}

How i will get it into my javascript. The below function never get called.

 

	AuthorizeNetPopup.onReceiveCommunication = function (querystr) {
		var params = parseQueryString(querystr);
		console.log(querystr);
		switch(params["action"]) {
			case "successfulSave":
				AuthorizeNetPopup.closePopup();
				break;
			case "cancel":
				AuthorizeNetPopup.closePopup();
				break;
			case "resizeWindow":
				var w = parseInt(params["width"]);
				var h = parseInt(params["height"]);
				var ifrm = document.getElementById("iframeAuthorizeNet");
				ifrm.style.width = w.toString() + "px";
				ifrm.style.height = h.toString() + "px";
				centerPopup();
				adjustPopupScreen();
				break;
		}
	};

 

Could you please let me know how i would get tranaction response data. 

 

There is one more thing that is happening wrong is that when i use "showReceipt": false in hostedPaymentReturnOptions then after clicking Pay button it shows me Processing but it never return me on my response page. If i use   "showReceipt": true then everything work fine . It show me continue button And after clicking continue button i return back on response page. What could be the possible reason for this issue.

Hi,

 

I am also facing th same issue, that i am successfullly able to open the IFrame pop window to accept the credit card details and goes to show receipt page . but when i click continue button i am not able to get Transaction ID from response into to my page. could you please let me know what should i do to get the response from IFrame to html page?

 

When i check in Google chrome network console i see the response,

{"resultCode":"Ok","messageCode":"Ok","transactionData":{"accountType":"MasterCard","accountNumber":"XXXX0015","transId":"60130039055","responseCode":"1","authorization":"VF2WPA","merchantName":"G and S Questions Inc.","billTo":{"phoneNumber":"","firstName":"Ellen","lastName":"Johnson","address":"14 Main Street","city":"Pecan Springs","state":"TX","zip":"44628","country":"US"},"totalAmount":"20.00","dateTime":"10/28/2019 5:56:35 PM"}}

But i am not able to see the response in the below function, 

AuthorizeNetPopup.onReceiveCommunication = function (querystr) {
var params = parseQueryString(querystr);

switch (params["action"]) {
case "successfulSave":

AuthorizeNetPopup.closePopup();
break;
case "cancel":
AuthorizeNetPopup.closePopup();
break;
case "transactResponse":
var response = params["response"];
document.getElementById("token").value = response;
AuthorizeNetPopup.closePopup();
break;
case "resizeWindow":
alert(params);
var w = parseInt(params["width"]);
var h = parseInt(params["height"]);
var ifrm = document.getElementById("iframeAuthorizeNet");
ifrm.style.width = w.toString() + "px";
ifrm.style.height = h.toString() + "px";
centerPopup();
break;
}
};