401 on Cybersource Payments REST API (Process a Payment)

Solved! Go to solution
dtslog
Regular Visitor

401 on Cybersource Payments REST API (Process a Payment)

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"
      }
   }
}

 

5 REPLIES 5
dtslog
Regular Visitor

Re: 401 on Cybersource Payments REST API (Process a Payment)

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

 

API_Products
Visa Developer Support Specialist

Re: 401 on Cybersource Payments REST API (Process a Payment)

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

 

 




Thanks,

Diana H.



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

dtslog
Regular Visitor

Re: 401 on Cybersource Payments REST API (Process a Payment)

Thanks for your help!
martheneilson
Regular Visitor

Re: 401 on Cybersource Payments REST API (Process a Payment)

Great. Thanks for the solution.

MarthaNeilson
martheneilson
Regular Visitor

Re: 401 on Cybersource Payments REST API (Process a Payment)

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

MarthaNeilson