Debit card issuance and lifecycle management (virtual and physical), powered by Treasury Prime's card processor partnership (Marqeta).
Issuing a card
{:ok, card} =
TreasuryPrime.Card.create(client, %{
account_id: "acct_1234567890",
person_id: "psn_1234567890",
card_product_id: "cprod_...",
type: "virtual",
name_on_card: "GEORGE WASHINGTON"
})Lifecycle actions
Use update/3 for general field changes, or the convenience wrappers
activate/2, suspend/2, terminate/2 for the common status
transitions. reissue/3 issues a brand new card (new PAN/CVV/expiration)
to replace a lost/stolen/damaged one; pass same_pan: true in opts to
instead keep the same PAN/PIN with a new CVV and expiration (e.g. for an
expiring card).
Revealing PAN / CVV (PCI scope)
pan and cvv are nil on every response by default. Pass
show_pan: true / show_cvv: true as query params to get/3 or
list/2 to have Treasury Prime include them — doing so puts that data
in your own systems and brings PCI DSS obligations with it, so most
integrations instead use TreasuryPrime.Marqeta.JS or
TreasuryPrime.Marqeta.UXToolkit to display sensitive card data
directly to the cardholder via a PCI-compliant widget, without it ever
touching your servers.
Summary
Functions
Activates a card (typically once the cardholder confirms receipt of a physical card).
Issues a card. Required: account_id, person_id, card_product_id,
type ("virtual" | "physical").
Fetches a single card by id. Pass %{show_pan: true} and/or
%{show_cvv: true} as params to include those normally-nil fields
(see "Revealing PAN / CVV" above).
Lists cards.
Reissues a card — issues a fresh card to replace this one. Pass
same_pan: true in opts to keep the same PAN/PIN with only a new
CVV/expiration (e.g. for card expiry); omit it to issue an entirely new
PAN (e.g. for lost/stolen).
Suspends a card (temporary — can be reactivated).
Terminates a card permanently.
Updates a card (e.g. status, card_controls, name_on_card).
Types
@type t() :: %TreasuryPrime.Card{ account_id: String.t() | nil, bin: String.t() | nil, card_auth_loop_endpoint_id: String.t() | nil, card_controls: map() | nil, card_product_id: String.t() | nil, created_at: String.t() | nil, cvv: String.t() | nil, expiration: String.t() | nil, fulfillment: map() | nil, id: String.t() | nil, last_4: String.t() | nil, name_on_card: String.t() | nil, pan: String.t() | nil, person_id: String.t() | nil, pin_set: boolean() | nil, reissue_pan_from_card_id: String.t() | nil, status: String.t() | nil, type: String.t() | nil, updated_at: String.t() | nil, userdata: map() | nil }
Functions
@spec activate(TreasuryPrime.Client.t(), String.t()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Activates a card (typically once the cardholder confirms receipt of a physical card).
@spec create(TreasuryPrime.Client.t(), map(), keyword()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Issues a card. Required: account_id, person_id, card_product_id,
type ("virtual" | "physical").
@spec create!(TreasuryPrime.Client.t(), map(), keyword()) :: t()
@spec get(TreasuryPrime.Client.t(), String.t(), map()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Fetches a single card by id. Pass %{show_pan: true} and/or
%{show_cvv: true} as params to include those normally-nil fields
(see "Revealing PAN / CVV" above).
@spec get!(TreasuryPrime.Client.t(), String.t(), map()) :: t()
@spec list(TreasuryPrime.Client.t(), map()) :: {:ok, TreasuryPrime.Page.t()} | {:error, TreasuryPrime.Error.t()}
Lists cards.
Filterable params
account_id, person_id, last_4, status, type. Pass show_pan: true / show_cvv: true to include those fields (see "Revealing PAN /
CVV" above).
@spec list!(TreasuryPrime.Client.t(), map()) :: TreasuryPrime.Page.t()
@spec reissue(TreasuryPrime.Client.t(), String.t(), keyword()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Reissues a card — issues a fresh card to replace this one. Pass
same_pan: true in opts to keep the same PAN/PIN with only a new
CVV/expiration (e.g. for card expiry); omit it to issue an entirely new
PAN (e.g. for lost/stolen).
@spec suspend(TreasuryPrime.Client.t(), String.t()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Suspends a card (temporary — can be reactivated).
@spec terminate(TreasuryPrime.Client.t(), String.t()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Terminates a card permanently.
@spec update(TreasuryPrime.Client.t(), String.t(), map()) :: {:ok, t()} | {:error, TreasuryPrime.Error.t()}
Updates a card (e.g. status, card_controls, name_on_card).
@spec update!(TreasuryPrime.Client.t(), String.t(), map()) :: t()