Marqeta.PINs (marqeta v1.0.0)

Copy Markdown View Source

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

  1. create_control_token/1 — obtain a single-use control token
  2. set/2 — set or update the PIN using the control token
  3. 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

create_control_token(params, opts \\ [])

@spec create_control_token(
  map(),
  keyword()
) :: {:ok, map()} | {:error, Marqeta.Error.t()}

Creates a single-use PIN control token for a card.

get(token, opts \\ [])

@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.

get!(token, opts \\ [])

@spec get!(
  String.t(),
  keyword()
) :: map()

Retrieves a PIN by token. Raises Marqeta.Error on failure.

reveal(control_token, opts \\ [])

@spec reveal(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Marqeta.Error.t()}

Reveals a PIN using a control token. Requires special program permissions.

set(control_token, pin, opts \\ [])

@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.

update(token, params, opts \\ [])

@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.

update!(token, params, opts \\ [])

@spec update!(String.t(), map(), keyword()) :: map()

Updates an existing PIN. Raises Marqeta.Error on failure.