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

# Testing & Sandbox

> Test your integration in sandbox before going live with production payments.

PayNext provides separate sandbox and production environments. Always test your integration in sandbox before processing real payments.

## Environments

| Environment    | Dashboard                     | API                     |
| -------------- | ----------------------------- | ----------------------- |
| **Sandbox**    | sandbox-dashboard.paynext.com | sandbox-api.paynext.com |
| **Production** | dashboard.paynext.com         | api.paynext.com         |

Switch between environments using the toggle in the left sidebar of each dashboard.

<Warning>
  Processor sandbox credentials only work with PayNext sandbox. Production credentials only work with PayNext production. Mixing environments will cause authentication failures.
</Warning>

## Setup Checklist

<Steps>
  <Step title="Configure processor in sandbox">
    Add your processor's **sandbox/test credentials** in **sandbox-dashboard.paynext.com → Integrations**.
  </Step>

  <Step title="Create sandbox API keys">
    Generate API keys in **sandbox-dashboard.paynext.com → Developers → API Keys**.
  </Step>

  <Step title="Set SDK environment">
    Use `environment: 'sandbox'` when mounting the SDK:

    ```javascript theme={"system"}
    checkout.mount('paynext-checkout', {
      clientToken: session.id,
      environment: 'sandbox',  // Use 'production' for live
      // ...
    })
    ```
  </Step>

  <Step title="Test payment flows">
    Use processor-specific test cards to simulate different scenarios.
  </Step>
</Steps>

## Test Credentials

Each processor provides test credentials for their sandbox environment—cards, wallets, and alternative payment methods. See your processor's integration page in [Integrations](/integrations/overview) for sandbox setup guides and test credentials.

<Tip>
  Test both successful payments and failure scenarios (declined cards, insufficient funds, 3DS challenges) to ensure your error handling works correctly.
</Tip>

## Best Practices

### During Development

* **Use sandbox exclusively** — Never test with production credentials during development
* **Test all payment methods** — Verify each enabled payment method works correctly
* **Simulate failures** — Use test cards that trigger declines to test your error handling
* **Verify webhooks** — Confirm your webhook endpoint receives and processes events correctly

### Before Going Live

* **Complete end-to-end testing** — Test the full flow from checkout to settlement
* **Verify 3D Secure** — Test authentication flows with 3DS-enabled test cards
* **Test subscription scenarios** — Verify trials, renewals, upgrades, and cancellations
* **Check Dashboard data** — Confirm payments appear correctly in the sandbox Dashboard

### Going Live

1. Add **production credentials** for your processor in **dashboard.paynext.com**
2. Generate **production API keys** in **dashboard.paynext.com → Developers**
3. Update your backend to use `api.paynext.com`
4. Change SDK `environment` to `'production'`
5. Process a small real payment to verify the integration

<Warning>
  Double-check your environment configuration before launch. Sandbox API calls to production endpoints (or vice versa) will fail.
</Warning>

## Debugging

| Issue                  | Cause                             | Solution                                                |
| ---------------------- | --------------------------------- | ------------------------------------------------------- |
| Authentication failed  | Wrong environment credentials     | Verify API key matches environment                      |
| Processor error        | Sandbox credentials in production | Check processor credentials match PayNext environment   |
| Payments not appearing | Wrong Dashboard                   | Switch to correct environment in sidebar                |
| Webhooks not received  | Wrong endpoint                    | Verify webhook URL is configured in correct environment |
