Registry transport credentials and agent request signatures have separate roles.
| Surface | Credentials / proof | Where used |
|---|---|---|
| VARS · X-Pay-Token | VDP API key + decrypted shared secret; HMAC SHA-256. | ?apiKey=… and x-pay-token on the registry call. |
| VARS · two-way TLS (mTLS) | VDP client certificate/private key + HTTP Basic username/password. | TLS handshake plus Authorization: Basic …; this mode sends no API-key query or X-Pay-Token. |
| VMRS merchant registry | The public OpenAPI omits authentication details. | Select the product’s VDP project authentication; validate its headers / TLS requirements before use. |
| Agent → merchant | Agent’s private TAP signing key, paired with its registered public key. | RFC 9421 Signature-Input and Signature; profile may add Signature-Agent. |
| Visa → merchant ID token | Visa’s signing key, selected using JWT kid and trusted issuer metadata. | Verify the separate signed ID token inside consumer recognition data. |
| Payment → merchant encryption | Merchant’s VMRS public encryption key; merchant retains the private key. | Protects an encrypted payment payload for the merchant. |
X-Pay-Token, byte for byte
message = timestamp + resourcePath + queryString + requestBody
digest = lowercaseHex(HMAC_SHA256(sharedSecret, UTF8(message)))
token = "xv2:" + timestamp + ":" + digest| Component | Exact VARS rule | Example |
|---|---|---|
timestamp | UTC Unix seconds. Generate after any queued delay. | Math.floor(Date.now() / 1000) |
resourcePath | Strip the leading slash and the vars/ context segment. | /vars/v1/agents → v1/agents |
queryString | Sorted query pairs, no leading ?. Includes apiKey. Use identical encoded bytes in URL and HMAC. | apiKey=YOUR_KEY&page=1&pageSize=30 |
requestBody | Exact raw UTF-8 body bytes; empty string for body-less GET / DELETE / activation calls. | Serialize once and reuse the same string. |
import { createHmac } from "node:crypto";
// Serialize once. Hash and transmit the same UTF-8 string.
function varsXPayRequest({ baseUrl, path, method, apiKey,
sharedSecret, payload, query = {} }) {
const body = payload === undefined ? "" : JSON.stringify(payload);
const params = new URLSearchParams();
for (const [key, value] of Object.entries(query))
params.set(key, String(value));
params.set("apiKey", apiKey);
params.sort();
const qs = params.toString();
const resourcePath = path.replace(/^\//, "").replace(/^vars\//, "");
const timestamp = String(Math.floor(Date.now() / 1000));
const digest = createHmac("sha256", sharedSecret)
.update(timestamp + resourcePath + qs + body, "utf8")
.digest("hex");
const token = "xv2:" + timestamp + ":" + digest;
return fetch(baseUrl.replace(/\/$/, "") + path + "?" + qs, {
method,
headers: {
accept: "application/json",
"content-type": "application/json",
"x-pay-token": token
},
...(body === "" ? {} : { body })
});
}Compact JSON is convenient when generated once. Whitespace, query order and encoding must match the bytes sent; this guide does not assume server-side JSON canonicalization. HTTP method is not a component of this X-Pay-Token formula.
Environment and credential setup
Create / select a VDP project with the required API access, obtain credentials for the intended environment and complete the platform’s next-environment onboarding when applicable. The public OpenAPI specifies https://sandbox.api.visa.com. Visa CLI requires an explicit VARS base URL and never silently falls back to sandbox.
The current X-Pay setup guide describes uploading an RSA public key to receive an encrypted shared secret, then decrypting it using the corresponding private key and OAEP SHA-256. Those setup keys are separate from the agent’s TAP signing key.
For mTLS, set TLS 1.2 minimum, verify server certificates, refuse redirects and add HTTP Basic auth. Have the complete credential set for the mode you select.
Sources: TAP merchant specifications, VDP X-Pay Token authentication, VDP Two-Way SSL authentication, VDP quick start, VDP environment switching and testing, VDP going live.