Skip to Content
Docs

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:

  1. Fetch your environment's public keys from /cse/keys and pick the current one.
  2. Encrypt the card (or, for a saved card, only the CVV) into a token on the device.
  3. 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_card or encrypted_cvv field.
  4. 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.

PartValue
Key wrappingRSA-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 encryptionAES-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.
SegmentsProtected 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:

ClaimMeaning
midYour Pay.com merchant ID. Pay.com accepts the token only for this merchant.
audThe API host the token is for: api.pay.com for live, api.sandbox.pay.com for the sandbox. See Encryption keys.
sidThe 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.
iatWhen it was encrypted. Pay.com refuses a token as expired once iat is more than 1200 seconds (20 minutes) in the past.
jtiA random ID. Each token is accepted once.
sdkWhich 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:

IntegrationWho collects the cardUse it when
Hosted or secure card fieldsPay.com iframes on your pageYou want the card never to exist on your page.
checkout.cse()Your own card formYou need your own card inputs on the web, and still want only an encrypted token to leave the page.
PayCSE.create()Your own card formYou encrypt in the browser and send the token to your server, which calls the API.
Mobile SDKsSDK-owned fields or your ownYour iOS or Android app pays, or forwards tokens to your server.
Server APIAny of the aboveYour 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.
Was this page helpful?