본문 바로가기

[Other API]

[Visa] API Key – Shared Secret (X-Pay-Token) [by SOAPUI ]

developer.visa.com/pages/working-with-visa-apis/x-pay-token

 

https://developer.visa.com/pages/working-with-visa-apis/x-pay-token

import java.math.BigInteger; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.security.SignatureException; public static String generateXpaytoken(String resourcePath, String queryString,

developer.visa.com

 

> www.soapui.org/

 

The World's Most Popular API Testing Tool | SoapUI

Accelerating API Quality Through Testing Whether open source or commercial, SmartBear testing tools make it easy to create, manage, and execute end-to-end tests on REST, SOAP, & GraphQL APIs, JMS, JDBC, and other web services so you can deliver software fa

www.soapui.org

 

Download click
Download SoapUI Open Source Click!

 

 

To Be Continue..

 

 

 

Below is  visa developer center web page.

visa debeloper center dashboard

 

 

 

check the checkbox that need the x-pay-token.

 

 

 

I checked the CyberSource Payments checkbox.

 

 

click the Create Project button.

 

 

 

 

Back to SoaUI.

 

 

copy test url :

Method : GET

https://sandbox.api.visa.com/vdp/helloworld?apikey=<your api key>

Click the OK button.

 

Select the API and right click on it. And select Generate TestSuite.

 

Paste this script below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
cs

 

xv2:16123...... << copy!

 

Request 1 << double click
headers << click
value is [xv2:16123...... ] << paste! And ▶(run) / JSON tab click!