cancel
Showing results for 
Search instead for 
Did you mean: 

Accept.js returns E_WC_21 error even with correct login/key

I am testing our integration with authorize.net. I have two test accounts on sandbox.authorize.net (one for USD and one for GBP).

 

I am using the https://jstest.authorize.net/v1/Accept.js library for our testing.

 

In my testing the Accept.dispatchData method returns the E_WC_21 error even with a valid API login and public client key.

 

I've double checked against the accounts on sandbox.authorize.net.

 

I generated a new public client key and tried that but I am getting the same error.

 

Does it take a while for a new public client key to become "live"?

 

Thanks,

 

Brad

bkembree
Member
17 REPLIES 17

Hi @Madeleine

 

Have you seen the Accept sample app at https://github.com/AuthorizeNet/accept-sample-app  

 

It does has example of using AcceptUI.js .

 

Hope it helps !!





Send feedback at developer_feedback@authorize.net

Hello

 

That is a great example but it is in php and it is way more than I need to do - I will need that sort of example once  I get past my problems

 

I need the simplest form ever!

The example on the page says you can even get the token back in pure html - well I am so stuck with out the token I cannot for forward. 

 

All I want is the token back and I am getting an error - 

 

E_WC_21: User authentication failed due to invalid authentication values.

The authentication data object includes only two values, your API Login ID and the Public Client Key.

 

The simplest example is below: 

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

<form id="paymentForm"
    method="POST"
    action="https://YourServer/PathToYourPaymentProcessingScript">
    <input type="hidden" name="dataValue" id="dataValue" />
    <input type="hidden" name="dataDescriptor" id="dataDescriptor" />
    <button type="button"
        class="AcceptUI"
        data-billingAddressOptions='{"show":true, "required":false}' 
        data-apiLoginID="YOUR API LOGIN ID" 
        data-clientKey="YOUR PUBLIC CLIENT KEY : 64 byte string"
        data-acceptUIFormBtnTxt="Submit" 
        data-acceptUIFormHeaderTxt="Card Information" 
        data-responseHandler="responseHandler">Pay
    </button>
</form>

<script type="text/javascript">
function responseHandler(response) {
    if (response.messages.resultCode === "Error") {
        var i = 0;
        while (i < response.messages.message.length) {
            console.log(
                response.messages.message[i].code + ": " +
                response.messages.message[i].text
            );
            i = i + 1;
        }
    } else {
        paymentFormUpdate(response.opaqueData);
    }
}


function paymentFormUpdate(opaqueData) {
    document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor;
    document.getElementById("dataValue").value = opaqueData.dataValue;

  document.getElementById("paymentForm").submit();
}
</script>

In the above example, your Sandbox credentials would apply. Once the lightbox payment form is submitted, the dataValue input is auto-populated with the token and submitted to your payment processing script. 

<input type="hidden" name="dataValue" id="dataValue" value="eyJjb2XXX...">

 To test, login to the Sandbox, get your API Login ID and the Public Client Key and replace the placeholder values in the JavaScript above. 

Powered by NexWebSites.com -
Certified Authorize.net developers

Hello

 

I do understand- I have read that doc over and over - I have tried that - exactly that see below with exactly the string for ID and KEY that test successfully.see below. What else could be wrong? still get error...Screen is working - does it all returns E_WC_21: User authentication failed due to invalid authentication values.

 

Thank you please help

 

 

<!DOCTYPE html>
<html>

<!--
    This file is a standalone HTML page demonstrating usage of the Authorize.net
    Accept JavaScript library using the integrated payment information form.

    For complete documentation for the Accept JavaScript library, see
    https://developer.authorize.net/api/reference/features/acceptjs.html
-->

<head>
    <title>Sample form</title>
</head>

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

