<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic no action=transactResponse in Accept Hosted iframe for Authorize.net in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/no-action-transactResponse-in-Accept-Hosted-iframe-for-Authorize/m-p/78831#M49546</link>
    <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200"&gt;I'm trying to implement the Authorize.net Accept Hosted hosted checkout solution in a Coldfusion application.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="s-prose js-post-body"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(For all the ColdFusion developers, this code run on BlueDragon.NET 9 which a CF9 implementation. The cfscript stacktrace support is terrible which is why this code is in tags and not in cfscript.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using our sandbox authorize.net account, the iframe hosted checkout page shows up. I can fill out the credit card info and submit. I get the receipt, 2 receipt emails from authorize.net and get sent to the confirmation page, but the case "transactResponse" in AuthorizeNetIFrame.onReceiveCommunication never gets triggered. I put a alert in the javascript function to see all the querystrings that come into the iframe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than the coldfusion code to authenticate and get the token (which seems to work) I got the rest of the code from the Authorize.net documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why I don't see the action=transactResponse query string come into iframe with the response from the authorize.net credit card transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this with a live authorize.net account as well and I get a 'User authentication failed due to invalid authentication values.' on the iframe payment page even though I can authenticate and get a token for the iframe successfully. What am I missing. Any help would be appreciated.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sensitive parts of the code (i.e. credentials), email, and address have been redacted.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here's the code for the page with the iframe:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;title&amp;gt;HostedPayment Test Page&amp;lt;/title&amp;gt;
	&amp;lt;script src="https://code.jquery.com/jquery-3.6.0.js"
			integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
			crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;
	&amp;lt;script type="text/javascript"&amp;gt;

		$(function () {

			$("#btnOpenAuthorizeNetIFrame").click(function () {
				$("#add_payment").show();
				$("#send_token").attr({ "action": "https://test.authorize.net/payment/payment", "target": "add_payment" }).submit();
				$(window).scrollTop($('#add_payment').offset().top - 50);
			});

		});


&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;cfif NOT IsDefined("url.CFID") or NOT IsDefined("url.CFTOKEN")&amp;gt;
	&amp;lt;p style="color: red;"&amp;gt;Error: CFID and CFTOKEN required as URL parameters...&amp;lt;/p&amp;gt;
	&amp;lt;cfabort /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfinclude template="../#client.custom_path#/constants.cfm" /&amp;gt;

&amp;lt;cfset variables.LOGIN_TOKEN_URL = "https://apitest.authorize.net/xml/v1/request.api" /&amp;gt;
&amp;lt;cfset variables.API_LOGIN_ID = "ZZZZZZZZZZZ" /&amp;gt;
&amp;lt;cfset variables.TRANSACTION_KEY = "ZZZZZZZZZZZZZZ" /&amp;gt;

&amp;lt;h2&amp;gt;Authenticate&amp;lt;/h2&amp;gt;

&amp;lt;cfoutput&amp;gt;
&amp;lt;cfsavecontent variable="variables.soapBody"&amp;gt;
&amp;lt;authenticateTestRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
    &amp;lt;merchantAuthentication&amp;gt;
        &amp;lt;name&amp;gt;#variables.API_LOGIN_ID#&amp;lt;/name&amp;gt;
        &amp;lt;transactionKey&amp;gt;#variables.TRANSACTION_KEY#&amp;lt;/transactionKey&amp;gt;
    &amp;lt;/merchantAuthentication&amp;gt;
&amp;lt;/authenticateTestRequest&amp;gt;
&amp;lt;/cfsavecontent&amp;gt;
&amp;lt;/cfoutput&amp;gt;

&amp;lt;cfhttp url="#variables.LOGIN_TOKEN_URL#"
	method="post"
	result="variables.result1"&amp;gt;
	&amp;lt;cfhttpparam
		type="xml"
		value="#Trim( variables.soapBody )#"
		/&amp;gt;
&amp;lt;/cfhttp&amp;gt;

&amp;lt;cfdump var="#variables.result1#" /&amp;gt;

&amp;lt;cfset variables.response1 = XMLParse(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1))) /&amp;gt;
&amp;lt;cfset variables.response = StructNew() /&amp;gt;

