Client-side encryption
Encrypt card data on the device to a Pay.com key so that only Pay.com can read it, then send the encrypted token instead of the card.
PayCSE, Pay.com's client-side encryption, lets your web page, your app, or your server send card data to Pay.com encrypted to a Pay.com public key. The private key never leaves Pay.com's key management, so only Pay.com can decrypt the card. Code that forwards the token, including your server, can't read it.
How it works
A payment with client-side encryption takes four steps:
- Fetch your environment's public keys from
/cse/keysand pick the current one. - Encrypt the card (or, for a saved card, only the CVV) into a token on the device.
- Send the token where you would have sent the card: through Pay.com.js or a mobile SDK, or from your server in an
encrypted_cardorencrypted_cvvfield. - Pay.com decrypts the token, checks it, and tokenizes the card as it does for any other card payment.
Pay.com.js and the mobile SDKs do steps 1 and 2 for you.
The token
One card is one token: a JWE (JSON Web Encryption) string in compact serialization, five base64url segments separated by dots, at most 4096 characters.
| Part | Value |
|---|---|
| Key wrapping | RSA-OAEP-256 (SHA-256 for both the hash and MGF1) with a fresh 256-bit key per token, to a Pay.com RSA-3072 key |
| Content encryption | AES-256-GCM with a random 12-byte IV and a 16-byte tag. The additional authenticated data is the protected header segment as it appears in the token. |
| Segments | Protected header, encrypted key (384 bytes), IV, ciphertext, tag |
| Header | {"alg":"RSA-OAEP-256","enc":"A256GCM","kid":"…","cty":"pay.card+json","v":1}, exactly these five members |
Inside, the token carries the card (or the CVV) and claims that bind it to one use:
| Claim | Meaning |
|---|---|
mid | Your Pay.com merchant ID. Pay.com accepts the token only for this merchant. |
aud | The API host the token is for: api.pay.com for live, api.sandbox.pay.com for the sandbox. See Encryption keys. |
sid | The payment session the token belongs to, when it's sent with that session's client_secret: ps_ (or ss_ for a setup session) followed by 18 to 20 digits. Absent when your server sends it with an API key. |
iat | When it was encrypted. Pay.com refuses a token as expired once iat is more than 1200 seconds (20 minutes) in the past. |
jti | A random ID. Each token is accepted once. |
sdk | Which SDK made it, for example web/1.0.0. Informational. |
The SDKs set these claims. If you build tokens yourself, see the payload.
Choose an integration
Pick an integration by who collects the card and when to use it:
| Integration | Who collects the card | Use it when |
|---|---|---|
| Hosted or secure card fields | Pay.com iframes on your page | You want the card never to exist on your page. |
checkout.cse() | Your own card form | You need your own card inputs on the web, and still want only an encrypted token to leave the page. |
PayCSE.create() | Your own card form | You encrypt in the browser and send the token to your server, which calls the API. |
| Mobile SDKs | SDK-owned fields or your own | Your iOS or Android app pays, or forwards tokens to your server. |
| Server API | Any of the above | Your server sends encrypted_card or encrypted_cvv with its API key. |
What your servers see
The card is encrypted on the device with Pay.com's public key, so your servers never see it in the clear. With your own card form, your page or app still handles the card before it's encrypted. With hosted or secure card fields, the card never exists on your page at all.
Security properties
Beyond the encryption itself, PayCSE limits where card data and keys can appear:
- Errors and events name a card field, never its value.
- Each environment has its own keys. Live and sandbox keys are never mixed, and a token encrypted for one environment is refused by the other.
- The SDKs never bundle a key. Without a usable key from
/cse/keys, they don't encrypt and don't fall back to sending the card.