<?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: accept.js E_WC_14:Accept.js encryption failed. in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58663#M33281</link>
    <description>&lt;P&gt;Forget about the acceptJSCaller.js file. &amp;nbsp;For the sandbox, just include Accept.js with :&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;and put the following between &amp;lt;script&amp;gt; tags on the same page or as an external .js file. If an external .js file, include that as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function sendPaymentDataToAnet() {
    var secureData = {}; authData = {}; cardData = {};
    cardData.cardNumber = document.getElementById("cardNumberID").value;
    cardData.month = document.getElementById("monthID").value;
    cardData.year = document.getElementById("yearID").value;
    cardData.cardCode = document.getElementById("cardCodeID").value;
    secureData.cardData = cardData;

    authData.clientKey = "YOUR_PUBLIC_KEY";
    authData.apiLoginID = "YOUR_LOGIN_ID";
    secureData.authData = authData;

    Accept.dispatchData(secureData, responseHandler);

function responseHandler(response) {
        if (response.messages.resultCode === "Error") {
            for (var i = 0; i &amp;lt; response.messages.message.length; i++) {
                console.log(response.messages.message[i].code + ": " + response.messages.message[i].text);
            }
            alert("acceptJS library error!")
        } else {
            console.log(response.opaqueData.dataDescriptor);
            console.log(response.opaqueData.dataValue);
            processTransaction(response.opaqueData);
        }
    }
}

function processTransaction(responseData) {
    
    var transactionForm = document.createElement("form");
    transactionForm.Id = "transactionForm";
    &lt;BR /&gt;  //Your payment processing script to post the XML. &lt;BR /&gt;    transactionForm.action = "paymentprocessor.php";
    transactionForm.method = "POST";
    document.body.appendChild(transactionForm);

    amount = document.createElement("input")
    amount.hidden = true;
    amount.value = document.getElementById('amount').value;
    amount.name = "amount";
    transactionForm.appendChild(amount);

    dataDesc = document.createElement("input")
    dataDesc.hidden = true;
    dataDesc.value = responseData.dataDescriptor;
    dataDesc.name = "dataDesc";
    transactionForm.appendChild(dataDesc);

    dataValue = document.createElement("input")
    dataValue.hidden = true;
    dataValue.value = responseData.dataValue;
    dataValue.name = "dataValue";
    transactionForm.appendChild(dataValue);

    //submit the new form
    transactionForm.submit();
}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="html-tag"&gt;Replace your button onclick event with:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;button type="button" id="submitButton" onclick="sendPaymentDataToAnet()"&amp;gt;Pay&amp;lt;/button&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="html-tag"&gt;Done. Good job.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jul 2017 12:48:01 GMT</pubDate>
    <dc:creator>NexusSoftware</dc:creator>
    <dc:date>2017-07-04T12:48:01Z</dc:date>
    <item>
      <title>accept.js E_WC_14:Accept.js encryption failed.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58660#M33278</link>
      <description>&lt;P&gt;I have read through all of the posts on here for the encryption failed error and cannot resolve this. &amp;nbsp;I get the same error in my code and with the demo application.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to use this in a WordPress site. &amp;nbsp;The page that is loading has the following scripts on the page. &amp;nbsp;they are not in the head section, they are just in the page above the form.&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript" src="https://mydomain.com/acceptJSCaller.js" charset="utf-8"&amp;gt;&amp;lt;/script&amp;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;I modified acceptJSCaller.js from the sample app to include my test apilogin and public key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My form is as follows:&lt;/P&gt;&lt;PRE&gt;    &amp;lt;form&amp;gt;
        &amp;lt;input type="hidden" name="amount" value="750.00" /&amp;gt;
      
        Card Number&amp;lt;br&amp;gt;
        &amp;lt;input type="tel" id="creditCardNumber" autocomplete="off" /&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
        Expiration Date (Month)&amp;lt;br&amp;gt;
        &amp;lt;input type="text" id="expiryDateMM" /&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
        Expiration Date (Year)&amp;lt;br&amp;gt;
        &amp;lt;input type="text" id="expiryDateYY"  /&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
        Card Security Code&amp;lt;br&amp;gt;
        &amp;lt;input type="text" id="cvv" /&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
        
        &amp;lt;button type="button" id="submitButton" onclick="acceptJSCaller()"&amp;gt;Pay&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;&lt;/PRE&gt;&lt;P&gt;Has anyone found a solution for this that consistently works?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 05:40:18 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58660#M33278</guid>
      <dc:creator>microweb</dc:creator>
      <dc:date>2017-07-04T05:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: accept.js E_WC_14:Accept.js encryption failed.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58663#M33281</link>
      <description>&lt;P&gt;Forget about the acceptJSCaller.js file. &amp;nbsp;For the sandbox, just include Accept.js with :&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;and put the following between &amp;lt;script&amp;gt; tags on the same page or as an external .js file. If an external .js file, include that as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function sendPaymentDataToAnet() {
    var secureData = {}; authData = {}; cardData = {};
    cardData.cardNumber = document.getElementById("cardNumberID").value;
    cardData.month = document.getElementById("monthID").value;
    cardData.year = document.getElementById("yearID").value;
    cardData.cardCode = document.getElementById("cardCodeID").value;
    secureData.cardData = cardData;

    authData.clientKey = "YOUR_PUBLIC_KEY";
    authData.apiLoginID = "YOUR_LOGIN_ID";
    secureData.authData = authData;

    Accept.dispatchData(secureData, responseHandler);

function responseHandler(response) {
        if (response.messages.resultCode === "Error") {
            for (var i = 0; i &amp;lt; response.messages.message.length; i++) {
                console.log(response.messages.message[i].code + ": " + response.messages.message[i].text);
            }
            alert("acceptJS library error!")
        } else {
            console.log(response.opaqueData.dataDescriptor);
            console.log(response.opaqueData.dataValue);
            processTransaction(response.opaqueData);
        }
    }
}

