TreasuryPrime.Testing.Simulation (TreasuryPrime v1.0.0)

Copy Markdown View Source

Drives Treasury Prime's sandbox-only simulation endpoint, which lets you force state transitions and synthetic events that would otherwise require waiting on a real bank/network partner — e.g. moving an ACH straight to "settled", simulating a card authorization request, triggering a FedNow receipt, or completing a Green Dot cash load.

Calling any of these against a :production client will simply fail (the endpoint doesn't exist outside sandbox) — there's no special guard here, Treasury Prime itself enforces this.

Generic usage

{:ok, result} =
  TreasuryPrime.Testing.Simulation.create(client, "card_event.auth_request", %{
    amount: "25.10",
    card_id: "card_104",
    merchant: %{
      name: "KROGER #10626",
      mcc: "5411",
      mid: "4445025949032",
      address: %{city: "LAS VEGAS", state: "NV", postal_code: "88901", country: "USA"}
    }
  })

See Treasury Prime's per-resource simulation guides (ACH, Card, Check Deposit, Check Issuing, Digital Wallet Token, FedNow, Green Dot, Statement, Wire) for the exhaustive, current list of type values and the simulation fields each one accepts — they evolve over time and are documented per-resource rather than in one combined schema.

A handful of the most common ones are wrapped below for convenience.

Summary

Functions

Forces an ACH transfer through a status transition (e.g. "settled", "returned").

Simulates an incoming card authorization request against card_id, as if it came from the card network in real time — useful for testing TreasuryPrime.CardAuthLoopEndpoint integrations or card control logic without a real card present.

Forces a check deposit through a status transition (e.g. "accepted", "rejected").

Creates a simulation event of the given type, with simulation as the type-specific input payload. This is the fully general escape hatch — prefer the convenience functions below when one fits your case.

Simulates an incoming FedNow payment to account_id.

Completes a pending Green Dot cash load as if the customer paid at the register.

Forces a wire transfer through a status transition.

Functions

ach_status(client, ach_id, status)

@spec ach_status(TreasuryPrime.Client.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Forces an ACH transfer through a status transition (e.g. "settled", "returned").

card_auth_request(client, card_id, attrs \\ %{})

@spec card_auth_request(TreasuryPrime.Client.t(), String.t(), map()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Simulates an incoming card authorization request against card_id, as if it came from the card network in real time — useful for testing TreasuryPrime.CardAuthLoopEndpoint integrations or card control logic without a real card present.

check_deposit_status(client, check_deposit_id, status)

@spec check_deposit_status(TreasuryPrime.Client.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Forces a check deposit through a status transition (e.g. "accepted", "rejected").

create(client, type, simulation)

@spec create(TreasuryPrime.Client.t(), String.t(), map()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Creates a simulation event of the given type, with simulation as the type-specific input payload. This is the fully general escape hatch — prefer the convenience functions below when one fits your case.

fednow_receive(client, account_id, amount)

@spec fednow_receive(TreasuryPrime.Client.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Simulates an incoming FedNow payment to account_id.

greendot_complete(client, greendot_id)

@spec greendot_complete(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Completes a pending Green Dot cash load as if the customer paid at the register.

wire_status(client, wire_id, status)

@spec wire_status(TreasuryPrime.Client.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, TreasuryPrime.Error.t()}

Forces a wire transfer through a status transition.