Hi there!
I am having troubles with the validation of the x-pay-token authentication process:
What I Did:
1) Created an app in the developer Dashboard where I Add the "Visa Token Service" API.
2) I build an App in C# to test the services, that uses the code in the Official Visa Github repository:
https://github.com/visa/SampleCode/tree/master/vdp-c-sharp
I used the class VisaAPIClient.cs which calculates the x-pay-token and build and send the request.
3) With that C# App i Succesfully called the helloworld service:
https://sandbox.api.visa.com/vdp/helloworld
4) When i try to call any service from "Visa Token Service" API i always get the error in the response:
{"errorResponse":{"status":401,"message":"Token Validation Failed","reason":"inputValidationError","details":[{"location":"x-pay-token"}]}}
5) The x-pay-token calculation and request build message is done by that class Visa Provides in their Sample repository.
Could not be the apiKey or shared secret because the helloworld worked. It is in the data that i am sending?
Help) I next show the C# file from the soultion that I used to test, where is the request body i use, i do not include the sandbox apiKey and shared secret for obvious reason.
using System; using System.Configuration; using Vdp; namespace TestService { class Program { /* WARINING: Before you test this App configure the following fields in the "App.config" file: - apiKey - sharedSecret - visaUrl: I put the one i used, but could be another one? VisaAPIClient Class is provided by the official Github Visa repository. */ static void Main(string[] args) { try { string bodyData; string baseUri; string resourcePath; VisaAPIClient visaAPIClient = new VisaAPIClient(); System.Console.WriteLine("Testing VISA service..."); bool TEST_HELLOWORLD = false; if(TEST_HELLOWORLD == true) { //for Helloworld: baseUri = "vdp/"; resourcePath = "helloworld"; bodyData = ""; } else { //For panEnrollments service: THIS TEST IS FAILING. baseUri = ""; resourcePath = "vts/panEnrollments"; bodyData = @"{ ""clientAppID"": ""98765432"", ""clientWalletAccountID"": ""FAmwn"", ""consumerEntryMode"": ""KEYENTERED"", ""encPaymentInstrument"": ""123456789321654987"", ""locale"": ""en_US"", ""panSource"": ""MANUALLYENTERED"" }"; //@"{""clientAppID"":""98765432"",""clientWalletAccountID"":""FAmwn"",""consumerEntryMode"":""KEYENTERED"",""encPaymentInstrument"":""123456789321654987"",""locale"":""en_US"",""panSource"":""MANUALLYENTERED""}"; } //Do the request: string queryString = "apikey=" + ConfigurationManager.AppSettings["apiKey"]; visaAPIClient.DoXPayTokenCall(baseUri, resourcePath, queryString, "GET", "Test servicecall ", bodyData); System.Console.WriteLine("End Test..."); } catch(Exception exc) { System.Console.WriteLine("Exception: " + exc.Message.ToString()); } } } }
Thank you very much in advance for your Help, we have exausted all the ideas for this. Thanks.
Solved! Go to Solution
Hello,
Few things to note while generating token:
Note:
For Flex Keys resource we have to send xpaytoken
https://sandbox.api.visa.com/cybersource/payments/flex/v1/keys?apikey={apikey}
for flex Tokens there will be no xpaytoken
https://sandbox.api.visa.com/cybersource/payments/flex/v1/tokens
Try this out and keep me updated!
Thanks
Sanobar
Than for the help, we finallt make it work, there was two problems:
- The panEnrollments service required POST http method instead GET as we badly used.
- The "apiKey" was with "K" upper case, wich is different from the helloworld example wich uses "apikey" with "k" lower case, this API incosistency is cruel, and lead us to the confusion.
thanks you!