Marqeta.Sandbox (marqeta v1.0.0)

Copy Markdown View Source

Sandbox bootstrapping helpers for development and testing.

bootstrap/2 creates a complete, ready-to-use sandbox setup: a user + card product + active virtual card + funded GPA.

Examples

{:ok, setup} = Marqeta.Sandbox.bootstrap(%{
  first_name: "Alice",
  last_name: "Smith"
}, funding_source_token: "program_fs_01", amount: 500.00)

# setup.user, setup.card_product, setup.card, setup.gpa_order
{:ok, auth} = Marqeta.Simulations.authorization(%{
  card_token: setup.card["token"],
  amount: 25.00,
  mid: "merchant_01"
})

Summary

Functions

Bootstraps a complete sandbox setup.

Runs a full purchase simulation on a bootstrapped setup.

Types

bootstrap_result()

@type bootstrap_result() :: %{
  user: map(),
  card_product: map(),
  card: map(),
  gpa_order: map()
}

Functions

bootstrap(user_params \\ %{}, opts \\ [])

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

Bootstraps a complete sandbox setup.

Required Options

  • :funding_source_token — your program funding source token

Optional Options

  • :amount — initial GPA load amount (default: 100.00)
  • :currency — currency code (default: "USD")
  • :card_product_config — override card product config

Returns

{:ok, %{user, card_product, card, gpa_order}} or {:error, %Marqeta.Error{}}.

simulate_purchase(card_token, amount, merchant \\ %{})

@spec simulate_purchase(String.t(), number(), map()) ::
  {:ok, %{authorization: map(), clearing: map()}} | {:error, Marqeta.Error.t()}

Runs a full purchase simulation on a bootstrapped setup.

Returns

{:ok, %{authorization, clearing}} or {:error, error}.