NowgateDocs

Sandbox

The sandbox behaves as live does, without real money, and lets you play the payer, fail a payout or skip a destination's wait.

On this page

The sandbox (https://sandbox-api.nowgate.io/v1, with an ngk_sandbox_… key) runs the same engine as live, with the same statuses, credits, webhooks, payouts and refunds, but no real money: simulated deposits stay in the sandbox's books and payouts are never sent. It adds controls that live doesn't have.

Play the payer#

await nowgate.sandbox.simulatePayment(paid.id, { action: "pay" });
actionWhat happens
paya deposit of exactly what is due
underpaya deposit short by amount, or by half: partially_paid
overpaya deposit over by amount, or by half: finished and overpaid
repeatanother deposit after the payment finished
wrong_assetanother asset of the network to the payment's address, which goes to review
latethe payment expires now, then what was due arrives: late
expirethe payment expires now

A simulated deposit is pending at first, as one in the mempool is, and settles about ten seconds later. From then on it is processed like any deposit:

const finished = await until("the payment to finish", async () => {
  const current = await nowgate.payments.retrieve(paid.id);
  assert.ok(!["expired", "failed"].includes(current.status), current.status);
  return current.status === "finished" ? current : undefined;
});

Payouts and refunds#

A new payout destination waits before its first payout, as in live, unless the sandbox activates it at once. Payouts and refunds then run to finished with simulated transactions, and POST /v1/sandbox/payouts/{id}/simulate can make one fail.

const destination = await payouts.payoutDestinations.create({
  network: "tron",
  address: PAYOUT_ADDRESS,
  label: "Treasury",
});
await payouts.sandbox.activatePayoutDestination(destination.id); // the sandbox skips the wait
const payout = await payouts.payouts.create({
  destination: destination.id,
  network: "tron",
  asset: "USDT",
  amount: "5",
});