<form id="paymentForm"
    method="POST"
    action="https://YourServer/PathToYourPaymentProcessingScript">
    <input type="hidden" name="dataValue" id="dataValue" />
    <input type="hidden" name="dataDescriptor" id="dataDescriptor" />
    <button type="button"
        class="AcceptUI"
        data-billingAddressOptions='{"show":true, "required":false}' 
        data-apiLoginID="MYID" 
        data-clientKey="9aptdYwtHt2F22XLRgr4B9AM4Pkt5eb6b6MC9d2Nn3m3YEptx3RFFuXmpYWDLHev"
        data-acceptUIFormBtnTxt="Submit" 
        data-acceptUIFormHeaderTxt="Card Information" 
        data-responseHandler="responseHandler">Pay
    </button>
</form>

<script type="text/javascript">
function responseHandler(response) {
    if (response.messages.resultCode === "Error") {
        var i = 0;
        while (i < response.messages.message.length) {
            console.log(
                response.messages.message[i].code + ": " +
                response.messages.message[i].text
            );
            i = i + 1;
        }
    } else {
        paymentFormUpdate(response.opaqueData);
    }
}


function paymentFormUpdate(opaqueData) {
    document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor;
    document.getElementById("dataValue").value = opaqueData.dataValue;

  document.getElementById("paymentForm").submit();
}



function paymentFormUpdate(opaqueData) {
    document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor;
    document.getElementById("dataValue").value = opaqueData.dataValue;

    // If using your own form to collect the sensitive data from the customer,
    // blank out the fields before submitting them to your server.
    // document.getElementById("cardNumber").value = "";
    // document.getElementById("expMonth").value = "";
    // document.getElementById("expYear").value = "";
    // document.getElementById("cardCode").value = "";

    document.getElementById("paymentForm").submit();
}
</script>

<?xml version="1.0" encoding="utf-8"?>
<getMerchantDetailsResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<isTestMode>false</isTestMode>
<processors>
<processor>
<name>First Data Nashville</name>
</processor>
</processors>
<merchantName>fwHGwSdCaR</merchantName>
<gatewayId>565697</gatewayId>
<marketTypes>
<marketType>eCommerce</marketType>
</marketTypes>
<productCodes>
<productCode>CNP</productCode>
</productCodes>
<paymentMethods>
<paymentMethod>AmericanExpress</paymentMethod>
<paymentMethod>DinersClub</paymentMethod>
<paymentMethod>Discover</paymentMethod>
<paymentMethod>EnRoute</paymentMethod>
<paymentMethod>JCB</paymentMethod>
<paymentMethod>Mastercard</paymentMethod>
<paymentMethod>Visa</paymentMethod>
</paymentMethods>
<currencies>
<currency>USD</currency>
</currencies>
<publicClientKey>9aptdYwtHt2F22XLRgr4B9AM4Pkt5eb6b6MC9d2Nn3m3YEptx3RFFuXmpYWDLHev</publicClientKey>
</getMerchantDetailsResponse>

 

 

Where are you getting the error?  In that XML response you posted, the response is successful. 

 

If you are getting the error when including https://js.authorize.net/v3/AcceptUI.js instead of https://jstest.authorize.net/v3/AcceptUI.js, the production endpoint requires seperate production login credentials. 

Powered by NexWebSites.com -
Certified Authorize.net developers

Hello

 

I am getting the error in the console so the form will not go to submit- I get no token..

 E_WC_21: User authentication failed due to invalid authentication values.

 

When I use the TRY it in this page URL it WORKS I give you the results, so I have the correct IDs and KEYS.

 

https://developer.authorize.net/api/reference/#transaction-reporting-get-merchant-details

 

I am asking the client to regenerate the public Client Key could it be old or something- as you can see I am using the example:

 

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

 

I got grumpy and made my own sandbox and  public key and it works now-

 

That old public client key was old or something?

 

So I will have to get this client to regenerate thier keys.

 

The public client key will not impact anything else. They are very nervous.

 

Thanks I am not a dork thanks!  Moving on now ..

I solved this by changing my script source from 

src="https://jstest.authorize.net/v3/AcceptUI.js"

 to 

src="https://js.authorize.net/v3/AcceptUI.js"

 

Probably wont help everyone but if you're sure your codes are good, maybe this is the issue. 

Complex210
Member