Marqeta.Simulations (marqeta v1.0.0)

Copy Markdown View Source

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

atm_withdrawal(params, opts \\ [])

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

Simulates an ATM withdrawal (auth_plus_capture).

authorization(params, opts \\ [])

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

Simulates a card authorization.

balance_inquiry(params, opts \\ [])

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

Simulates a balance inquiry.

card_direct_deposit(params, opts \\ [])

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

Simulations 2.0 — direct deposit.

card_transaction(params, opts \\ [])

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

Simulations 2.0 — card transaction (supports more transaction types).

clearing(params, opts \\ [])

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

Simulates clearing (capture/settlement) for an existing authorization.

direct_deposit(params, opts \\ [])

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

Simulates a direct deposit (ACH inbound) transaction.

pin_debit(params, opts \\ [])

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

Simulates a PIN debit transaction.

purchase(params, opts \\ [])

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

Simulates a full purchase: authorization + clearing in one step.

refund(params, opts \\ [])

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

Simulates a refund (credit) on a card.

reversal(params, opts \\ [])

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

Simulates a reversal (void) of an authorization.