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);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)
{
}
return digest;
}