Skip to Content
Docs

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.com

The 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/keys

Returns 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
    }
  ]
}
MemberDescription
ktyAlways RSA.
kidThe key ID, 1 to 64 characters of A-Z a-z 0-9 . _ -. It goes in the token header.
useAlways enc.
algAlways RSA-OAEP-256.
nThe RSA-3072 modulus, base64url (384 bytes).
eThe public exponent, always AQAB (65537).
pay_active_fromWhen 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-11

Returns 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:

StatusMeaning
200The key set, or the key. Responses carry an ETag.
304Not modified, when you send If-None-Match with the ETag you have.
404Unknown key ID, host, or path.
503No usable key is available right now. Don't encrypt. Try again later.

Choose the key to encrypt with

Every SDK uses the same rule:

  1. Consider only keys with kty RSA, use enc, alg RSA-OAEP-256, e AQAB, and a 384-byte n.
  2. Pick the key with the greatest pay_active_from that isn't after now.
  3. If none qualifies (the device clock is far behind), pick the key with the smallest pay_active_from.
  4. 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.

Use only keys from these endpoints. Pay.com never takes a key from a token. A header that names or carries a key (such as jku or jwk) makes the token invalid. Tokens encrypted to another environment's key are refused.

Was this page helpful?