Set, update, and reveal PINs for payment cards.
PIN operations use a two-step control-token flow for security. The control token is single-use and expires after a short window.
Flow
create_control_token/1— obtain a single-use control tokenset/2— set or update the PIN using the control token- Optionally
reveal/1— reveal the PIN (requires special program permissions)
Examples
{:ok, %{"control_token" => ct}} = Marqeta.PINs.create_control_token(%{
card_token: "card_01"
})
{:ok, _} = Marqeta.PINs.set(ct, "1234")
{:ok, %{"pin" => pin}} = Marqeta.PINs.reveal(ct)
Summary
Functions
Creates a single-use PIN control token for a card.
Retrieves a PIN by token.
Retrieves a PIN by token. Raises Marqeta.Error on failure.
Reveals a PIN using a control token. Requires special program permissions.
Sets or updates a card PIN. Accepts a control token and 4-digit PIN string.
Updates an existing PIN.
Updates an existing PIN. Raises Marqeta.Error on failure.
Functions
@spec create_control_token( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Creates a single-use PIN control token for a card.
@spec get( String.t(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Retrieves a PIN by token.
Returns {:ok, map()} on success, {:error, %Marqeta.Error{}} on failure.
Retrieves a PIN by token. Raises Marqeta.Error on failure.
@spec reveal( String.t(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Reveals a PIN using a control token. Requires special program permissions.
@spec set(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Sets or updates a card PIN. Accepts a control token and 4-digit PIN string.
@spec update(String.t(), map(), keyword()) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Updates an existing PIN.
Returns {:ok, map()} on success, {:error, %Marqeta.Error{}} on failure.
Updates an existing PIN. Raises Marqeta.Error on failure.