function processTransaction(responseData) {
    
    var transactionForm = document.createElement("form");
    transactionForm.Id = "transactionForm";
    &lt;BR /&gt;  //Your payment processing script to post the XML. &lt;BR /&gt;    transactionForm.action = "paymentprocessor.php";
    transactionForm.method = "POST";
    document.body.appendChild(transactionForm);

    amount = document.createElement("input")
    amount.hidden = true;
    amount.value = document.getElementById('amount').value;
    amount.name = "amount";
    transactionForm.appendChild(amount);

    dataDesc = document.createElement("input")
    dataDesc.hidden = true;
    dataDesc.value = responseData.dataDescriptor;
    dataDesc.name = "dataDesc";
    transactionForm.appendChild(dataDesc);

    dataValue = document.createElement("input")
    dataValue.hidden = true;
    dataValue.value = responseData.dataValue;
    dataValue.name = "dataValue";
    transactionForm.appendChild(dataValue);

    //submit the new form
    transactionForm.submit();
}&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="html-tag"&gt;Replace your button onclick event with:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;button type="button" id="submitButton" onclick="sendPaymentDataToAnet()"&amp;gt;Pay&amp;lt;/button&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="html-tag"&gt;Done. Good job.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 12:48:01 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58663#M33281</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2017-07-04T12:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: accept.js E_WC_14:Accept.js encryption failed.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58664#M33282</link>
      <description>&lt;P&gt;PS. Don't forget to replace the example above's document IDs with your own ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    cardData.cardNumber = document.getElementById("creditCardNumber").value;
    cardData.month = document.getElementById("expiryDateMM").value;
    cardData.year = document.getElementById("expiryDateYY").value;
    cardData.cardCode = document.getElementById("cvv").value;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 13:02:41 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58664#M33282</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2017-07-04T13:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: accept.js E_WC_14:Accept.js encryption failed.</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58764#M33379</link>
      <description>&lt;P&gt;The error message on this is very misleading. &amp;nbsp;I finally got it working by using the firebug&amp;nbsp;console. &amp;nbsp;The problem was not in my call to accept.js but in the code on the payment processor page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I realized the issue wasn't with the call to authorize, but more of a javascript error I was able to get this working quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 17:10:08 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/accept-js-E-WC-14-Accept-js-encryption-failed/m-p/58764#M33379</guid>
      <dc:creator>microweb</dc:creator>
      <dc:date>2017-07-11T17:10:08Z</dc:date>
    </item>
  </channel>
</rss>

