# Testing

> Test mode end to end — test keys, test checkout, simulating payments and webhooks, and how test and live stay separate.

Test mode lets you build and demo a complete integration with **no real money**, no bKash or Nagad account, no Bridge and no Service Credit.

## What test mode is

- Use a **test secret key** (`dz_test_sk_…`). Payments it creates have `livemode: false`.
- The test checkout page shows **TEST MODE — No real money will be moved** and a clearly fake receiving number (`01XXXXXXXXX`, "Test bKash").
- Every provider and payment type works: bKash and Nagad, Send Money, Payment, Cash In and Bank / Card Add Money. `allowed_methods`, `allowed_channels` and `return_url` behave exactly as in live mode.
- Test payments never appear in your real payments list, revenue insights, receipts or Service Credit.

## Complete a test payment

Simulate the outcome — with the SDK, with HTTP, or with the buttons on the test checkout page:

**Node.js**

```js
await devzity.testHelpers.payments.succeed(payment.id)   // → PAID
await devzity.testHelpers.payments.cancel(payment.id)    // → CANCELLED
```

**curl**

```bash
#!/usr/bin/env bash
# Complete a TEST payment without any real money (Test secret keys only).
# Usage: ./simulate-payment.sh <payment-id> [succeed|cancel]
set -euo pipefail
: "${DEVZITY_SECRET_KEY:?Set DEVZITY_SECRET_KEY to your dz_test_sk_... key}"
: "${DEVZITY_API_URL:?Set DEVZITY_API_URL to the Devzity API base URL you were given}"

curl "$DEVZITY_API_URL/v1/test_helpers/payments/$1/${2:-succeed}" \
  -X POST \
  -H "Authorization: Bearer $DEVZITY_SECRET_KEY"
```

These endpoints (`POST /v1/test_helpers/payments/{id}/succeed` and `/cancel`) accept **test keys only**; a live key gets a plain `404`. They run through the normal payment lifecycle, so webhooks are emitted exactly as they would be for a real payment.

## Test webhooks

Register a **Test** endpoint (Developers → Webhooks) and it receives the events of your test payments, signed with its own secret. A Test payment is never delivered to a Live endpoint, so register a Test endpoint even if you already have a Live one. **Send test event** sends a harmless `endpoint.test` event to check your receiver. See [Webhooks](https://docs.devzity.com/v1/webhooks.md).

## Test and live are isolated

- A test key cannot retrieve, list or cancel a live payment (and vice versa) — the answer is `404`, as if it didn't exist.
- Test webhook events go only to Test endpoints, live events only to Live endpoints.
- Keys, webhook endpoints and events in the dashboard are always shown for one environment at a time.

Test payments currently do not generate downloadable receipts.

When your integration works, read [Going live](https://docs.devzity.com/v1/going-live.md).
