Nombaone.Sandbox (Nomba One v0.1.0)

View Source

Sandbox only. Simulation instruments that make billing outcomes happen on demand — no cron waits, no real cards. These endpoints exist only on the sandbox deployment; calling them with a live key raises ArgumentError locally, before any network request.

Summary

Functions

Sandbox only. The test clock: run the subscription's next billing cycle right now, through the real engine — invoice, charge, ledger, webhooks and all.

Sandbox only. Mint a ready, chargeable test payment method whose :behavior decides every future charge outcome deterministically (success, decline_insufficient_funds, decline_expired_card, decline_do_not_honor, requires_otp). :kind is card (default) or mandate.

Sandbox only. Emit a real, signed catalog event to your registered endpoints — the genuine pipeline (real secret, real signature, real retries), not a mock. :type is any catalog event type; :payload shapes the delivery's data.

Functions

advance_cycle(client, subscription_id, opts \\ [])

@spec advance_cycle(Nombaone.Client.t(), String.t(), keyword()) ::
  {:ok, Nombaone.AdvanceCycleResult.t()} | {:error, Nombaone.Error.t()}

Sandbox only. The test clock: run the subscription's next billing cycle right now, through the real engine — invoice, charge, ledger, webhooks and all.

Example

{:ok, result} = Nombaone.Sandbox.advance_cycle(client, subscription.id)
result.outcome            # => "paid"
result.invoice.total_in_kobo

advance_cycle!(client, subscription_id, opts \\ [])

Raising variant of advance_cycle/3.

create_payment_method(client, params, opts \\ [])

@spec create_payment_method(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.PaymentMethod.t()} | {:error, Nombaone.Error.t()}

Sandbox only. Mint a ready, chargeable test payment method whose :behavior decides every future charge outcome deterministically (success, decline_insufficient_funds, decline_expired_card, decline_do_not_honor, requires_otp). :kind is card (default) or mandate.

Example

{:ok, method} =
  Nombaone.Sandbox.create_payment_method(client, %{
    customer_id: customer.id,
    behavior: "decline_insufficient_funds"
  })

create_payment_method!(client, params, opts \\ [])

@spec create_payment_method!(Nombaone.Client.t(), map(), keyword()) ::
  Nombaone.PaymentMethod.t()

Raising variant of create_payment_method/3.

simulate_webhook(client, params, opts \\ [])

@spec simulate_webhook(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.WebhookSimulation.t()} | {:error, Nombaone.Error.t()}

Sandbox only. Emit a real, signed catalog event to your registered endpoints — the genuine pipeline (real secret, real signature, real retries), not a mock. :type is any catalog event type; :payload shapes the delivery's data.

Example

{:ok, _} =
  Nombaone.Sandbox.simulate_webhook(client, %{
    type: "invoice.payment_failed",
    payload: %{reference: invoice.id, reason: "insufficient_funds"}
  })

simulate_webhook!(client, params, opts \\ [])

@spec simulate_webhook!(Nombaone.Client.t(), map(), keyword()) ::
  Nombaone.WebhookSimulation.t()

Raising variant of simulate_webhook/3.