I have developed an online payment page using PHP and jQuery that allows both CIM payment submissions as well manual credit card entry.
I have no problems submitting the CIM payments to the sandbox but when I use the exact same merchantAuthenticationType values
to Accept.dispatchData() I get an E00007/E_WC_21 "User authentication failed due to invalid authentication values." error.
I have been going through the previous posts about this but none of them answered why one method works while the other doesn't when both use the same authentication values.
CIM process
client javascript
function submitCIMPayment(data) { var submission = { _token: Billing.token, amount: data['amount'], cardCode: data['card-cvv'], gateway_id: data['gateway_id'], gateway_ppid: data['gateway_ppid'] }; $.post("/billing/payment", submission) .done(function (data) { ... }) .fail(function(data){ ... }); }
server php
public function chargeProfile($authAccount, $amount, $cardCode, $user) { $profileToCharge = new AnetAPI\CustomerProfilePaymentType(); $profileToCharge->setCustomerProfileId($authAccount->gateway_id); $paymentProfile = new AnetAPI\PaymentProfileType(); $paymentProfile->setPaymentProfileId($authAccount->gateway_ppid); $paymentProfile->setCardCode($cardCode); $profileToCharge->setPaymentProfile($paymentProfile); $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setProfile($profileToCharge); $request = new AnetAPI\CreateTransactionRequest(); $merchant = new AnetAPI\MerchantAuthenticationType() $merchant->setName($config['login']); $merchant->setTransactionKey($config['key']); $request->setMerchantAuthentication($merchant) $request->setTransactionRequest($transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse('https://apitest.authorize.net'); ... }
There have been no errors with the CIM process.
Accept.JS process
client javascript
<script src="https://jstest.authorize.net/v1/Accept.js" type="text/javascript" charset="utf-8"></script> function sendCardDataToAnet(data) { var secureData = {}, authData = {}, cardData = {}; cardData.cardNumber = data['card-number']; cardData.month = data['expiration'][1]; cardData.year = data['expiration'][0]; cardData.cardCode = data['card-cvv']; authData.clientKey = Billing.clientKey; authData.apiLoginID = Billing.apiLoginID; secureData.cardData = cardData; secureData.authData = authData; /* Dispatch Data to Accept.js */ Accept.dispatchData(secureData, 'anetResponseHandler'); } function anetResponseHandler(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 { submitSecurePayment(response.opaqueData); } }
The console output is: E_WC_21: User authentication failed due to invalid authentication values.
Solved! Go to Solution.
06-13-2018 09:57 AM
Hi @wdbaker54
The error is with your clientKey in Accept.js, as per the dump you have shared for the authData the authentication values which you are using are incorrect.
Please generate a CleintKey by logging into the Merchant Interface and navigating to Account --> Security Settings --> Manage Public Client Key, and use this as clientKey in authData.
Hope this Helps !
06-14-2018 11:10 AM
So what you are saying is that they don't use the same values:
My mistake was that I thought that both processes used the same values - only the API Login ID is used for both. I am now beyond that problem but still haven't been successful in completing an accept.js transaction but it is now with the remainder of my code and not my understanding of the API.
Thanks for pointing me in the right direction - I read and re-read the APIs and still missed the difference.
06-14-2018 01:08 PM
In case someone needs more information, Here is the JSON data for the Accept.dispatchData() secureData parameter:
{ "authData": { "apiLoginID": "72RxxxvP", "clientKey": "295U3Xxxx7DLQ3dg" }, "cardData": { "cardCode": "151", "cardNumber": "4111111111111111", "month": "07", "year": "2024" } }
(I don't want to be paranoid but the apiLoginID and clientKey were tweaked even though this is a sandbox account)
and a JSON dump of the merchantAuthenticationType values:
{ "name": "72RxxxvP", "transactionKey": "295U3Xxxx7DLQ3dg" }
06-14-2018 09:22 AM
Hi @wdbaker54
The error is with your clientKey in Accept.js, as per the dump you have shared for the authData the authentication values which you are using are incorrect.
Please generate a CleintKey by logging into the Merchant Interface and navigating to Account --> Security Settings --> Manage Public Client Key, and use this as clientKey in authData.
Hope this Helps !
06-14-2018 11:10 AM
So what you are saying is that they don't use the same values:
My mistake was that I thought that both processes used the same values - only the API Login ID is used for both. I am now beyond that problem but still haven't been successful in completing an accept.js transaction but it is now with the remainder of my code and not my understanding of the API.
Thanks for pointing me in the right direction - I read and re-read the APIs and still missed the difference.
06-14-2018 01:08 PM
06-14-2018 10:02 PM