Encryption keys
Fetch Pay.com's PayCSE public keys from /cse/keys, choose the one to encrypt with, and handle key rotation.
Pay.com publishes the public keys for PayCSE as a JSON Web Key Set (JWKS). Pay.com.js and the mobile SDKs fetch and choose keys for you. Call these endpoints directly only if you encrypt with your own code or cache keys yourself.
Endpoints
Each environment has its own key set at /cse/keys on its API host. Live and sandbox keys are never mixed. The web, iOS, and Android SDKs are configured with these key set URLs, and write the same host into a token's aud:
Live: https://api.pay.com/cse/keys aud: api.pay.com
Sandbox: https://api.sandbox.pay.com/cse/keys aud: api.sandbox.pay.comThe endpoints are public: no API key, any origin (Access-Control-Allow-Origin: *), no credentials.
Get the key set
Send a GET request with no credentials:
curl https://api.sandbox.pay.com/cse/keysReturns application/jwk-set+json, the environment's current keys sorted by pay_active_from:
{
"keys": [
{
"kty": "RSA",
"kid": "cse-test-2026-11",
"use": "enc",
"alg": "RSA-OAEP-256",
"n": "…",
"e": "AQAB",
"pay_active_from": 1794787200
}
]
}| Member | Description |
|---|---|
kty | Always RSA. |
kid | The key ID, 1 to 64 characters of A-Z a-z 0-9 . _ -. It goes in the token header. |
use | Always enc. |
alg | Always RSA-OAEP-256. |
n | The RSA-3072 modulus, base64url (384 bytes). |
e | The public exponent, always AQAB (65537). |
pay_active_from | When to start encrypting with this key, in seconds since the Unix epoch. It's a Pay.com member, so generic JOSE libraries ignore it. |
The response carries Cache-Control: public, max-age=300, s-maxage=300, stale-while-revalidate=600, stale-if-error=86400.
Get one key
Add the key ID to the path:
curl https://api.sandbox.pay.com/cse/keys/cse-test-2026-11Returns one key as application/jwk+json. A key ID's material never changes, so this response is cached for a year (immutable).
Responses
Both endpoints return these status codes:
| Status | Meaning |
|---|---|
200 | The key set, or the key. Responses carry an ETag. |
304 | Not modified, when you send If-None-Match with the ETag you have. |
404 | Unknown key ID, host, or path. |
503 | No usable key is available right now. Don't encrypt. Try again later. |
Choose the key to encrypt with
Every SDK uses the same rule:
- Consider only keys with
ktyRSA,useenc,algRSA-OAEP-256,eAQAB, and a 384-byten. - Pick the key with the greatest
pay_active_fromthat isn't after now. - If none qualifies (the device clock is far behind), pick the key with the smallest
pay_active_from. - If there's no usable key, don't encrypt and don't send the card. Never fall back to a key bundled in your code.
Rotation and caching
Pay.com publishes a new key at least 7 days before its pay_active_from, and keeps accepting the previous key for at least 7 days after that. Pay.com accepts every key in the environment's set, including one published early.
- Fetch the key set when your checkout loads, so the key is ready when the customer submits.
- Keep a key set for at most 24 hours.
- If Pay.com refuses a token with
decline_code: "cse_unknown_key", fetch the set again once (bypassing your cache), encrypt again, and retry once.