Hi All,
I have an issue while doing payment through Authorize.Net with Accept.js methodology in sandbox environment only. I am facing this issue from last few days. The integration with Accept.js is already in place in our application and it is working fine on production Accept.js but suddenly, it is stopped working in sandbox Accept.js. I have not changed any code and same code is working for production.
Sandbox URL: https://jstest.authorize.net/v1/Accept.js
I am submitting payment in below code:
Accept.dispatchData(secureData, responseHandler);
The "secureData" being submitted is:
{
"cardData": {
"cardNumber": "4111111111111111",
"month": "12",
"year": "2022",
"zip": "99503",
"fullname": "Test"
},
"authData": {
"clientKey": "{ClientKey}",
"apiLoginID": "{APILoginID}"
}
}
It generates an OPTIONS error response of :
{
"messages": {
"resultCode": "Error",
"message": [
"code": "E00003",
"text": "Root element is missing."
]
}
}
I also get a POST response from "https://apitest.authorize.net/xml/v1/request.api"
{
"opaqueData": {
"dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
"dataValue": "{someAlphnumericString}"
},
"messages": {
"resultCode": "Ok",
"message": [
"code": "I00001",
"text": "Successful."
]
}
}
After above response, while responseHandler() is invoked to submit transaction details, no response was received from Authorize.Net for this request. I have checked for the different set of values but no joy. Please let me know what I need to do for this.
Anyone is or was facing this issue, please add comment and provide solution.
Solved! Go to Solution.
05-28-2018 09:38 AM - edited 05-28-2018 09:41 AM
The reason this occurs is that the `Accept.dispatchData` function triggers a pre-flight OPTIONS request (we're dealing with CORS here). This request, on A.net's end, triggers the error response you are seeing. Why this triggers the pre-flight request may be related to certain headers in use. You can read more about it here. (it's most likely related to the `content-type` header)
On our end we currently have a workaround. Essentially in the function passed in as the `responseHandler` parameter we check to see if the response contains the classic 'encryption failed' message and ignore it.
07-12-2018 03:17 PM - edited 07-12-2018 03:22 PM
The reason this occurs is that the `Accept.dispatchData` function triggers a pre-flight OPTIONS request (we're dealing with CORS here). This request, on A.net's end, triggers the error response you are seeing. Why this triggers the pre-flight request may be related to certain headers in use. You can read more about it here. (it's most likely related to the `content-type` header)
On our end we currently have a workaround. Essentially in the function passed in as the `responseHandler` parameter we check to see if the response contains the classic 'encryption failed' message and ignore it.
07-12-2018 03:17 PM - edited 07-12-2018 03:22 PM
Hey RichardH, thanks for accepting my response as the solution.
First and foremost I really like A.net's Accept.js integration method, as well as the API (only gateway that allows easy validation of merchant credentials).
However maybe on A.net's end the request made by `Accept.dispatchData` should be changed to have a `Content-type` of `application/x-www-form-urlencoded` so that it no longer triggers this pre-flight request. Merely a suggestion, the OPTIONS request could also be ignored by AcceptCore
07-12-2018 03:51 PM - edited 07-12-2018 03:56 PM
Thanks for the note. I've forwarded your suggestion to our product team for consideration.
You are welcome to post this as a new feature using our Ideas forum. This will allow others to vote on and make suggestions to improve the request.
Richard
07-12-2018 04:34 PM
Hi,
I am still getting this error and I am not able to reach to the request.api call that is successful.
There are two calls, one with the E0003 error which is with OPTIONS header.
This is causing the Encryption Failed error in the response. Even if I check for this scenario and ignore this condition, the problem is how to reach the second correct call? Since the response is hitting only once. I am really stuck here. Please help.
Thanks
-Stuti
07-25-2018 05:15 PM
hi,
I am stcuk with this error.
Beacuse of the OPTIONS call with error code E0003, the response shows the Encryption Failed error. There is no way to reach the successful second response. I handled the case where I check for this condition but since its hitting the responseHandler only one time, I am not able to get the opaqueData which I see in the second call. I am really stuck here.
Please help.
Thanks
Stuti
07-25-2018 05:19 PM
Ignore this. I have a new thread for the actual issue.
07-26-2018 01:41 PM