Test mode

Draft. Written from the repository's documents and code; not yet reviewed by the owner.

Every app has two environments: a sandbox, where nothing is real, and live. You integrate against the sandbox, then switch the key and the address of the code to live.

What the sandbox is

Choosing how a payment goes

Give a sandbox customer a payment method from GET /v1/sandbox/scenarios, or set it with POST /v1/sandbox/customers/{external_id}/payment-scenario (for example {"scenario": "declined"}). Each pm_sandbox_* method makes the payment take one path, so you can see how your app behaves when a charge succeeds, is declined, is declined once and then succeeds, fails with an error and then succeeds, or times out whether or not it went through.

Getting an invoice now

  1. Create a customer, subscribe it to a package, and send some usage.
  2. POST /v1/sandbox/close-period closes the period right away and runs the real billing flow: cutoff, rating, numbering and the payment saga with the simulator. It answers 202; poll GET /v1/invoices until the invoice is there.
  3. To run a payment again under another scenario, POST /v1/sandbox/invoices/{id}/simulate. It sets the customer's scenario and retries the invoice's payment.

Webhooks are sent from the sandbox too, so you can test your receiver end to end; Send a test webhook on the console's Connect your app page sends a signed ping to an endpoint (see Webhooks).

What only live does

The console can promote the sandbox configuration to live so you do not rebuild it by hand: meters, plans and their prices, tax rates, coupons, mail settings and webhook endpoints (never customers, usage, invoices or payments). It only adds, matches objects by their code, so running it again does nothing, and a dry run shows the difference first. Test the same flow once more in live with a small real payment before you send customers there.