Reply
New Member
Posts: 1
Registered: ‎01-30-2017

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

I am also getting "E_WC_14:Accept.js encryption failed." I have processed a number of test transactions in the sandbox with the below code now I am getting the above error.

  

The elevent part of the code are:

 

function sendPaymentDataToAnet() {
    $('#errorMessage').hide();
    $('#spinner').show();
    var secureData = {}, authData = {}, cardData = {};
    
    cardData.cardNumber = $('#cardNumber').val();
    cardData.month = $('#expMonth').val();
    cardData.year = $('#expYear').val();
    cardData.cardCode = $('#cvv').val();
    cardData.zip = $('#cardZip').val();
    cardData.fullName = $('#cardName').val();
    
    secureData.cardData = cardData;
    authData.clientKey = '<?php echo $authKey?>';
    authData.apiLoginID = '<?php echo $authId?>';
    secureData.authData = authData;

    //console.log(secureData);
    
    Accept.dispatchData(secureData, 'responseHandler');
}
function responseHandler(response) {
    if (response.messages.resultCode === 'Error') {
        html='<ul>';
        for (var i = 0; i < response.messages.message.length; i++) {
            console.log(response.messages.message[i].code + ':' + response.messages.message[i].text);
            html+='<li>'+response.messages.message[i].text+'</li>';
        }
        html+='</ul>';
        $('#spinner').hide();
        $('#errorMessage').html(html).show();
    } else {
        useOpaqueData(response.opaqueData)
    }
}

Access.js is included in the head of the page with:

 

 

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

I would like to know why the error is happening.

 

Highlighted
New Member
Posts: 1
Registered: ‎02-14-2017

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

There seems to be a bug in AcceptCore.js. When it loops over received API responses it's not processing the error response object correctly.

 

 

 

// The function in question (this is in AcceptCore)

function n(a, b) { try { var c = JSON.parse(a.responseText); if (void 0 !== c.messages.resultCode && void 0 !== c.messages.message && c.messages.message.length >= 1) { for (var d in c.messages.message) switch (c.messages.message[d].code) { case "I00001": c.messages.message[d].code = "I_WC_01"; break; case "E00001": c.messages.message[d].code = "E_WC_15"; break; case "E00003": c.messages.message[d].code = "E_WC_16"; break; case "E00007": c.messages.message[d].code = "E_WC_17"; break; case "E00096": c.messages.message[d].code = "E_WC_13" } window[b](c) } else r.messages.resultCode = "Error", h("E_WC_14", w.messageInfo.E_WC_14), window[b](r) } catch (e) { r.messages.resultCode = "Error", h("E_WC_14", w.messageInfo.E_WC_14), window[b](r) } } // Example of the problem for (var d in c.messages.message) { console.log(d) } //2017 - 02 - 09 10: 36: 45.285 VM3811: 2 0 //2017 - 02 - 09 10: 36: 45.286 VM3811: 2 _super //2017 - 02 - 09 10: 36: 45.286 VM3811: 2 nextObject //2017 - 02 - 09 10: 36: 45.286 VM3811: 2 firstObject //2017 - 02 - 09 10: 36: 45.287 VM3811: 2 lastObject //2017 - 02 - 09 10: 36: 45.287 VM3811: 2 contains //2017 - 02 - 09 10: 36: 45.288 VM3811: 2 getEach //2017 - 02 - 09 10: 36: 45.288 VM3811: 2 setEach //... // To fix; the for loop needs to do the right thing for (var i = c.messages.message.length - 1; i >= 0; i--) switch (c.messages.message[i].code) { case "I00001": c.messages.message[d].code = "I_WC_01"; break; case "E00001": c.messages.message[d].code = "E_WC_15"; break; case "E00003": c.messages.message[d].code = "E_WC_16"; break; case "E00007": c.messages.message[d].code = "E_WC_17"; break; case "E00096": c.messages.message[d].code = "E_WC_13" }

 

I've emailed dev support and they just pointed me at this forum thread which is of no help at all. Like others I've found sometimes the script works, sometimes it doesn't. I don't know if their CDN is serving good code sometimes, and then a broken version at other times, but I can't see how the code can work as it is.