Reply
Member
Posts: 10
Registered: ‎12-10-2010

getting an error with the new accept.js solution

I am trying to test the new accept.js solution. I am copying/pasting the example code. I am just trying to log the results to the console, at this point.

 

However, when I load the page in FF or Chrome, I get the following error:

 

Chrome: Accept.js:1 Uncaught SyntaxError: Invalid or unexpected token

 

FireFox:  SyntaxError: illegal character

 
 
...4>s;s++){var t=q+g.Σ1(n)+g.Ch(n,o,p)+b[s]+r[s],u=g.Σ0(j)+g.Maj(j,k,l);q=p,p=o

 

 

Here is the code from the page I'm testing (of course I put my key/api login):

 

<!DOCTYPE HTML>

<html>

<head>
        <title>Auth.net Accept.js</title>
        <script type="text/javascript" src="https://jstest.authorize.net/v1/Accept.js"></script>
        <script type="text/javascript">
        function sendPaymentDataToAnet() {
        	var secureData = {}, authData = {}, cardData = {};

        	cardData.cardNumber = document.getElementById('CARDNUMBER_ID').value;
	        cardData.month = document.getElementById('EXPIRY_MONTH_ID').value;
	        cardData.year = document.getElementById('EXPIRY_YEAR_ID').value;
        	secureData.cardData = cardData;

        	authData.clientKey = 'my_client_key';
        	authData.apiLoginID = 'my_api_login';
        	secureData.authData = authData;

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

        function  responseHandler(response) {
        	if (response.messages.resultCode === 'Error') {
        		for (var i = 0; i < response.messages.message.length; i++) {
        			console.log(response.messages.message[i].code + ':' + response.messages.message[i].text);
        		        }
        		alert('acceptJS library error!');
        	        }
                else {
        		postBackToMyServer(response.opaqueData);
                        console.log(response.opaque.Data);
        	        }
                }
        </script>

</head>

<body>


<form>

CC#: <input type="text" id="CARDNUMBER_ID" />
MM: <input type="text" id="EXPIRY_MONTH_ID" />
YY: <input type="text" id="EXPIRY_YEAR_ID" />
<button type="submit" onclick="sendPaymentDataToAnet()">Pay</button>
</form>


</body>

</html>

Any ideas?

 

Thanks,

 

Joe

Developer
Posts: 80
Registered: ‎03-28-2014

Re: getting an error with the new accept.js solution

Make sure you include the UTF-8 charset meta tag:

 

<meta charset="utf-8">

 

Brian

 

Member
Posts: 2
Registered: ‎05-25-2016

Re: getting an error with the new accept.js solution

Utf-8 tag seems to be the solution.


Next, can ayone help with this error:  E_WC_14:Accept.js encryption failed.

All form validation is working so it appears accept.js is loading but error above is coming on submit.

 

 

 

 

Developer
Posts: 80
Registered: ‎03-28-2014

Re: getting an error with the new accept.js solution

Can you post your html/javascript?
Member
Posts: 2
Registered: ‎12-20-2014

Re: getting an error with the new accept.js solution

Hello,

I'm also getting error  E_WC_14:Accept.js encryption failed.

using https localhost

 

in Chrome, showing this message in the js console on page load:

XMLHttpRequest cannot load https://jstest.authorize.net/v1/AcceptCore.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost' is therefore not allowed access.

 

anyone have suggestions ?

 

-thanks

Developer
Posts: 80
Registered: ‎03-28-2014

Re: getting an error with the new accept.js solution

[ Edited ]

Hi Matt,

 

We have some updates to our documentation page coming today which should help greatly.  Right now I can tell you that the CORS warning "cannot load" is actually correct behaviour in that it's alerting the fact that the page cannot call our core js library only the Accept.js library.  So that will not impact functionality (we are nonetheless looking at ways to stop the browser doing this).

 

On the WC_14 error, we have an error in our sample code, if you make the response handler like this it should work:

 

function responseHandler(response) {
if (response.messages.resultCode === 'Error') {
for (var i = 0; i < response.messages.message.length; i++) {
console.log(response.messages.message[i].code + ':' + response.messages.message[i].text);
$("#blob").val(response.messages.message[i].code + ':' + response.messages.message[i].text);
}
} else {
useOpaqueData(response.opaqueData)
}
}
function useOpaqueData(responseData) {
console.log(responseData.dataDescriptor);
console.log(responseData.dataValue);
alert(responseData.dataValue);
}

 

Member
Posts: 2
Registered: ‎07-18-2016

Re: getting an error with the new accept.js solution

With sandbox and "https://jstest.authorize.net/v1/Accept.js", getting this error: E_WC_03:Accept.js is not loaded correctly. 

Member
Posts: 2
Registered: ‎07-18-2016

Re: getting an error with the new accept.js solution

With the same code using sandbox and "https://jstest.authorize.net/v1/Accept.js", most of the times getting error: E_WC_03:Accept.js is not loaded correctly. 

Developer
Posts: 80
Registered: ‎03-28-2014

Re: getting an error with the new accept.js solution

Hi @ali25000, can you post your code or send it to developer@authorize.net?

 

Also, have you looked at our sample app code?  https://github.com/AuthorizeNet/accept-sample-app/blob/master/acceptJSCaller.js   Lines 68 - 93

 

 

Thanks,

 

Brian

Developer
Posts: 80
Registered: ‎03-28-2014

Re: getting an error with the new accept.js solution

One more thing to check is that you haven't downloaded or altered the Authorize.Net javascript libraries.  That would cause E_WC03

 

Brian