Error from running SOAP UI example for X-PAY TOKEN

Highlighted
Occasional Visitor

Error from running SOAP UI example for X-PAY TOKEN

{"responseStatus":{"code":"9101","severity":"ERROR","info":"","status":401,"message":"Token validation failed"}}

I ran this code:

 

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 = ‘VALUE_OF_YOUR_API_KEY’
def sharedSecret = ‘VALUE_OF_YOUR_SHARED_SECRET’
def URI = "helloworld"
def QS = "apikey="+APIKey
def timeStampUTC = String.valueOf(System.currentTimeMillis().intdiv(1000L))
def payload = ""
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)

 

I followed your instructions to the T and get this error. Please advice what I need to do.

(I only changed  APIKey and sharedSecret)

1 REPLY 1
Highlighted
Visa Dev Moderator
Visa Dev Moderator

Re: Error from running SOAP UI example for X-PAY TOKEN

Hi @petablue,

I recommend using the VDC Playground tool to test X-Pay Token. You can find the guide on Getting Started with VDC Playground from this blog post here - https://developer.visa.com/pages/visa-developer-center-playground

 

Here's my setup for reference:

 

TestXPayToken_Playground.png

 

1. Select Auth Method as X-Pay Token.

2. Get the API Key and Shared Secret from VDP Dashboard  > Credentials section.

3. Provide the API key as part of query parameter on the API End Point.

4. Provide the Shared Secret in the settings input field.

 

Hope this helps.


Best,
Stacey

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