Sandbox-only helpers for testing without a frontend: mint a public
token for a test institution, fire webhooks on demand, and force an
Item into ITEM_LOGIN_REQUIRED. Each call errs locally unless its
environment (environment in opts, else plaid.env) is "sandbox". Sandbox test credentials are user_good
/ pass_good; ins_109508 is First Platypus Bank.
Functions
create-public-token
fn (institution-id: Str, initial-products: Vec<Str>): Map
fn (institution-id: Str, initial-products: Vec<Str>, options: Map?): Map
fn (institution-id: Str, initial-products: Vec<Str>, options: Map?, opts: Map): Map
POST /sandbox/public_token/create: a public token for a sandbox Item
at institution-id with initial-products, skipping Link. Exchange
it with ::plaid::link/exchange-public-token. Options (Plaid's
options object): webhook, override_username,
override_password, transactions: {start_date, end_date, days_requested}.
Example
pt ::plaid::sandbox/create-public-token("ins_109508", ["transactions"], {webhook: "https://example.com/plaid/webhook"})
tokens ::plaid::link/exchange-public-token(pt.public_token)
fire-webhook
fn (access-token: Str, webhook-code: Str): Map
fn (access-token: Str, webhook-code: Str, options: Map): Map
fn (access-token: Str, webhook-code: Str, options: Map, opts: Map): Map
POST /sandbox/item/fire_webhook: make Plaid send a webhook for the
Item to its configured URL. webhook-code is e.g.
"SYNC_UPDATES_AVAILABLE", "DEFAULT_UPDATE",
"NEW_ACCOUNTS_AVAILABLE", "LOGIN_REPAIRED",
"PENDING_DISCONNECT", "USER_PERMISSION_REVOKED". Options:
webhook_type (e.g. "TRANSACTIONS", "ITEM"; Plaid infers it
when omitted), new_transactions (how many to generate for
SYNC_UPDATES_AVAILABLE). Returns {webhook_fired}.
Example
access-token ::hot::ctx/get("plaid.access-token")
out ::plaid::sandbox/fire-webhook(access-token, "SYNC_UPDATES_AVAILABLE", {new_transactions: 5})
out.webhook_fired
reset-login
fn (access-token: Str): Map
fn (access-token: Str, opts: Map): Map
POST /sandbox/item/reset_login: put a sandbox Item into
ITEM_LOGIN_REQUIRED to test Link update mode. Returns {reset_login: true}.
Example
access-token ::hot::ctx/get("plaid.access-token")
::plaid::sandbox/reset-login(access-token)