Reply
Highlighted
Contributor
Posts: 34
Registered: ‎09-29-2016

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?

Highlighted
Contributor
Posts: 34
Registered: ‎09-29-2016

Re: Accept Hosted Payment IFrameCommunicator

bump

Highlighted
All Star
Posts: 699
Registered: ‎11-03-2016

Re: Accept Hosted Payment IFrameCommunicator

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.

Highlighted
All Star
Posts: 699
Registered: ‎11-03-2016

Re: Accept Hosted Payment IFrameCommunicator

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.

Highlighted
Contributor
Posts: 18
Registered: ‎05-18-2018

Re: Accept Hosted Payment IFrameCommunicator

[ Edited ]

"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?

Highlighted
Contributor
Posts: 15
Registered: ‎11-29-2017

Re: Accept Hosted Payment IFrameCommunicator

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.