Setting a PIN

This page describes the process for setting a PIN

Background

A personal identification number (PIN) is an anti-fraud measure that helps authenticate the cardholder at physical points of sale and ATMs. Spidr recommends routing customers to set a PIN at the time they activate their card. The PIN can also be updated at any time via the Get PIN Change Token and Change PIN endpoints.

You can set a PIN for a Physical-Only and Digital-First cards (see Card Types) or for a Virtual-Only card that is provisioned to a mobile wallet, in the event that the wallet is presented at a physical NFC device that accepts PINs. Please do not set PINs for Virtual-Only cards that are not in mobile wallets.

Overview

Spidr provides a secure direct-render PIN set method that allows the cardholder to enter their PIN via a processor-hosted form. This method does not require PCI compliance on behalf of the program and ensures that data is securely exchanged directly with the underlying processor.

PIN-Set Configuration Items

  • Spidr will provide you with a base URL where your program's PIN set form resides. This URL can also be found within the Spidr Dev Portal. For mobile apps, you will embed this form in a WebView. For web apps, you will open it in a popup window or new tab.

Mobile Apps (WebView)

The WebView approach uses native JavaScript interfaces to receive status codes directly from the processor-hosted PIN form.

WebView Setup

  • Add an interface/handler to the WebView to receive the success/failure codes outlined below in Status Code Values.
  • For Android, generate and register to the WebView a JavaScriptInterface with the name Android and the method postMessage (int statusCode).
  • For iOS, generate and register to the WebView a ScriptMessageHandler with the name IOS.

Staging the PIN

📘

PIN Change Token Validity

The PIN change token is valid for 5 minutes and for 5 attempts. After 5 minutes have elapsed or if 5 attempts are unsuccessful, a new key must be generated.

  • Using the base URL configured for your program, you will append the token to the URL for your PIN-set call.
  • After the user enters and confirms their PIN, you will receive the status code via your interface/handler. See Status Code Values for codes.
  • Depending on the code received, redirect your user to an error/success screen.

Committing the PIN

If a status code of 0 is received from the PIN-set form call, you can proceed with the final step, committing the PIN. Call the Commit PIN Change endpoint to finalize the PIN change. Your user now has a new PIN! 🎉

Web Applications

Web apps cannot use the native WebView JavaScript interfaces (JavaScriptInterface on Android, ScriptMessageHandler on iOS) to receive status codes from the processor-hosted PIN form. Instead, use webhooks to determine when the PIN has been staged and is ready to commit.

Webhook-Based Flow

  1. Get a token — Call Get PIN Change Token from your backend.
  2. Load the PIN form — Open the processor-hosted PIN set URL in a popup window or new tab, appending the token to the base URL configured for your program.
  3. Listen for webhooks — Listen for the account.pinChangeStageSuccess webhook. This fires when the processor confirms that the user successfully entered their PIN via the form. Also listen to account.pinChangeStageFail to handle failures (e.g., mismatched PINs, expired token).
  4. Commit the PIN — Upon receiving account.pinChangeStageSuccess, call Commit PIN Change from your backend to finalize the PIN change.

Status Code Values

Consult this table to see an explanation of the status codes returned for the PIN-set form call and which next steps to take, if any. These codes are delivered via the WebView interface/handler (mobile) or indicated by the account.pinChangeStageSuccess / account.pinChangeStageFail webhooks (web).

Status CodeDescriptionNext Steps
0SuccessContinue the procedure. You may commit the PIN
-1Bad submitter ID or no redirect URL providedRetry with valid submitter ID or provide redirect URL
-10Invalid token. Token is either expired or not found.Verify that the token is correct or call the Get Card PIN Change Key endpoint again.
-11Cardholder submitted a form with a token that is no longer valid, because Get Card PIN Change Key was called again, invalidating the previous key.Verify that the form is using the correct key before calling Get Card PIN Change Key again.
-999System errorContact Spidr for troubleshooting
-9999Unknown errorContact Spidr for troubleshooting

PIN-Related Webhooks

The following webhooks are relevant to the PIN-setting flow. See the Spidr Webhook Documentation for full payload examples.

Processor-Originated Webhooks

These are sent asynchronously by the processor during or after the PIN-setting process.

WebhookDescriptionWhen It Fires
account.pinChangeStageSuccessPIN change was successfully staged with the processor.User submits a valid PIN via the processor's PIN form.
account.pinChangeStageFailPIN change staging failed at the processor.User's PIN entry fails (e.g., mismatched PINs, expired token, inactive account).
account.pinChangeAsync confirmation that the PIN change was finalized by the processor.Processor confirms PIN change in their system after commit.

API-Originated Webhooks

These are sent when the corresponding Spidr API endpoint is called successfully.

WebhookDescriptionTrigger Endpoint
card.pinTokenA PIN change token was generated.GET /v1/card/{cardId}/pinChangeToken
card.pinChangedThe PIN change was committed.POST /v1/card/{cardId}/commitPinChange
card.resetPinThe PIN fail count was reset.POST /v1/card/{cardId}/resetPinFailCount
📘

card.pinChanged vs account.pinChange

card.pinChanged fires immediately when your backend calls /commitPinChange. account.pinChange is an asynchronous confirmation from the processor that the PIN was actually updated in their system. Both should be received for a successful PIN change.

Related Endpoints

EndpointMethodDescription
Get PIN Change TokenGET /v1/card/{cardId}/pinChangeTokenGenerate a token to initiate a PIN set or change.
Change PINPOST /v1/card/{cardId}/commitPinChangeCommit a staged PIN change.
Reset Card PIN Fail CountPOST /v1/card/{cardId}/resetPinFailCountReset the PIN fail counter after multiple failed PIN attempts.
Get Card InfoGET /v1/card/{cardId}Retrieve card details including pinFailCount and pinFailDate.
Get Account and CardsGET /v1/account/{accountId}/andCardsRetrieve account info with all associated cards, including PIN fail data.