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" });client.sandbox.simulate_payment(paid["id"], action="pay")$nowgate->sandbox->simulatePayment($paid['id'], ['action' => 'pay']);action | What happens |
|---|---|
pay | a deposit of exactly what is due |
underpay | a deposit short by amount, or by half: partially_paid |
overpay | a deposit over by amount, or by half: finished and overpaid |
repeat | another deposit after the payment finished |
wrong_asset | another asset of the network to the payment's address, which goes to review |
late | the payment expires now, then what was due arrives: late |
expire | the 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;
});def finished() -> Optional[Payment]:
current = client.payments.retrieve(paid["id"])
check(current["status"] not in ("expired", "failed"), current["status"])
return current if current["status"] == "finished" else None
payment = until("the payment to finish", finished)$payment = until('the payment to finish', static function () use ($nowgate, $paid): ?array {
$current = $nowgate->payments->retrieve($paid['id']);
check(!in_array($current['status'], ['expired', 'failed'], true), $current['status']);
return $current['status'] === 'finished' ? $current : null;
});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",
});destination = payouts.payout_destinations.create(network="tron", address=PAYOUT_ADDRESS, label="Treasury")
payouts.sandbox.activate_payout_destination(destination["id"]) # the sandbox skips the wait
payout = payouts.payouts.create(destination=destination["id"], network="tron", asset="USDT", amount="5")$destination = $payouts->payoutDestinations->create(['network' => 'tron', 'address' => PAYOUT_ADDRESS, 'label' => 'Treasury']);
$payouts->sandbox->activatePayoutDestination($destination['id']); // the sandbox skips the wait
$payout = $payouts->payouts->create(['destination' => $destination['id'], 'network' => 'tron', 'asset' => 'USDT', 'amount' => '5']);