<?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 Re: Getting 'Accept is undefined' JavaScript runtime error when testing with accept.js in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58745#M33360</link>
    <description>&lt;P&gt;It is working being called from the body onload:&amp;nbsp;&lt;A href="https://nexwebsites.com/authorize.net-token-tester/test-accept.html" target="_blank"&gt;https://nexwebsites.com/authorize.net-token-tester/test-accept.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why not just put :&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript" src="https://jstest.authorize.net/v1/Accept.js" charset="utf-8"&amp;gt;&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;in your header or do a conditional file inclusion from the code behind, if you must?&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2017 18:04:06 GMT</pubDate>
    <dc:creator>NexusSoftware</dc:creator>
    <dc:date>2017-07-10T18:04:06Z</dc:date>
    <item>
      <title>Getting 'Accept is undefined' JavaScript runtime error when testing with accept.js</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58734#M33349</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I am testing credit card payments on my NopCommerce based web store using Test mode in Authorize.net with Accept.js.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the javascript run-time error, 'Accept is undefined' when I try to call&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Accept.dispatchData.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Intellisense picks up the Accept object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var PaymentInfo = {&lt;BR /&gt;form: false,&lt;BR /&gt;saveUrl: false,&lt;/P&gt;&lt;P&gt;init: function (form, saveUrl) {&lt;BR /&gt;this.form = form;&lt;BR /&gt;this.saveUrl = saveUrl;&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;save: function () {&lt;BR /&gt;if (Checkout.loadWaiting != false) return;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;this.sendPaymentDataToAnet();&lt;BR /&gt;Checkout.setLoadWaiting('payment-info');&lt;BR /&gt;$.ajax({&lt;BR /&gt;cache: false,&lt;BR /&gt;url: this.saveUrl,&lt;BR /&gt;data: $(this.form).serialize(),&lt;BR /&gt;type: 'post',&lt;BR /&gt;success: this.nextStep,&lt;BR /&gt;complete: this.resetLoadWaiting,&lt;BR /&gt;error: Checkout.ajaxFailure&lt;BR /&gt;});&lt;BR /&gt;},&lt;BR /&gt;sendPaymentDataToAnet: function () {&lt;BR /&gt;var secureData = {}; authData = {}; cardData = {};&lt;/P&gt;&lt;P&gt;//document.writeln("&amp;lt;script type='text/javascript' src='&lt;A href="https://js.authorize.net/v1/Accept.js" target="_blank"&gt;https://js.authorize.net/v1/Accept.js&lt;/A&gt;' charset='utf-8'&amp;gt;&amp;lt;/script&amp;gt;");&lt;/P&gt;&lt;P&gt;var imported = document.createElement("script");&lt;BR /&gt;imported.src="&lt;A href="https://jstest.authorize.net/v1/Accept.js" target="_blank"&gt;https://jstest.authorize.net/v1/Accept.js&lt;/A&gt;";&lt;BR /&gt;imported.charset = "utf-8";&lt;/P&gt;&lt;P&gt;document.head.appendChild(imported);&lt;BR /&gt;// for Sandbox / Testing use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;// for Production use, use &lt;A href="https://js.authorize.net/v1/Accept.js" target="_blank"&gt;https://js.authorize.net/v1/Accept.js&lt;/A&gt;&lt;BR /&gt;//$.getScript('&lt;A href="https://jstest.authorize.net/v1/Accept.js" target="_blank"&gt;https://jstest.authorize.net/v1/Accept.js&lt;/A&gt;', function () {&lt;BR /&gt;try {&lt;BR /&gt;// Extract the card number, expiration date, and card code.&lt;BR /&gt;cardData.cardNumber = document.getElementById("CardNumber").value;&lt;BR /&gt;cardData.month = document.getElementById("ExpireMonth").value;&lt;BR /&gt;cardData.year = document.getElementById("ExpireYear").value;&lt;BR /&gt;cardData.cardCode = document.getElementById("CardCode").value;&lt;BR /&gt;secureData.cardData = cardData;&lt;/P&gt;&lt;P&gt;// The Authorize.Net Client Key is used in place of the traditional Transaction Key. The Transaction Key&lt;BR /&gt;// is a shared secret and must never be exposed. The Client Key is a public key suitable for use where&lt;BR /&gt;// someone outside the merchant might see it.&lt;BR /&gt;authData.clientKey = "****" ;&lt;/P&gt;&lt;P&gt;authData.apiLoginID = "****";&lt;BR /&gt;secureData.authData = authData;&lt;/P&gt;&lt;P&gt;// Pass the card number and expiration date to Accept.js for submission to Authorize.Net.&lt;/P&gt;&lt;P&gt;Accept.dispatchData(secureData, 'responseHandler');&lt;BR /&gt;} catch (ex) {&lt;BR /&gt;console.log(ex.message);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//});&lt;BR /&gt;},&lt;BR /&gt;responseHandler: function (response) {&lt;BR /&gt;if (response.messages.resultCode === "Error") {&lt;BR /&gt;for (var i = 0; i &amp;lt; response.messages.message.length; i++) {&lt;BR /&gt;console.log(response.messages.message[i].code + ": " + response.messages.message[i].text);&lt;BR /&gt;}&lt;BR /&gt;alert("acceptJS library error!")&lt;BR /&gt;} else {&lt;BR /&gt;console.log(response.opaqueData.dataDescriptor);&lt;BR /&gt;console.log(response.opaqueData.dataValue);&lt;BR /&gt;//this.processTransaction(response.opaqueData);&lt;/P&gt;&lt;P&gt;var frmPaymentInfo= document.getElementById("co-payment-info-form");&lt;BR /&gt;var amount = document.createElement("input")&lt;BR /&gt;amount.hidden = true;&lt;BR /&gt;amount.value = document.getElementById('amount').value;&lt;BR /&gt;amount.name = "amount";&lt;BR /&gt;amount.id = "amount";&lt;BR /&gt;frmPaymentInfo.appendChild(amount);&lt;/P&gt;&lt;P&gt;var dataDesc = document.createElement("input")&lt;BR /&gt;dataDesc.hidden = true;&lt;BR /&gt;dataDesc.value = response.opaqueData.dataDescriptor;&lt;BR /&gt;dataDesc.name = "dataDesc";&lt;BR /&gt;dataDesc.id = "dataDesc";&lt;BR /&gt;frmPaymentInfo.appendChild(dataDesc);&lt;/P&gt;&lt;P&gt;var dataValue = document.createElement("input")&lt;BR /&gt;dataValue.hidden = true;&lt;BR /&gt;dataValue.value = response.opaqueData.dataValue;&lt;BR /&gt;dataValue.name = "dataValue";&lt;BR /&gt;dataValue.id = "dataValue";&lt;BR /&gt;frmPaymentInfo.appendChild(dataValue);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Saad&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 04:46:46 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58734#M33349</guid>
      <dc:creator>saadm</dc:creator>
      <dc:date>2017-07-10T04:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 'Accept is undefined' JavaScript runtime error when testing with accept.js</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58737#M33352</link>
      <description>&lt;P&gt;In this case, Accept.js functions are not loaded when the call to Accept.dispatchData() is made.&lt;BR /&gt;One way is to remove the loading from the sendPaymentDataToAnet() function and do something like :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;body onload="loadScript()"&amp;gt; 

