Hi, I am getting a 401 "UNAUTHORIZED_USER" error as shown below when trying to process payment per the API DOC
The URL I am posting to is:
https://sandbox.api.visa.com/cybersource/payments/flex/v1/tokens?apikey={apikey}
And the response error is:
{
"response": {
"rmsg": {
"error": "UNAUTHORIZED_USER",
"error_description": "UNAUTHORIZED USER"
}
}
}
Solved! Go to Solution
Sorry, I posted wrong API before.
The correct payment API is
https://sandbox.api.visa.com/cybersource/v2/payments?apikey={apikey}
The request body as follows:
{"clientReferenceInformation":{"code":"TC50171_3"},"processingInformation":{"commerceIndicator":"internet"},"orderInformation":{"billTo":{"country":"US","lastName":"VDP","address2":"Address 2","address1":"201 S. Division St.","postalCode":"48104-2201","locality":"Ann Arbor","administrativeArea":"MI","firstName":"RTS","phoneNumber":"999999999","district":"MI","buildingNumber":"123","company":"Visa","email":"test@cybs.com"},"amountDetails":{"totalAmount":"102.21","currency":"USD"}},"paymentInformation":{"card":{"expirationYear":"2031","number":"5555555555554444","securityCode":"123","expirationMonth":"12","type":"002"}}}
Additional info: It is successful to generate key for below API
https://sandbox.api.visa.com/cybersource/payments/flex/v1/keys?apikey={apikey}
So, I think generating x-pay-token method is right. I use same method for payment API with failed result.
Please help to figure out this problem. Thanks
Hey @dtslog,
That's a good question. The only way to correctly test the CyberSource Payments sandbox is creating a merchant account directly with CyberSource:
https://developer.cybersource.com
CyberSource provides a simple method to test their account credentials:
https://developer.cybersource.com/api/reference/api-reference.html
Furthermore, here are the following links for sample code: https://github.com/CyberSource/cybersource-rest-samples-java/blob/master/src/main/java/samples/payme...
Great. Thanks for the solution.
The only way to properly test the secure environment for online service payments is to create a direct account for your cyber source account. Thanks