Skip to main content
The PIN management API allows users to update and retrieve the PIN for their cards.

Security best practices

  • Never store decrypted card details.
  • Only request card PIN details when absolutely necessary.
  • Always use the latest encryption libraries to maintain security.
This guide outlines the process of setting, encrypting, and retrieving a card’s PIN securely.

Requirements

  • User’s cardId that you are setting the PIN for.

Steps to set a card’s PIN

To securely update a card’s PIN, follow these steps:
1

User initiates a PIN update

Collect PIN from your user.
2

Ensure PIN meets security standards

  • No simple sequences (e.g., 1234, 0000).
  • No repeated numbers (e.g., 1111, 2222).
  • Length must be between 4–12 digits.
3

Encrypt the PIN

Encrypt the PIN using the client session key before submitting it. (See sample below)
4

Submit the encrypted PIN to the API

Send a request to set a PIN for a card. If the encrypted PIN is valid, the system updates the card’s PIN.
5

Confirm the update

The API returns a success status with no body once the PIN is set.
6

(Optional) Retrieve the PIN

If the user needs to verify the updated PIN, call the get a card’s PIN endpoint.

Encrypting and decrypting a PIN (TypeScript example)

Below is an example of how to encrypt a PIN before submission and decrypt it when retrieving it.

Requirement: Generate a session Key and ID

Set the pem variable to Rain’s public RSA key for your environment.
generateSessionId.js

Step 2: Encrypt the PIN before submission

encryptPin.js

Decrypting the PIN when retrieved

decryptPin.js