Simulate card transactions in the sandbox environment.
Sandbox only — these endpoints are not available in production.
Examples
# Simulate an authorization
{:ok, auth} = Marqeta.Simulations.authorization(%{
card_token: "card_01",
amount: 42.50,
mid: "merchant_01",
card_acceptor: %{
name: "Coffee Shop",
mcc: "5812",
city: "San Francisco",
state: "CA",
country: "USA"
}
})
# Settle it
{:ok, _} = Marqeta.Simulations.clearing(%{
original_transaction_token: auth["token"],
amount: 42.50
})
# Or do it in one step
{:ok, txn} = Marqeta.Simulations.purchase(%{
card_token: "card_01",
amount: 100.00
})
# Simulate a refund
{:ok, _} = Marqeta.Simulations.refund(%{
card_token: "card_01",
amount: 15.00,
mid: "merchant_01"
})
# ATM withdrawal
{:ok, _} = Marqeta.Simulations.atm_withdrawal(%{
card_token: "card_01",
amount: 200.00
})
# Simulations 2.0 (card transactions)
{:ok, _} = Marqeta.Simulations.card_transaction(%{
card_token: "card_01",
amount: 50.00,
type: "AUTHORIZATION"
})
Summary
Functions
Simulates an ATM withdrawal (auth_plus_capture).
Simulates a card authorization.
Simulates a balance inquiry.
Simulations 2.0 — direct deposit.
Simulations 2.0 — card transaction (supports more transaction types).
Simulates clearing (capture/settlement) for an existing authorization.
Simulates a direct deposit (ACH inbound) transaction.
Simulates a PIN debit transaction.
Simulates a full purchase: authorization + clearing in one step.
Simulates a refund (credit) on a card.
Simulates a reversal (void) of an authorization.
Functions
@spec atm_withdrawal( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates an ATM withdrawal (auth_plus_capture).
@spec authorization( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a card authorization.
@spec balance_inquiry( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a balance inquiry.
@spec card_direct_deposit( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulations 2.0 — direct deposit.
@spec card_transaction( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulations 2.0 — card transaction (supports more transaction types).
@spec clearing( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates clearing (capture/settlement) for an existing authorization.
@spec direct_deposit( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a direct deposit (ACH inbound) transaction.
@spec pin_debit( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a PIN debit transaction.
@spec purchase( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a full purchase: authorization + clearing in one step.
@spec refund( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a refund (credit) on a card.
@spec reversal( map(), keyword() ) :: {:ok, map()} | {:error, Marqeta.Error.t()}
Simulates a reversal (void) of an authorization.