Reply
Contributor
Posts: 12
Registered: ‎08-28-2016

Re: Accept.js error E_WC_14:Accept.js encryption failed.

[ Edited ]

It says here: 

 

http://developer.authorize.net/api/reference/features/acceptjs.html

 

That thje error  "XMLHttpRequest cannot load ... bla bla" is normal, and that it happens on localhost. Still not clue about the E_WC_14 ! 

 

Come to think about it, you guys should return more technical error descriptions, it's not like we're scared users, not knowing what to do when a fancy word comes up - we are developing integrations right ? 

 

Side note, I do not understand why on earth is it so difficult to come with a stable .js library. I have been implementing tens of integrations with numerous gateways, and 90% is the JavaScript approach. However, none of them throw so much errors. In fact most of them work from the 1st time. Point being that Authorize.NET developers certainly are not the first ones making this kind of wheel. 

 

 

 

 

Posts: 2,057
Topics: 47
Kudos: 136
Blog Posts: 62
Registered: ‎12-05-2011

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Hello

I've reported this issue to the product team for analysis.

I'd recommend subscribing to this topic so that you'll be alerted via email if there are updates. To subscribe, click Topic Options at the top of this thread and then select Subscribe. You'll then receive an email once anyone replies to your post.

Thanks,

Richard

--------

Webhooks are now available for Authorize.Net

Using SOAP, see our deprecation notice.
Check out Accept.js, our Javascript replacement for DPM.
Pro Tip: Never use test mode in the sandbox, instead use the Testing Guide.
Posts: 2,057
Topics: 47
Kudos: 136
Blog Posts: 62
Registered: ‎12-05-2011

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Hello,

 

The product team is asking how you are loading accept.js?

 

• By including the script tag and as described in documentation

<script type="text/javascript" src="https://js.authorize.net/v1/Accept.js" charset="utf-8"></script>

• Or Dynamically loading the script after page load?

 

Richard

--------

Webhooks are now available for Authorize.Net

Using SOAP, see our deprecation notice.
Check out Accept.js, our Javascript replacement for DPM.
Pro Tip: Never use test mode in the sandbox, instead use the Testing Guide.
Contributor
Posts: 12
Registered: ‎08-28-2016

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Hi,

 

I am loading it like this: 

 

 

<script type="text/javascript" src="https://jstest.authorize.net/v1/Accept.js" charset="utf-8"></script>

But it is a One Page Checkout, so the Payment form is loaded with ajax at one step. So in the loaded HTML, I have the above script tag, and I also have an inline javascript section, where I have the following code: 

 

<script type="text/javascript">
    $(document).ready(function () {
        GetScriptCallback();
    });

    function sendPaymentDataToAnet() {
        var secureData = {}, authData = {}, cardData = {};

        cardData.cardNumber = document.getElementById('@ViewBag.FormInputIds[1]').value;
        cardData.month = document.getElementById('@ViewBag.FormInputIds[2]').value;
        cardData.year = document.getElementById('@ViewBag.FormInputIds[3]').value;
        cardData.fullName = document.getElementById('@ViewBag.FormInputIds[0]').value;
        cardData.cardCode = document.getElementById('@ViewBag.FormInputIds[4]').value;

        secureData.cardData = cardData;

        authData.clientKey = "@ViewBag.PublicClientKey";
        authData.apiLoginID = "@ViewBag.ApiLogin";
        secureData.authData = authData;

        console.log(secureData);
        console.log(Accept);

        Accept.dispatchData(secureData, 'createTokenCallback');
    }

    function createTokenCallback(response) {

        if (response.messages.resultCode === 'Error') {
            $(".payment-errors").text("");
            var errorMessages = [];
            for (var i = 0; i < response.messages.message.length; i++) {
                errorMessages.push(response.messages.message[i].code + ':' + response.messages.message[i].text);
            }

            $(".payment-errors").append(errorMessages.join("<br />"));
            $(".payment-info-next-step-button").removeAttr("disabled");

        } else {
            var token = response.opaqueData.dataValue;

            $(".payment-errors").text("");
            var form = $(".payment-info-next-step-button").closest('form');

            $("#paymenttoken").val(token);
            //if (document.location.href.indexOf('onepagecheckout') > -1) {
            //    PaymentInfo.save();
            //}
            //else {
            //    form.submit();
            //}
        }
    }

    function GetScriptCallback() {
        $(".payment-info-next-step-button").removeAttr("onClick");
        $(".payment-info-next-step-button").unbind().click(function (event) {
            $('.submit-button').attr("disabled", "disabled");

            sendPaymentDataToAnet();

            return false;
        });
    };

