cancel
Showing results for 
Search instead for 
Did you mean: 

Accept Hosted Payment IFrameCommunicator

I'm implementing the Hosted Payment form currently in an IFrame using the IFrameCommunicator option. According to this page: https://developer.authorize.net/api/reference/features/accept_hosted.html CancelUrl and Url are optional parameters when the form is imbedded in an iframe.

 

However, the cancel button calls the function (in app-min.js) "cancelContinueBtnHandler" which due to this line: 

 

var w = (x === "continue" ? n.continueURL : n.cancelURL);

w will always be empty string. Then the following line:

 

 if (w && g_iframeCommunicatorUrl.length > 0 && n.isIframeCommunication)

 

will always be false.

 

Which means we hit the else statment (not the iframe communicator).

 

Which does:

 

 if (w) {
                window.location = w
            }

 

Nothing at all.

 

I want to be able to not have a cancel/continue URL just have the iframe communicator tell me that the user clicked cancel. Is that not possible? Do I have to pass in a cancel Url even though I don't want the window to navigate?

Devin
Contributor
5 REPLIES 5

bump

Devin
Contributor

HI @Devin,

 

You do have to set the cancelUrl in order to get a cancel event. So, strictly speaking, the parameter is optional, but if you want to do anything when the cancel button is clicked, you have to send a cancel URL.

 

The good news is that when hosted in an iframe, you'll get a cancel event to act on, so the cancelUrl itself doesn't actually need to be the destination the customer will end up at. It just has to be present to get past the code you referenced.

Just to followup, if you find working with Accept Hosted difficult because of the limitations like the above, might I recommend Accept.js?

 

You can actually now call a hosted payment form from JavaScript in the browser, and then return an encrypted representation of the card data back to your server to do all of the transaction processing server-side. It's the PCI-DSS profile of Accept Hosted without the iFrameCommunicator weirdness.

"You do have to set the cancelUrl in order to get a cancel event. So, strictly speaking, the parameter is optional, but if you want to do anything when the cancel button is clicked, you have to send a cancel URL."

 

Was this in the documentation? Because I have been fighting with getting the Cancel button to do anything, and I think this is why. Could I just set the URL to an empty string?

If you have the form hosted in an iframe, the parameter just needs to have a value for the system to know that it needs to send a cancel event. If all you care about is getting a cancel event, then set the cancelUrl to "https://www.royalbaconsociety.com/hats-of-meat/" if you want. It's just got to be set to something.

 

Once set, when the customer clicks cancel, they're not getting sent to that URL. Instead, you get a cancel event, and you can act accordingly.