Hi,
I tried to run Enroll Customer API for Visa In-App Provisioning but I got the following error:
{"responseStatus": { "status": 401, "code": "9159", "severity": "ERROR", "message": "Token Validation Failed", "info": "" }}
- I already set the SSL settings
- I already put the userid and password (basic authorization)
- I already put the x-pay-token value from groovy script which is shown in the helloworld example (but change URI="helloworld" to URI="customers")
I already tried the hello world API calling using SOAP UI in here: https://developer.visa.com/pages/working-with-visa-apis/x-pay-token and it return the helloworld successfully.
So, I'm not sure what's wrong with my API call. Can anyone please give a hint/ help on how to solve this issue please?
(This is my groovy script to generate x-pay token, I changed the "helloworld" to "customers")
Hi @flomaya,
Please follow the steps in the developer.visa.com Getting started and test whether certificates are good.
https://developer.visa.com/pages/working-with-visa-apis/visa-developer-quick-start-guide
If that works, then send us the json http request and response (complete request and response with header values) and we can help if there is an issue.
Thank you,
Vaibhav
Hi,
Thanks for your reply.
I actually has done the 2 steps you are talking about. Hence my first screenshot, where the helloworld successfully returned.
Here are my HTTP Request and Respond of the Enroll Customer API ( https://developer.visa.com/capabilities/visa-in-app-provisioning/reference#visa-in-app-provisioning_... ) :
{
"lastName": "Paramita",
"firstName": "Maya",
"locale": "en_US"
}
{"responseStatus": {
"status": 401,
"code": "9102",
"severity": "ERROR",
"message": "Token Validation Failed",
"info": ""
}}
I suspect the cause of the error might be in the x-pay-token groovy script. For helloworld we use "helloworld" in the def uri right? So I am not sure what value to be put to the parameter there for the Enroll Customer API.
This is the helloworld x-pay-token groovy script in helloworld that I was talking about:
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
def hmac(String secretKey, String data) {
Mac mac = Mac.getInstance("HmacSHA256")
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256")
mac.init(secretKeySpec)
byte[] digest = mac.doFinal(data.getBytes())
return digest
}
def APIKey = "CXPUGIJAGG7MZ5DMVOI321BUCz1t9fUabZ9l8oEauadUkv2_0"
def sharedSecret = "MC1NE#FdQnEWaLLXGrmyC{ld2fC2Vhj9Dzhfc#En"
def URI = "customers"
def QS = "apikey="+APIKey
def timeStampUTC = String.valueOf(System.currentTimeMillis().intdiv(1000L))
def payload = "{\"lastName\": \"Doe\", \"firstName\": \"John\", \"locale\": \"en_US\", \"encMobileNumber\": \"ewogICJjb3VudHJ5Q29kZSI6ICI2MiIsCiAgInBob25lTnVtYmVyIjogIjgxMjg4MTQwNjkyIgp9\",\"encEmailAddress\": \"bWFwZW1hcGVsYUBnbWFpbC5jb20=\", \"encAddress\":\"ewogICJuYW1lIjogIkpvaG4gRG9lIiwKICAibGluZTEiOiAiMTIzMDEgUmVzZWFyY2ggQm91bGV2YXJkIiwKICAibGluZTIiOiAiUmVzZWFyY2ggQm91bGV2YXJkIiwKICAibGluZTMiOiAiVmlzYSBVU0EiLAogICJjaXR5IjogIkF1c3RpbiIsCiAgInN0YXRlIjogIlRYIiwKICAiY291bnRyeUNvZGUiOiAiVVMiLAogICJwb3N0YWxDb2RlIjogIjc4NzU5Igp9\"}"
def HMACDigest = hmac(sharedSecret, timeStampUTC + URI + QS + payload)
def encodedDigest = HMACDigest.encodeHex().toString()
def XPayToken = "xv2:"+ timeStampUTC + ":" + encodedDigest
testRunner.testCase.setPropertyValue("xpayToken", XPayToken)
log.info(XPayToken)
Hello @flomaya,
I am working with our product team on the error you reported. I will keep you updated.
Thank you,
Vaibhav
Hello @flomaya,
Can you confirm if you are using URI value as core/customers instead of customers.
Thanks,
Vaibhav
Hi @vkamboj
Yes, I have tried to use core/customers too, but it still shows this following error result:
{"responseStatus": {
"status": 401,
"code": "9159",
"severity": "ERROR",
"message": "Token Validation Failed",
"info": ""
}}
;Hello @flomaya,