> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paybridgenp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox Testing

> Test the full payment flow without real credentials or real money.

Sandbox mode lets you simulate complete payment flows - checkout, provider redirect, callback, webhook - without a real merchant account and without charging anyone.

## How sandbox works

When you use a `sk_test_` API key, PayBridgeNP automatically uses built-in test credentials for each provider. You don't need to configure anything in the Providers section.

API keys in sandbox mode start with `sk_test_`.

## Built-in test credentials

PayBridgeNP manages sandbox provider credentials platform-side, so you don't enter merchant keys for eSewa or Khalti when using `sk_test_`. Fonepay is different: it has no test environment, so sandbox-mode Fonepay uses your own real Fonepay merchant credentials and moves real money. PayBridgeNP caps it at NPR 1,000 per payment and NPR 5,000 per month to keep test costs small - test with tiny amounts like NPR 10.

The **buyer-side** test logins you'll need to complete a sandbox payment are listed under each provider below.

## Running a test payment

<Steps>
  <Step title="Use your sandbox API key">
    In the [dashboard](https://dashboard.paybridgenp.com), go to **Settings → API Keys** and copy a key that starts with `sk_test_`. Use this key in your server. Sandbox mode is determined by the key, not a project toggle.
  </Step>

  <Step title="Create a test checkout session">
    ```typescript theme={null}
    const session = await paybridgenp.checkout.create({
      amount: 1000,  // NPR 10.00
      returnUrl: "https://yoursite.com/success",
    });

    // Open session.checkout_url in your browser
    ```
  </Step>

  <Step title="Pay with eSewa test account">
    On the checkout page, select **eSewa**. You'll be redirected to eSewa's sandbox (`rc-epay.esewa.com.np`).

    Use these test credentials:

    * **eSewa ID:** `9806800001` through `9806800005`
    * **Password:** `Nepal@123`
    * **MPIN:** `1122`
    * **Token/OTP:** `123456`
  </Step>

  <Step title="Pay with Khalti test account">
    On the checkout page, select **Khalti**. You'll be redirected to Khalti's sandbox (`dev.khalti.com`).

    Use these test credentials:

    * **Khalti ID:** `9800000001` through `9800000005`
    * **MPIN:** `1111`
    * **OTP:** `987654`
  </Step>

  <Step title="Pay with Fonepay (real money, capped)">
    On the checkout page, select **Fonepay**. A Dynamic QR code is displayed - it refreshes every 3 minutes until paid or the session expires.

    Scan the QR with any Nepali bank app, exactly as a live buyer would. The payment is confirmed in real time via WebSocket - no page refresh needed.

    <Warning>
      Fonepay has no test environment. Sandbox-mode Fonepay runs against the real Fonepay network with your own merchant credentials (configured in your project's Providers settings), and the money moves for real. PayBridgeNP caps sandbox Fonepay at NPR 1,000 per payment and NPR 5,000 per month - keep test amounts tiny (NPR 10 works fine).
    </Warning>
  </Step>

  <Step title="Check the result">
    After payment, you're redirected back to your `returnUrl`. Check the **Payments** tab in the [dashboard](https://dashboard.paybridgenp.com) - the payment should appear with status **Succeeded**.

    If you have a webhook configured, check **Webhooks → Delivery Log** to confirm the event was delivered.
  </Step>
</Steps>

## Going live

When you're ready to accept real payments:

1. Go to **Settings → API Keys** in the [dashboard](https://dashboard.paybridgenp.com)
2. Copy your live key (starts with `sk_live_`)
3. Go to **Providers** and add your real eSewa, Khalti, and Fonepay credentials (see [Provider Setup](/guides/provider-setup))
4. Update your server to use the `sk_live_` key

That's it. Swapping the key from `sk_test_` to `sk_live_` switches all API calls to live mode. No project toggle required.

<Warning>
  Live keys process real payments. Make sure your provider credentials are from the production environment - not eSewa's RC environment or Khalti's dev environment.
</Warning>

## Sandbox limitations

* Sandbox payments do not appear in your eSewa or Khalti merchant dashboard - they're simulated end-to-end within PayBridgeNP
* Fonepay has no test environment - sandbox Fonepay uses your real merchant credentials and moves real money (capped at NPR 1,000 per payment, NPR 5,000 per month). Payments appear in your real Fonepay merchant panel
* Webhook delivery works normally in sandbox - your webhook URL must be publicly reachable. Use [ngrok](https://ngrok.com) or [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) for local testing
