Reply
Contributor
Posts: 29
Registered: ‎12-08-2015

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

[ Edited ]

Here is what I have, and it always results in an error ("acceptJS library error!"). I've tried the various code suggestions from this post. Anyone have any luck?

 

Also, how does one get back the info from authorize (such as card type, response code, etc)? I had mine with a relay response page before.

 

<!DOCTYPE HTML>
<meta charset="utf-8">

<html>

<head>
    <title>Auth.net Accept.js</title>
    <script type="text/javascript" src="https://js.authorize.net/v1/Accept.js"></script>
    <script type="text/javascript">
        function sendPaymentDataToAnet() {
            var secureData = {}, authData = {}, cardData = {};
            cardData.cardNumber = document.getElementById('creditCardNumber').value;
            //add cvv
            cardData.month = document.getElementById('expiryDateMM').value;
            cardData.year = document.getElementById('expiryDateYY').value;
            secureData.cardData = cardData;
            authData.clientKey = 'clientkeyhere';
            authData.apiLoginID = 'loginidhere';
            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 {
                console.log(response.opaqueData.dataDescriptor);
                console.log(response.opaqueData.dataValue);
                createTransact(response.opaqueData);
                alert("2");
            }
        }

      
    </script>

</head>

<body>


    <form>

        CC#: <input type="text" id="creditCardNumber" />
        MM: <input type="text" id="expiryDateMM" />
        YY: <input type="text" id="expiryDateYY" />
        <button type="submit" onclick="sendPaymentDataToAnet()">Pay</button>
    </form>


</body>

</html>

 

Contributor
Posts: 29
Registered: ‎12-08-2015

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

Chrome is saying this error: "XMLHttpRequest cannot load https://js.authorize.net/v1/AcceptCore.js. No 'Access-Control-Allow-Origin' header is present on the requested resource."

Member
Posts: 1
Registered: ‎09-16-2016

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

Im currently getting the XMLHttpRequest cannot load https://jstest.authorize.net/v1/AcceptCore.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. issue as well and then when i try and submit it tells me that windows[c] is not a function.

 

has anyone been able to get this to work yet?

Member
Posts: 6
Registered: ‎12-31-2016

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

I am also seeing "windows[b] is not a function" and the 'Access-Control-Allow-Origin'.  Has anyone gotten this working?

Administrator
Posts: 209
Registered: ‎11-03-2016

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

Just a heads up for you and anyone watching this thread that we've released code in sandbox that fixes many of the issues brought up here, and this code should make it into the production environment within the next couple of days.

 

Specifically for Accept.js, there's no longer any "Access-Control-Allow-Origin" related error in the console, the accept.js script can now be loaded at any point in the workflow, and the response handler function can be passed directly in the function call instead of having to pass the name.

 

Of course, please let us know if anything's not working as expected!

-Aaron

Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!
Member
Posts: 1
Registered: ‎03-13-2017

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

[ Edited ]

@Aaron Have the fixes made it into the production environment yet?

Administrator
Posts: 209
Registered: ‎11-03-2016

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

Yes, these are all now in production.

-Aaron

Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!