&amp;lt;cfset variables.response.resultCode = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'resultCode' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.resultCode[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.resultCode = variables.response.resultCode[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.response.code = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'code' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.code[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.code = variables.response.code[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.response.text = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'text' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.text[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.text = variables.response.text[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfif IsDefined("variables.response.text") AND FindNoCase("Successful", variables.response.text)&amp;gt;
	&amp;lt;p style="color: green; font-weight: bold;"&amp;gt;Success&amp;lt;/p&amp;gt;
&amp;lt;cfelse&amp;gt;
	&amp;lt;p style="color: red; font-weight: bold;"&amp;gt;Failure&amp;lt;/p&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfdump var="#variables.response#" /&amp;gt;
&amp;lt;cfdump var="#variables.response1#" /&amp;gt;

&amp;lt;h2&amp;gt;Get token&amp;lt;/h2&amp;gt;

&amp;lt;cfoutput&amp;gt;
&amp;lt;cfsavecontent variable="variables.soapBody2"&amp;gt;
&amp;lt;getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
  &amp;lt;merchantAuthentication&amp;gt;
    &amp;lt;name&amp;gt;#variables.API_LOGIN_ID#&amp;lt;/name&amp;gt;
    &amp;lt;transactionKey&amp;gt;#variables.TRANSACTION_KEY#&amp;lt;/transactionKey&amp;gt;
  &amp;lt;/merchantAuthentication&amp;gt;
  &amp;lt;transactionRequest&amp;gt;
    &amp;lt;transactionType&amp;gt;authCaptureTransaction&amp;lt;/transactionType&amp;gt;
    &amp;lt;amount&amp;gt;0.01&amp;lt;/amount&amp;gt;
    &amp;lt;customer&amp;gt;
      &amp;lt;email&amp;gt;ZZZZZZZZ@ZZZZZZZZ.com&amp;lt;/email&amp;gt;
    &amp;lt;/customer&amp;gt;
    &amp;lt;billTo&amp;gt;
        &amp;lt;firstName&amp;gt;ZZZZZZZZ&amp;lt;/firstName&amp;gt;
        &amp;lt;lastName&amp;gt;Tester1&amp;lt;/lastName&amp;gt;
        &amp;lt;company&amp;gt;&amp;lt;/company&amp;gt;
        &amp;lt;address&amp;gt;123 Main Street&amp;lt;/address&amp;gt;
        &amp;lt;city&amp;gt;ZZZZZZZZ&amp;lt;/city&amp;gt;
        &amp;lt;state&amp;gt;ZZ&amp;lt;/state&amp;gt;
        &amp;lt;zip&amp;gt;22222&amp;lt;/zip&amp;gt;
        &amp;lt;country&amp;gt;US&amp;lt;/country&amp;gt;
    &amp;lt;/billTo&amp;gt;
  &amp;lt;/transactionRequest&amp;gt;
  &amp;lt;hostedPaymentSettings&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentReturnOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"showReceipt": true, "url": "https://ZZZZZZZZ.com/test/hosted_pages/cart_hosted_confirm.cfm", "urlText": "Continue", "cancelUrl": "https://ZZZZZZZZ.com/test/hosted_pages/cart_hosted_cancel.cfm", "cancelUrlText": "Cancel"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentButtonOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"text": "Pay"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentStyleOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"bgColor": "blue"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentPaymentOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"cardCodeRequired": true, "showCreditCard": true, "showBankAccount": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentSecurityOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"captcha": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentShippingAddressOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": false, "required": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentBillingAddressOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": true, "required":true}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentCustomerOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"showEmail": true, "requiredEmail": true, "addPaymentProfile": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentOrderOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": true, "merchantName": "Test Company, LLC"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
	&amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentIFrameCommunicatorUrl&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"url": "https://ZZZZZZZZ.com/test/hosted_pages/IFrameCommunicator.html"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
  &amp;lt;/hostedPaymentSettings&amp;gt;
&amp;lt;/getHostedPaymentPageRequest&amp;gt;
&amp;lt;/cfsavecontent&amp;gt;
&amp;lt;/cfoutput&amp;gt;

&amp;lt;cfhttp url="#variables.LOGIN_TOKEN_URL#"
	method="post"
	result="variables.result2"&amp;gt;
	&amp;lt;cfhttpparam
		type="xml"
		value="#Trim( variables.soapBody2 )#"
		/&amp;gt;
&amp;lt;/cfhttp&amp;gt;

&amp;lt;cfdump var="#variables.result2#" /&amp;gt;

&amp;lt;cfset variables.response2 = XMLParse(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1))) /&amp;gt;
&amp;lt;cfset variables.responseToken = StructNew() /&amp;gt;

&amp;lt;cfset variables.responseToken.resultCode = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'resultCode' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.resultCode[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.resultCode = variables.responseToken.resultCode[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.responseToken.code = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'code' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.code[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.code = variables.responseToken.code[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.responseToken.text = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'text' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.text[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.text = variables.responseToken.text[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfif IsDefined("variables.responseToken.text") AND FindNoCase("Successful", variables.responseToken.text)&amp;gt;
	&amp;lt;p style="color: green; font-weight: bold;"&amp;gt;Success&amp;lt;/p&amp;gt;
	
	&amp;lt;cfset variables.responseToken.token = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'token' ]"
	) /&amp;gt;
	&amp;lt;cfif IsDefined("variables.responseToken.token[1].XmlText")&amp;gt;
		&amp;lt;cfset variables.responseToken.token = variables.responseToken.token[1].XmlText /&amp;gt;
	&amp;lt;/cfif&amp;gt;
&amp;lt;cfelse&amp;gt;
	&amp;lt;p style="color: red; font-weight: bold;"&amp;gt;Failure&amp;lt;/p&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfdump var="#variables.response2#" /&amp;gt;
&amp;lt;cfdump var="#variables.responseToken#" /&amp;gt;

&amp;lt;h2&amp;gt;Hosted Page&amp;lt;/h2&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.token") AND Len(Trim(variables.responseToken.token)) GT 0&amp;gt;

	&amp;lt;div&amp;gt;
	Open Authorize.net in an iframe to complete transaction
	&amp;lt;button id="btnOpenAuthorizeNetIFrame" onclick=""&amp;gt;Show Payment Form&amp;lt;/button&amp;gt;
	&amp;lt;/div&amp;gt;
	&amp;lt;div id="iframe_holder" class="center-block" style="width:90%;max-width: 1000px"&amp;gt;
	&amp;lt;iframe id="add_payment" class="embed-responsive-item panel" name="add_payment" width="100%"  frameborder="0" scrolling="no" hidden="true"&amp;gt;
	&amp;lt;/iframe&amp;gt;
	&amp;lt;/div&amp;gt;
	&amp;lt;cfoutput&amp;gt;
	&amp;lt;form id="send_token" action="" method="post" target="add_payment"&amp;gt;
	&amp;lt;input type="hidden" name="token" value="#variables.responseToken.token#" /&amp;gt;
	&amp;lt;/form&amp;gt;	
	&amp;lt;/cfoutput&amp;gt;
	
	&amp;lt;script type="text/javascript"&amp;gt;
		(function () {
			if (!window.AuthorizeNetIFrame) window.AuthorizeNetIFrame = {};
				AuthorizeNetIFrame.onReceiveCommunication = function (querystr) {
				
					alert('processing 1:'+querystr);
					
					var params = parseQueryString(querystr);
						switch (params["action"]) {
							case "successfulSave":
								break;
							case "cancel":
								break;
							case "resizeWindow":
								var w = parseInt(params["width"]);
								var h = parseInt(params["height"]);
								var ifrm = document.getElementById("add_payment");
								ifrm.style.width = w.toString() + "px";
								ifrm.style.height = h.toString() + "px";
								break;
							case "transactResponse":
								var ifrm = document.getElementById("add_payment");
								ifrm.style.display = 'none';
								
								var formData = { gatewayResponse: params["response"] };
								$.ajax({
									url: "cart_hosted_async_log.cfm?&amp;lt;cfoutput&amp;gt;#URLTOKEN#&amp;lt;/cfoutput&amp;gt;",
									type: "POST",
									data: formData,
									success: function(data, textStatus, jqXHR)
									{},
									error: function (jqXHR, textStatus, errorThrown)
									{}
								});
								break;
							}
					};

				function parseQueryString(str) {
					var vars = [];
					var arr = str.split('&amp;amp;');
					var pair;
					for (var i = 0; i &amp;lt; arr.length; i++) {
						pair = arr[i].split('=');
						vars.push(pair[0]);
						vars[pair[0]] = unescape(pair[1]);
						}
					return vars;
					}
		}());
	&amp;lt;/script&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;Here's the code for the IFrameCommunicator.html&lt;/P&gt;&lt;PRE&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;title&amp;gt;Iframe Communicator&amp;lt;/title&amp;gt;
	&amp;lt;script type="text/javascript"&amp;gt;
		//&amp;lt;![CDATA[
			function callParentFunction(str) {
				if (str &amp;amp;&amp;amp; str.length &amp;gt; 0 
					&amp;amp;&amp;amp; window.parent 
					&amp;amp;&amp;amp; window.parent.parent
					&amp;amp;&amp;amp; window.parent.parent.AuthorizeNetIFrame 
					&amp;amp;&amp;amp; window.parent.parent.AuthorizeNetIFrame.onReceiveCommunication)
					{
// Errors indicate a mismatch in domain between the page containing the iframe and this page.
						window.parent.parent.AuthorizeNetIFrame.onReceiveCommunication(str);
					}
				}

			function receiveMessage(event) {
				if (event &amp;amp;&amp;amp; event.data) {
					callParentFunction(event.data);
					}
				}

				if (window.addEventListener) {
					window.addEventListener("message", receiveMessage, false);
					} else if (window.attachEvent) {
						window.attachEvent("onmessage", receiveMessage);
					}

				if (window.location.hash &amp;amp;&amp;amp; window.location.hash.length &amp;gt; 1) {
					callParentFunction(window.location.hash.substring(1));
					}
		//]]/&amp;gt;
	&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Sep 2021 16:58:08 GMT</pubDate>
    <dc:creator>amikhail</dc:creator>
    <dc:date>2021-09-28T16:58:08Z</dc:date>
    <item>
      <title>no action=transactResponse in Accept Hosted iframe for Authorize.net</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/no-action-transactResponse-in-Accept-Hosted-iframe-for-Authorize/m-p/78831#M49546</link>
      <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="js-voting-container d-flex jc-center fd-column ai-stretch gs4 fc-black-200"&gt;I'm trying to implement the Authorize.net Accept Hosted hosted checkout solution in a Coldfusion application.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="s-prose js-post-body"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(For all the ColdFusion developers, this code run on BlueDragon.NET 9 which a CF9 implementation. The cfscript stacktrace support is terrible which is why this code is in tags and not in cfscript.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using our sandbox authorize.net account, the iframe hosted checkout page shows up. I can fill out the credit card info and submit. I get the receipt, 2 receipt emails from authorize.net and get sent to the confirmation page, but the case "transactResponse" in AuthorizeNetIFrame.onReceiveCommunication never gets triggered. I put a alert in the javascript function to see all the querystrings that come into the iframe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than the coldfusion code to authenticate and get the token (which seems to work) I got the rest of the code from the Authorize.net documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why I don't see the action=transactResponse query string come into iframe with the response from the authorize.net credit card transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this with a live authorize.net account as well and I get a 'User authentication failed due to invalid authentication values.' on the iframe payment page even though I can authenticate and get a token for the iframe successfully. What am I missing. Any help would be appreciated.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sensitive parts of the code (i.e. credentials), email, and address have been redacted.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here's the code for the page with the iframe:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;title&amp;gt;HostedPayment Test Page&amp;lt;/title&amp;gt;
	&amp;lt;script src="https://code.jquery.com/jquery-3.6.0.js"
			integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
			crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;
	&amp;lt;script type="text/javascript"&amp;gt;

		$(function () {

			$("#btnOpenAuthorizeNetIFrame").click(function () {
				$("#add_payment").show();
				$("#send_token").attr({ "action": "https://test.authorize.net/payment/payment", "target": "add_payment" }).submit();
				$(window).scrollTop($('#add_payment').offset().top - 50);
			});

		});


&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;cfif NOT IsDefined("url.CFID") or NOT IsDefined("url.CFTOKEN")&amp;gt;
	&amp;lt;p style="color: red;"&amp;gt;Error: CFID and CFTOKEN required as URL parameters...&amp;lt;/p&amp;gt;
	&amp;lt;cfabort /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfinclude template="../#client.custom_path#/constants.cfm" /&amp;gt;

&amp;lt;cfset variables.LOGIN_TOKEN_URL = "https://apitest.authorize.net/xml/v1/request.api" /&amp;gt;
&amp;lt;cfset variables.API_LOGIN_ID = "ZZZZZZZZZZZ" /&amp;gt;
&amp;lt;cfset variables.TRANSACTION_KEY = "ZZZZZZZZZZZZZZ" /&amp;gt;

&amp;lt;h2&amp;gt;Authenticate&amp;lt;/h2&amp;gt;

&amp;lt;cfoutput&amp;gt;
&amp;lt;cfsavecontent variable="variables.soapBody"&amp;gt;
&amp;lt;authenticateTestRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
    &amp;lt;merchantAuthentication&amp;gt;
        &amp;lt;name&amp;gt;#variables.API_LOGIN_ID#&amp;lt;/name&amp;gt;
        &amp;lt;transactionKey&amp;gt;#variables.TRANSACTION_KEY#&amp;lt;/transactionKey&amp;gt;
    &amp;lt;/merchantAuthentication&amp;gt;
&amp;lt;/authenticateTestRequest&amp;gt;
&amp;lt;/cfsavecontent&amp;gt;
&amp;lt;/cfoutput&amp;gt;

&amp;lt;cfhttp url="#variables.LOGIN_TOKEN_URL#"
	method="post"
	result="variables.result1"&amp;gt;
	&amp;lt;cfhttpparam
		type="xml"
		value="#Trim( variables.soapBody )#"
		/&amp;gt;
&amp;lt;/cfhttp&amp;gt;

&amp;lt;cfdump var="#variables.result1#" /&amp;gt;

&amp;lt;cfset variables.response1 = XMLParse(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1))) /&amp;gt;
&amp;lt;cfset variables.response = StructNew() /&amp;gt;

&amp;lt;cfset variables.response.resultCode = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'resultCode' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.resultCode[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.resultCode = variables.response.resultCode[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.response.code = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'code' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.code[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.code = variables.response.code[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.response.text = xmlSearch(Trim(Right(variables.result1.filecontent, Len(variables.result1.filecontent)-1)),
	"//*[ local-name() = 'text' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.response.text[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.response.text = variables.response.text[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfif IsDefined("variables.response.text") AND FindNoCase("Successful", variables.response.text)&amp;gt;
	&amp;lt;p style="color: green; font-weight: bold;"&amp;gt;Success&amp;lt;/p&amp;gt;
&amp;lt;cfelse&amp;gt;
	&amp;lt;p style="color: red; font-weight: bold;"&amp;gt;Failure&amp;lt;/p&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfdump var="#variables.response#" /&amp;gt;
&amp;lt;cfdump var="#variables.response1#" /&amp;gt;

&amp;lt;h2&amp;gt;Get token&amp;lt;/h2&amp;gt;

&amp;lt;cfoutput&amp;gt;
&amp;lt;cfsavecontent variable="variables.soapBody2"&amp;gt;
&amp;lt;getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"&amp;gt;
  &amp;lt;merchantAuthentication&amp;gt;
    &amp;lt;name&amp;gt;#variables.API_LOGIN_ID#&amp;lt;/name&amp;gt;
    &amp;lt;transactionKey&amp;gt;#variables.TRANSACTION_KEY#&amp;lt;/transactionKey&amp;gt;
  &amp;lt;/merchantAuthentication&amp;gt;
  &amp;lt;transactionRequest&amp;gt;
    &amp;lt;transactionType&amp;gt;authCaptureTransaction&amp;lt;/transactionType&amp;gt;
    &amp;lt;amount&amp;gt;0.01&amp;lt;/amount&amp;gt;
    &amp;lt;customer&amp;gt;
      &amp;lt;email&amp;gt;ZZZZZZZZ@ZZZZZZZZ.com&amp;lt;/email&amp;gt;
    &amp;lt;/customer&amp;gt;
    &amp;lt;billTo&amp;gt;
        &amp;lt;firstName&amp;gt;ZZZZZZZZ&amp;lt;/firstName&amp;gt;
        &amp;lt;lastName&amp;gt;Tester1&amp;lt;/lastName&amp;gt;
        &amp;lt;company&amp;gt;&amp;lt;/company&amp;gt;
        &amp;lt;address&amp;gt;123 Main Street&amp;lt;/address&amp;gt;
        &amp;lt;city&amp;gt;ZZZZZZZZ&amp;lt;/city&amp;gt;
        &amp;lt;state&amp;gt;ZZ&amp;lt;/state&amp;gt;
        &amp;lt;zip&amp;gt;22222&amp;lt;/zip&amp;gt;
        &amp;lt;country&amp;gt;US&amp;lt;/country&amp;gt;
    &amp;lt;/billTo&amp;gt;
  &amp;lt;/transactionRequest&amp;gt;
  &amp;lt;hostedPaymentSettings&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentReturnOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"showReceipt": true, "url": "https://ZZZZZZZZ.com/test/hosted_pages/cart_hosted_confirm.cfm", "urlText": "Continue", "cancelUrl": "https://ZZZZZZZZ.com/test/hosted_pages/cart_hosted_cancel.cfm", "cancelUrlText": "Cancel"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentButtonOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"text": "Pay"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentStyleOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"bgColor": "blue"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentPaymentOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"cardCodeRequired": true, "showCreditCard": true, "showBankAccount": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentSecurityOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"captcha": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentShippingAddressOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": false, "required": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentBillingAddressOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": true, "required":true}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentCustomerOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"showEmail": true, "requiredEmail": true, "addPaymentProfile": false}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
    &amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentOrderOptions&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"show": true, "merchantName": "Test Company, LLC"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
	&amp;lt;setting&amp;gt;
      &amp;lt;settingName&amp;gt;hostedPaymentIFrameCommunicatorUrl&amp;lt;/settingName&amp;gt;
      &amp;lt;settingValue&amp;gt;{"url": "https://ZZZZZZZZ.com/test/hosted_pages/IFrameCommunicator.html"}&amp;lt;/settingValue&amp;gt;
    &amp;lt;/setting&amp;gt;
  &amp;lt;/hostedPaymentSettings&amp;gt;
&amp;lt;/getHostedPaymentPageRequest&amp;gt;
&amp;lt;/cfsavecontent&amp;gt;
&amp;lt;/cfoutput&amp;gt;

&amp;lt;cfhttp url="#variables.LOGIN_TOKEN_URL#"
	method="post"
	result="variables.result2"&amp;gt;
	&amp;lt;cfhttpparam
		type="xml"
		value="#Trim( variables.soapBody2 )#"
		/&amp;gt;
&amp;lt;/cfhttp&amp;gt;

&amp;lt;cfdump var="#variables.result2#" /&amp;gt;

&amp;lt;cfset variables.response2 = XMLParse(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1))) /&amp;gt;
&amp;lt;cfset variables.responseToken = StructNew() /&amp;gt;

&amp;lt;cfset variables.responseToken.resultCode = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'resultCode' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.resultCode[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.resultCode = variables.responseToken.resultCode[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.responseToken.code = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'code' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.code[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.code = variables.responseToken.code[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfset variables.responseToken.text = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'text' ]"
	) /&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.text[1].XmlText")&amp;gt;
	&amp;lt;cfset variables.responseToken.text = variables.responseToken.text[1].XmlText /&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfif IsDefined("variables.responseToken.text") AND FindNoCase("Successful", variables.responseToken.text)&amp;gt;
	&amp;lt;p style="color: green; font-weight: bold;"&amp;gt;Success&amp;lt;/p&amp;gt;
	
	&amp;lt;cfset variables.responseToken.token = xmlSearch(Trim(Right(variables.result2.filecontent, Len(variables.result2.filecontent)-1)),
	"//*[ local-name() = 'token' ]"
	) /&amp;gt;
	&amp;lt;cfif IsDefined("variables.responseToken.token[1].XmlText")&amp;gt;
		&amp;lt;cfset variables.responseToken.token = variables.responseToken.token[1].XmlText /&amp;gt;
	&amp;lt;/cfif&amp;gt;
&amp;lt;cfelse&amp;gt;
	&amp;lt;p style="color: red; font-weight: bold;"&amp;gt;Failure&amp;lt;/p&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;cfdump var="#variables.response2#" /&amp;gt;
&amp;lt;cfdump var="#variables.responseToken#" /&amp;gt;

&amp;lt;h2&amp;gt;Hosted Page&amp;lt;/h2&amp;gt;
&amp;lt;cfif IsDefined("variables.responseToken.token") AND Len(Trim(variables.responseToken.token)) GT 0&amp;gt;

	&amp;lt;div&amp;gt;
	Open Authorize.net in an iframe to complete transaction
	&amp;lt;button id="btnOpenAuthorizeNetIFrame" onclick=""&amp;gt;Show Payment Form&amp;lt;/button&amp;gt;
	&amp;lt;/div&amp;gt;
	&amp;lt;div id="iframe_holder" class="center-block" style="width:90%;max-width: 1000px"&amp;gt;
	&amp;lt;iframe id="add_payment" class="embed-responsive-item panel" name="add_payment" width="100%"  frameborder="0" scrolling="no" hidden="true"&amp;gt;
	&amp;lt;/iframe&amp;gt;
	&amp;lt;/div&amp;gt;
	&amp;lt;cfoutput&amp;gt;
	&amp;lt;form id="send_token" action="" method="post" target="add_payment"&amp;gt;
	&amp;lt;input type="hidden" name="token" value="#variables.responseToken.token#" /&amp;gt;
	&amp;lt;/form&amp;gt;	
	&amp;lt;/cfoutput&amp;gt;
	
	&amp;lt;script type="text/javascript"&amp;gt;
		(function () {
			if (!window.AuthorizeNetIFrame) window.AuthorizeNetIFrame = {};
				AuthorizeNetIFrame.onReceiveCommunication = function (querystr) {
				
					alert('processing 1:'+querystr);
					
					var params = parseQueryString(querystr);
						switch (params["action"]) {
							case "successfulSave":
								break;
							case "cancel":
								break;
							case "resizeWindow":
								var w = parseInt(params["width"]);
								var h = parseInt(params["height"]);
								var ifrm = document.getElementById("add_payment");
								ifrm.style.width = w.toString() + "px";
								ifrm.style.height = h.toString() + "px";
								break;
							case "transactResponse":
								var ifrm = document.getElementById("add_payment");
								ifrm.style.display = 'none';
								
								var formData = { gatewayResponse: params["response"] };
								$.ajax({
									url: "cart_hosted_async_log.cfm?&amp;lt;cfoutput&amp;gt;#URLTOKEN#&amp;lt;/cfoutput&amp;gt;",
									type: "POST",
									data: formData,
									success: function(data, textStatus, jqXHR)
									{},
									error: function (jqXHR, textStatus, errorThrown)
									{}
								});
								break;
							}
					};

				function parseQueryString(str) {
					var vars = [];
					var arr = str.split('&amp;amp;');
					var pair;
					for (var i = 0; i &amp;lt; arr.length; i++) {
						pair = arr[i].split('=');
						vars.push(pair[0]);
						vars[pair[0]] = unescape(pair[1]);
						}
					return vars;
					}
		}());
	&amp;lt;/script&amp;gt;
&amp;lt;/cfif&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;Here's the code for the IFrameCommunicator.html&lt;/P&gt;&lt;PRE&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;title&amp;gt;Iframe Communicator&amp;lt;/title&amp;gt;
	&amp;lt;script type="text/javascript"&amp;gt;
		//&amp;lt;![CDATA[
			function callParentFunction(str) {
				if (str &amp;amp;&amp;amp; str.length &amp;gt; 0 
					&amp;amp;&amp;amp; window.parent 
					&amp;amp;&amp;amp; window.parent.parent
					&amp;amp;&amp;amp; window.parent.parent.AuthorizeNetIFrame 
					&amp;amp;&amp;amp; window.parent.parent.AuthorizeNetIFrame.onReceiveCommunication)
					{
// Errors indicate a mismatch in domain between the page containing the iframe and this page.
						window.parent.parent.AuthorizeNetIFrame.onReceiveCommunication(str);
					}
				}

			function receiveMessage(event) {
				if (event &amp;amp;&amp;amp; event.data) {
					callParentFunction(event.data);
					}
				}

				if (window.addEventListener) {
					window.addEventListener("message", receiveMessage, false);
					} else if (window.attachEvent) {
						window.attachEvent("onmessage", receiveMessage);
					}

				if (window.location.hash &amp;amp;&amp;amp; window.location.hash.length &amp;gt; 1) {
					callParentFunction(window.location.hash.substring(1));
					}
		//]]/&amp;gt;
	&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 16:58:08 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/no-action-transactResponse-in-Accept-Hosted-iframe-for-Authorize/m-p/78831#M49546</guid>
      <dc:creator>amikhail</dc:creator>
      <dc:date>2021-09-28T16:58:08Z</dc:date>
    </item>
  </channel>
</rss>

