The remote server returned an error: (401) Unauthorized.

mbarone
Regular Visitor

The remote server returned an error: (401) Unauthorized.

Hi, 

I am getting an error while implementing visa cyber source using c# code and I have downloaded source code for that after creating a project but getting error may be x-pay-token was not generating correctly. Is there any way so I can verify my token or generate it with any API by passing parameter. Below code, I am using 

 

string baseUri = "cybersource/";
string resourcePath = "v2/payments";

string xPayToken = GetXPayToken(resourcePath, "apikey=" + apikey, requestBodyString);

 

 

private static string GetXPayToken(string apiNameURI, string queryString, string requestBody)
{
string timestamp = GetTimestamp();
string sourceString = timestamp + apiNameURI + queryString + requestBody;
string hash = GetHash(sourceString);
string token = "xv2:" + timestamp + ":" + hash;
return token;
}

 

private static string GetHash(string data)
{
string sharedSecret = ConfigurationManager.AppSettings["VisaPaySharedSecret"];
var hashString = new HMACSHA256(Encoding.ASCII.GetBytes(sharedSecret));
var hashbytes = hashString.ComputeHash(Encoding.ASCII.GetBytes(data));
string digest = String.Empty;

foreach (byte b in hashbytes)
{
digest += b.ToString("x2");
}

return digest;
}

 

 

3 REPLIES 3
API_Products
Visa Developer Support Specialist

Re: The remote server returned an error: (401) Unauthorized.

Hey @mbarone,

 

After meeting with CyberSource, we have come to learn that VDP generated Merchant ID’s will experience an unresolvable gateway issue.
 
The EBC error message: The payment processor gateway name is either invalid or missing
 
Currently, the only method to properly query the CyberSource Payments sandbox is creating a merchant account directly with CyberSource:
 
https://developer.cybersource.com

 

Luckily, their site also provides an easy to use method to test their account credentials:
 
https://developer.cybersource.com/api/reference/api-reference.html 
 
Additionally, here are the following links for sample code:  https://github.com/CyberSource/cybersource-rest-samples-java/blob/master/src/main/java/samples/payme... 

 




Thanks,

Tee



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

mbarone
Regular Visitor

Re: The remote server returned an error: (401) Unauthorized.

Thank for your consideration,

Can you please elaborate where should I start 

1. Do I need to register with the cyber source?

2. Is all the transaction, will I able to see them on the visa dashboard?

3. If I do transactions with Cyber source where is the role of visa developer?

4. Is x-pay-token generated by me is correct or not or can I verify it?
5. Are you able to find my failed transaction?

6. Why I am not getting the exact error message?
7. For API Url -

https://sandbox.api.visa.com/cybersource/v2/payments?apikey={apikey}

and I am using below code for generating x-pay-token is it correct or not

string baseUri = "cybersource/";
string resourcePath = "v2/payments";

 

 

API_Products
Visa Developer Support Specialist

Re: The remote server returned an error: (401) Unauthorized.

Hey @mbarone,

 

There's an expert team that manages questions specific to CyberSource. Please call CyberSource Support at 800-709-7779.

 

 




Thanks,

Tee



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