PIN management
Let your cardholders manage their personal identification numbers.
Some Point-of-Sale and ATM card terminals require cardholders to enter their cardâs PIN to authenticate transactions. Cardholders also need to use their PINs with physical cards in many regions of the world. You can use the Stripe API and Stripe Elements to manage and view PINs on your issued cards.
Both physical card and virtual card PINs are set to a random value at creation. Cards created as a replacement for other cards wonât inherit the old cardâs PIN. In test mode, all PINs are set to 0000 by default.
Set a cardâs initial PIN at creation
When issuing a new card through the API, you can provide a desired PIN to be pre-set on the card. This is optional, and if you donât provide an initial PIN, we randomly generate one for you. You can always view a cardâs PIN.
To pre-set a PIN when issuing a new card, pass it in encrypted form as the pin.
parameter to the Create Card API method:
curl https://api.stripe.com/v1/issuing/cards \ -u
: \ -d "cardholder"="ich_1D4b3fdsa" \ -d "pin[encrypted_number]"="eyJhbGciOiJSU0..." -d "type"="virtual" \ -d "currency"="usd"sk_test_4eC39HqLyjWDarjtT1zdp7dc
See Encrypting PINs for more information about how to encrypt a PIN before passing it to the Stripe API or your own servers.
Note
When setting a cardâs initial PIN in a request to the Create Card API method, the response to the creation request wonât return the PIN (in either encrypted or plain-text form).
View a cardâs PIN
You can use Issuing Elements to retrieve a cardâs PIN in a PCI-DSS-compliant way.
Use Issuing Elements
Stripe provides a browser-side JavaScript library that allows you to display the sensitive data (including PINs) of your Issuing cards in a PCI-compliant manner. The PIN renders inside of a Stripe-hosted iframe
and never touches your servers. Stripe offers this library as a part of Stripe.js.
All Issuing users, whether theyâre PCI-compliant or not, can use Issuing Elements to retrieve PINs.
To retrieve a cardâs PIN using Issuing Elements, first create an Issuing Elements integration, and then use it to display the issuingCardPinDisplay
Element:
const stripe = Stripe(
); const cardId = 'ic_abc123'; // ID of the issued Card you want to retrieve the PIN for const ephemeralKeyNonce = ...; const ephemeralKey = ...; // create the PIN Element with Stripe.js const pinElement = stripe.elements().create('issuingCardPinDisplay', { issuingCard: cardId, nonce: ephemeralKeyNonce, ephemeralKeySecret: ephemeralKey.secret, }); // Mount the PIN element onto DOM elements on your web page pinElement.mount('#card-pin');"pk_test_TYooMQauvdEDq54NiTphI7jx"
Change a cardâs PIN
Change a cardâs PIN with the Cards API
You can change the PIN for an issued card using the Card Update API. However, depending on the region the card is used in, the new PIN might not be immediately usable. See Online and offline PINs for further guidance.
You can also change a cardâs PIN at an ATM (if supported by ATMs in your region). PIN changes at an ATM are instantaneous.
To change the PIN for a given card using the API, pass it in encrypted form as the pin.
parameter to the Update Card API method:
See Encrypting PINs for more information about how to encrypt a PIN before passing it to the Stripe API or your own servers.
Note
When changing a cardâs PIN in a request to the Update Card API method, the response to the update request wonât return the PIN (in either encrypted or plain-text form).
Change a cardâs PIN at an ATM
Cardholders can change the PIN for their Stripe Issuing card at most ATMs. The cardholder must know the cardâs current PIN to change it at an ATM. You can retrieve a cardâs PIN before changing it. Some countries, such as France, donât provide PIN management features at ATMs.
Note
ATMs are the recommended way to change PINs on Issuing cards because they avoid offline PIN synchronization issues that are possible when changing PINs with the Cards API. See Online and offline PINs for more details.
Unblock a cardâs PIN
If you incorrectly enter a cardâs PIN three consecutive times, the PIN becomes blocked. No further PIN-authenticated payments can be made through the card until the PIN is unblocked. Additionally, when a cardâs online PIN is blocked, the cardâs status is set to inactive
, and no payments of any kind can be made until the card is reactivated.
To unblock a cardâs online PIN, and reactivate the card, use the Cards API to set its status to active
. You can also reactivate a card in your Stripe Dashboard.
To unblock a cardâs offline PIN, change the cardâs PIN using the Cards API. Changing a cardâs PIN, even to the same value as before, unblocks the cardâs offline PIN. Alternatively, in most countries, cardholders can also unblock a cardâs offline PIN at an ATM.
Note
After unblocking a cardâs offline PIN with the Cards API, the next offline PIN transaction might still fail once. When this happens, the cardholder needs to retry the transaction. After the retry, the cardâs offline PIN is unblocked.
Encrypting PINs
To enable you to set a cardâs PIN in a way that doesnât require it to pass through your servers in plain text, the Stripe API expects you to provide PINs in an encrypted form.
Encrypt the desired PIN (for example, "0123"
) in JWE (JSON Web Encryption) format using Stripeâs RSA public key. When encrypting, use the RSA-OAEP
algorithm for key wrapping and A128CBC-HS256
for content encryption.
Stripe provides its public key for PIN encryption in both PKCS#8 and JWK format. Depending on your client environment and the library used, one might be easier to use than the other.
PIN encryption best practices
- Donât cache, store, or reuse encrypted PINs for longer than necessary to call the Stripe API.
- Donât encrypt PINs on your servers. Instead, perform encryption as soon as your user provides the PIN (for example, in your mobile application or in your web applicationâs frontend) and pass the encrypted form to your servers, and then on to the Stripe API.
- Donât cache Stripeâs Issuing public key: we can change it or rotate it without notice. Instead, fetch it for every PIN operation you perform on the Stripe API.
- Donât roll your own cryptography. JWE libraries are available for most common languages and platforms.
PIN encryption examples
The example above encrypts a PIN (0123) using JSON Object Signing and Encryption libraries for various languages. Equivalent libraries exist for other languages:
Language | Library |
---|---|
JavaScript | jose |
Python | jwcrypto |
Ruby | ruby-jose |
Go | go-jose |
Swift | JOSESwift |
Java | jose4j |
.NET | jose-jwt |
Online and offline PINs
The physical cards that Stripe issues have EMV chips. One function of an EMV chip is to store the cardâs PIN. This allows card terminals to verify an entered PIN against the card itself, without needing to verify it online, directly with the issuer. This is known as an âofflineâ PIN (or cardholder) verification.
When a cardholder is asked to enter their PIN, depending on where theyâre using it, the card terminal might use either an online or an offline verification. Some countries use online PIN verifications, and others use offline. For example, card terminals in the US and Germany generally use an online PIN verification, while those in the UK, Ireland, or France use offline PIN.
Change a PIN in regions that use offline PIN verification
Even when a card has an EMV chip, its PIN is also stored online, with the issuer (Stripe). Because a cardâs PIN is stored in two places, changing it using the Stripe API only takes effect immediately for online PIN verifications.
After changing a PIN with the Stripe API, and then using it in an offline PIN region, the cardholder must first make a successful transaction using their previous PIN. An âofflineâ card terminal only updates the offline PIN stored on the EMV chip with the new one given to the Stripe API after it successfully completes a PIN verification.
In addition to using the Stripe API, you can also allow a cardholder change a cardâs PIN at an ATMâbut only in regions where ATMs support PIN changes. When changed at an ATM, the PIN simultaneously updates on both the EMV chip and at the issuer. PIN changes at ATMs take effect immediately for both online and offline PIN verifications.
Country | PIN change behavior |
---|---|
|
|
|
|
|
|
If the country your cardholders want to use cards in isnât listed above, contact Issuing support for PIN guidance in your region.
PIN verification during authorization
If a transaction requires PIN verification, the cardholder must enter their cardâs PIN on the card terminal. If the cardholder enters their PIN incorrectly, then the transaction is declined, and no issuing_
webhook is sent.
The timing to create PIN verification authorization objects depends on whether the transaction used the cardâs online or offline PIN. The authorizationâs verification_data.pin_check attribute tells you the type of PIN verification used and the result.
Online PIN verification
Authorizations with online PIN verifications have a pin_
value of online_
or online_
. A mismatch means that the cardholder entered the wrong PIN, so Stripe declined the transaction. Every PIN verification attempt creates an Authorization object.
After three consecutive online PIN verification failures, the cardâs online PIN is blocked and the cardâs status
is set to inactive
. The cardholder canât make any further transactions, PIN-verified or otherwise, until the card becomes active again.
Authorizations declined because of a blocked online PIN have a reason
of pin_
in the request_history array.
Offline PIN verification
Authorizations with offline PIN verifications have a pin_
value of offline_
or offline_
. A mismatch means that the cardholder entered the wrong PIN, so Stripe declined the transaction.
However, because the terminal performs offline PIN verification, Stripe isnât notified of every failed PIN attempt. we only create an Authorization object after authorization either succeeds or the cardholder fails all three PIN attempts.
Three incorrect PIN attempts blocks the cardâs offline PIN. The cardholder canât attempt a PIN-verified transaction until the offline PIN is unblocked. In contrast to online PIN blocks, the cardholder can still use the card for non-PIN-verified transactions (such as e-commerce transactions) while the offline PIN is blocked.
A terminal that performs offline PIN verification wonât attempt to authorize an inserted card with a blocked offline PIN. Instead, the terminal might display a message to the cardholder stating that the cardâs PIN is blocked, suggesting that the cardholder contact their issuer.