Reply
Highlighted
Member
Posts: 1
Registered: ‎07-04-2020

Missing or invalid token

I'm getting "Missing or invalid token" message when I submit the data elements via custom form.

I'm using 

https://test.authorize.net/payment/payment
<script type="text/javascript">
function sendPaymentDataToAnet() {
var authData = {};
authData.clientKey = "my transaction key";
authData.apiLoginID = "my api login ID";

var cardData = {};
//cardDat.cardName = document.getElementById("fullName").value;
cardDat.cardAmount = document.getElementById("cardAmount").value;
cardData.cardNumber = document.getElementById("cardNumber").value;
cardData.month = document.getElementById("expMonth").value;
cardData.year = document.getElementById("expYear").value;
cardData.cardCode = document.getElementById("cardCode").value;
var secureData = {};
secureData.authData = authData;
secureData.cardData = cardData;
Accept.dispatchData(secureData, responseHandler);
function responseHandler(response) {
if (response.messages.resultCode === "Error") {
var i = 0;
while (i &lt; 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;

// 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>