</script>

I also tried loading the Accept.js using jquery, like this: 

 

  $(document).ready(function () {
        $.getScript("https://jstest.authorize.net/v1/Accept.js", function (data, textStatus, jqxhr) {
            GetScriptCallback();
        });
    });

But then it throws the following error: 

E_WC_01Please include Accept.js library from cdn.

 

 

 

 

Posts: 2,057
Topics: 47
Kudos: 136
Blog Posts: 62
Registered: ‎12-05-2011

Re: Accept.js error E_WC_14:Accept.js encryption failed.

[ Edited ]

@andronachev2016  Try adding Accept.js at the top of the main area of your one page checkout not dynamically within the page using AJAX.

 

Or another option might be to use the following:

 

dispatchEvent(new Event('load'));

 

Richard

--------

Webhooks are now available for Authorize.Net

Using SOAP, see our deprecation notice.
Check out Accept.js, our Javascript replacement for DPM.
Pro Tip: Never use test mode in the sandbox, instead use the Testing Guide.
Contributor
Posts: 12
Registered: ‎08-28-2016

Re: Accept.js error E_WC_14:Accept.js encryption failed.

I would try, but I cannot do that - because this is a plugin, it needs to render it's own resources. The HEADER section is part of the CMS that it plugs into, I don't have access to that one.

 

 

Posts: 2,057
Topics: 47
Kudos: 136
Blog Posts: 62
Registered: ‎12-05-2011

Re: Accept.js error E_WC_14:Accept.js encryption failed.

You may have missed my update to try:

 

dispatchEvent(new Event('load'));
--------

Webhooks are now available for Authorize.Net

Using SOAP, see our deprecation notice.
Check out Accept.js, our Javascript replacement for DPM.
Pro Tip: Never use test mode in the sandbox, instead use the Testing Guide.
Contributor
Posts: 12
Registered: ‎08-28-2016

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Yes, it works with the dispatchEvent approach. However: 

 

It does not work if I include the script like this: 

 

 

<script type="text/javascript" src="https://jstest.authorize.net/v1/Accept.js" charset="utf-8"></script>

Because then you need to listen to the 

 

 

 

$(window).load()

Event (this includes the loading time of the external resources - document ready only listens for the DOM). But this event is not firing, because of the XMLHttpRequest cannot load https://jstest.authorize.net/v1/AcceptCore.js. No 'Access-Control-Allow-Origin' ... error. So what I did was to load the script dynamically, like this: 

 

$(document).ready(function () {
        $.getScript(jsUrl, function (data, textStatus, jqxhr) {
dispatchEvent(new Event('load')); GetScriptCallback(); }); });

Which initially was throwing the CDN error, but if I add your event triggering, then it does work. 

 

 

Hope this makes sense.

 

Thans a lot ! 

 

Vlad

 

 

Contributor
Posts: 12
Registered: ‎08-28-2016

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Actually the CDN is still an issue. I tested my dynamic loading of the script, whilst still having the <script> tag as well. 

 

So the solution is to use the <Script> tag.. but we can't use hte window.load, beacuse of the CORS error. so What I did was to use document ready, and add a sleep() function of 1 second, then I fire the load event. Therefore my javascript code runs after the <Script> tag has loaded.

Posts: 2,057
Topics: 47
Kudos: 136
Blog Posts: 62
Registered: ‎12-05-2011

Re: Accept.js error E_WC_14:Accept.js encryption failed.

Thanks @andronachev2016 for the detailed feedback.  I'll pass this information on to our product and documentation teams for future updates should developers have similar use cases.

 

Richard

--------

Webhooks are now available for Authorize.Net

Using SOAP, see our deprecation notice.
Check out Accept.js, our Javascript replacement for DPM.
Pro Tip: Never use test mode in the sandbox, instead use the Testing Guide.