function loadScript() {
var imported = document.createElement("script");
imported.src="https://jstest.authorize.net/v1/Accept.js";
imported.charset = "utf-8";
document.head.appendChild(imported);
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 14:52:21 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58737#M33352</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2017-07-10T14:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 'Accept is undefined' JavaScript runtime error when testing with accept.js</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58741#M33356</link>
      <description>&lt;P&gt;It did not work with body onload either. &amp;nbsp;I finally got it to work by copying and pasting the Accept.js script directly into the sendPaymentDataToAnet function like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sendPaymentDataToAnet: function () {&lt;BR /&gt;var secureData = {}; authData = {}; cardData = {};&lt;/P&gt;&lt;P&gt;var Accept = function () { "use strict"; function a(a) { var b; ((b = g.hash(a.responseText)) &amp;amp;&amp;amp; b ? b = "187361d772b193b659e74089acebc3a2077f044c89345d96b2149775796a3bc3" !== b : 0) &amp;amp;&amp;amp; (console.warn("Library is not coming from Accept server--- " + g.hash(a.responseText)), setTimeout(f, 2e3)), a = void 0 } function b(a, b) { var c = null; c = "undefined" != typeof XDomainRequest ? new XDomainRequest : new XMLHttpRequest, c.open("get", a, !0), c.send(), c.onload = function () { setTimeout(function () { b(c), 2e3 }) } } function c(a) { var b = document.createElement("script"); b.type = "text/javascript", b.src=a, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(b) } function d(a, b) { console.warn("Accept.js is not loaded correctly"); var c = { messages: { resultCode: "Ok", message: [] } }; c.messages.resultCode = "Error", c.messages.message.push({ code: "E_WC_03", text: "Accept.js is not loaded correctly" }), "function" == typeof b ? b.call(null, c) : window[b](c) } function e() { var a = document.getElementsByTagName("body")[0]; a.addEventListener("handshake", function () { window.isReady = !0 }, !1) } window.cdnPath = "&lt;A href="https://js.authorize.net" target="_blank"&gt;https://js.authorize.net&lt;/A&gt;", window.cdnPath = window.cdnPath + "/v1/", window.encryptEndPoint = "&lt;A href="https://api.authorize.net" target="_blank"&gt;https://api.authorize.net&lt;/A&gt;"; var f = function () { Accept.dispatchData = function (a, b) { var c = { messages: { resultCode: "Ok", message: [] } }; c.messages.resultCode = "Error", c.messages.message.push({ code: "E_WC_03", text: "Accept.js is not loaded correctly" }), "function" == typeof b ? b.call(null, c) : window[b](c) } }, g = {}; return g.hash = function (a) { a = a.utf8Encode(); var b = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298], c = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]; a += String.fromCharCode(128); for (var d = a.length / 4 + 2, e = Math.ceil(d / 16), f = new Array(e), h = 0; h &amp;lt; e; h++) { f[h] = new Array(16); for (var i = 0; i &amp;lt; 16; i++)f[h][i] = a.charCodeAt(64 * h + 4 * i) &amp;lt;&amp;lt; 24 | a.charCodeAt(64 * h + 4 * i + 1) &amp;lt;&amp;lt; 16 | a.charCodeAt(64 * h + 4 * i + 2) &amp;lt;&amp;lt; 8 | a.charCodeAt(64 * h + 4 * i + 3) } f[e - 1][14] = 8 * (a.length - 1) / Math.pow(2, 32), f[e - 1][14] = Math.floor(f[e - 1][14]), f[e - 1][15] = 8 * (a.length - 1) &amp;amp; 4294967295; var j, k, l, m, n, o, p, q, r = new Array(64); for (h = 0; h &amp;lt; e; h++) { for (var s = 0; s &amp;lt; 16; s++)r[s] = f[h][s]; for (s = 16; s &amp;lt; 64; s++)r[s] = g.s1(r[s - 2]) + r[s - 7] + g.s0(r[s - 15]) + r[s - 16] &amp;amp; 4294967295; for (j = c[0], k = c[1], l = c[2], m = c[3], n = c[4], o = c[5], p = c[6], q = c[7], s = 0; s &amp;lt; 64; s++) { var t = q + g.S1(n) + g.Ch(n, o, p) + b[s] + r[s], u = g.S0(j) + g.Maj(j, k, l); q = p, p = o, o = n, n = m + t &amp;amp; 4294967295, m = l, l = k, k = j, j = t + u &amp;amp; 4294967295 } c[0] = c[0] + j &amp;amp; 4294967295, c[1] = c[1] + k &amp;amp; 4294967295, c[2] = c[2] + l &amp;amp; 4294967295, c[3] = c[3] + m &amp;amp; 4294967295, c[4] = c[4] + n &amp;amp; 4294967295, c[5] = c[5] + o &amp;amp; 4294967295, c[6] = c[6] + p &amp;amp; 4294967295, c[7] = c[7] + q &amp;amp; 4294967295 } return g.toHexStr(c[0]) + g.toHexStr(c[1]) + g.toHexStr(c[2]) + g.toHexStr(c[3]) + g.toHexStr(c[4]) + g.toHexStr(c[5]) + g.toHexStr(c[6]) + g.toHexStr(c[7]) }, g.ROTR = function (a, b) { return b &amp;gt;&amp;gt;&amp;gt; a | b &amp;lt;&amp;lt; 32 - a }, g.S0 = function (a) { return g.ROTR(2, a) ^ g.ROTR(13, a) ^ g.ROTR(22, a) }, g.S1 = function (a) { return g.ROTR(6, a) ^ g.ROTR(11, a) ^ g.ROTR(25, a) }, g.s0 = function (a) { return g.ROTR(7, a) ^ g.ROTR(18, a) ^ a &amp;gt;&amp;gt;&amp;gt; 3 }, g.s1 = function (a) { return g.ROTR(17, a) ^ g.ROTR(19, a) ^ a &amp;gt;&amp;gt;&amp;gt; 10 }, g.Ch = function (a, b, c) { return a &amp;amp; b ^ ~a &amp;amp; c }, g.Maj = function (a, b, c) { return a &amp;amp; b ^ a &amp;amp; c ^ b &amp;amp; c }, g.toHexStr = function (a) { for (var b, c = "", d = 7; d &amp;gt;= 0; d--)b = a &amp;gt;&amp;gt;&amp;gt; 4 * d &amp;amp; 15, c += b.toString(16); return c }, "complete" === document.readyState ? e() : window.addEventListener ? window.addEventListener("load", e, !1) : window.attachEvent ? window.attachEvent("onload", e) : window.onLoad &amp;amp;&amp;amp; (window.onload = e), "undefined" == typeof String.prototype.utf8Encode &amp;amp;&amp;amp; (String.prototype.utf8Encode = function () { return unescape(encodeURIComponent(this)) }), "undefined" == typeof String.prototype.utf8Decode &amp;amp;&amp;amp; (String.prototype.utf8Decode = function () { try { return decodeURIComponent(escape(this)) } catch (a) { return this } }), c(cdnPath + "AcceptCore.js"), b(cdnPath + "AcceptCore.js", a), { dispatchData: d } }();&lt;BR /&gt;//document.writeln("&amp;lt;script type='text/javascript' src='&lt;A href="https://js.authorize.net/v1/Accept.js" target="_blank"&gt;https://js.authorize.net/v1/Accept.js&lt;/A&gt;' charset='utf-8'&amp;gt;&amp;lt;/script&amp;gt;");&lt;/P&gt;&lt;P&gt;//var imported = document.createElement("script");&lt;BR /&gt;//imported.src="&lt;A href="https://jstest.authorize.net/v1/Accept.js" target="_blank"&gt;https://jstest.authorize.net/v1/Accept.js&lt;/A&gt;";&lt;BR /&gt;//imported.charset = "utf-8";&lt;/P&gt;&lt;P&gt;//document.head.appendChild(imported);&lt;BR /&gt;// for Sandbox / Testing use&lt;BR /&gt;// for Production use, use &lt;A href="https://js.authorize.net/v1/Accept.js" target="_blank"&gt;https://js.authorize.net/v1/Accept.js&lt;/A&gt;&lt;BR /&gt;//$.getScript('&lt;A href="https://jstest.authorize.net/v1/Accept.js" target="_blank"&gt;https://jstest.authorize.net/v1/Accept.js&lt;/A&gt;', function () {&lt;BR /&gt;try {&lt;BR /&gt;// Extract the card number, expiration date, and card code.&lt;BR /&gt;cardData.cardNumber = document.getElementById("CardNumber").value;&lt;BR /&gt;cardData.month = document.getElementById("ExpireMonth").value;&lt;BR /&gt;cardData.year = document.getElementById("ExpireYear").value;&lt;BR /&gt;cardData.cardCode = document.getElementById("CardCode").value;&lt;BR /&gt;&lt;BR /&gt;secureData.cardData = cardData;&lt;/P&gt;&lt;P&gt;// The Authorize.Net Client Key is used in place of the traditional Transaction Key. The Transaction Key&lt;BR /&gt;// is a shared secret and must never be exposed. The Client Key is a public key suitable for use where&lt;BR /&gt;// someone outside the merchant might see it.&lt;BR /&gt;authData.clientKey = "54uHXf4tGxS3ghn448PSn7wHWJ2RZDxAe2qc68fJdxx43Q438khaHV9TRdyzBTAq";&lt;BR /&gt;authData.apiLoginID = "concordea2014";&lt;BR /&gt;secureData.authData = authData;&lt;/P&gt;&lt;P&gt;// Pass the card number and expiration date to Accept.js for submission to Authorize.Net.&lt;/P&gt;&lt;P&gt;Accept.dispatchData(secureData, this.responseHandler);&lt;BR /&gt;} catch (ex) {&lt;BR /&gt;console.log(ex.message);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//});&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but now I am getting an 'acceptJS library error' in responseHandler callback function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Saad&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 16:28:06 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58741#M33356</guid>
      <dc:creator>saadm</dc:creator>
      <dc:date>2017-07-10T16:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 'Accept is undefined' JavaScript runtime error when testing with accept.js</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58745#M33360</link>
      <description>&lt;P&gt;It is working being called from the body onload:&amp;nbsp;&lt;A href="https://nexwebsites.com/authorize.net-token-tester/test-accept.html" target="_blank"&gt;https://nexwebsites.com/authorize.net-token-tester/test-accept.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why not just put :&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript" src="https://jstest.authorize.net/v1/Accept.js" charset="utf-8"&amp;gt;&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;in your header or do a conditional file inclusion from the code behind, if you must?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 18:04:06 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Getting-Accept-is-undefined-JavaScript-runtime-error-when/m-p/58745#M33360</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2017-07-10T18:04:06Z</dc:date>
    </item>
  </channel>
</rss>

