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

# Testing

> Test your Kyren Pay integration before going live

Use this page to test your integration without making assumptions about unsupported environments.

## Current environment model

| Item                      | Current behavior                                               |
| ------------------------- | -------------------------------------------------------------- |
| Production API            | `https://api.kyren.top`                                        |
| Production API key prefix | `kyren_live_`                                                  |
| Self-service test keys    | Not currently exposed in the merchant dashboard                |
| Staging access            | Available only with a base URL and credentials issued by Kyren |

<Warning>
  Do not send test traffic to an arbitrary staging URL unless Kyren has issued credentials for that environment.
</Warning>

## Test API Keys

Use an API key issued for the target environment:

```bash theme={null}
curl https://api.kyren.top/v1/products \
  -H "x-api-key: kyren_live_xxxxxxxxxxxxxxxxxxxx"
```

## Test Card Numbers

Use these card numbers only when Kyren has issued a staging or test-capable environment, or when Kyren has enabled a test-capable payment gateway for your merchant. Do not assume these card numbers produce deterministic outcomes on production checkout sessions.

| Card Number           | Behavior           |
| --------------------- | ------------------ |
| `4242 4242 4242 4242` | Payment succeeds   |
| `4000 0000 0000 0002` | Card declined      |
| `4000 0000 0000 9995` | Insufficient funds |

For all test cards:

* Use any future expiration date (e.g., `12/28`)
* Use any 3-digit CVV (e.g., `123`)
* Use any cardholder name
* Use any billing address

## Test WeChat Pay / Alipay

QR payment behavior depends on the gateway configuration attached to your merchant. Use Kyren-provided credentials for the target environment or coordinate a callback simulation when validating asynchronous status updates.

## Testing Webhooks

When testing webhooks locally, you can use a tunneling tool like [ngrok](https://ngrok.com) to expose your local server:

```bash theme={null}
# Start your local webhook handler
node server.js  # listening on port 3000

# In another terminal, create a tunnel
ngrok http 3000
```

Then configure the ngrok URL as your webhook endpoint in the Dashboard:

```
https://abc123.ngrok.io/webhooks/kyren
```

<Tip>
  Remember to update your webhook URL to your production endpoint before going live.
</Tip>

## Going Live Checklist

Before switching to production, make sure you have:

<Steps>
  <Step title="Replace API keys">
    Use the production key issued for `api.kyren.top`
  </Step>

  <Step title="Update base URL">
    If Kyren issued a staging base URL, change from that URL to `api.kyren.top`
  </Step>

  <Step title="Update webhook URL">
    Set your production webhook endpoint in the Dashboard
  </Step>

  <Step title="Verify webhook signatures">
    Ensure your server correctly verifies `X-Kyren-Signature` headers
  </Step>

  <Step title="Handle errors gracefully">
    Test error scenarios and ensure your app handles them properly
  </Step>
</Steps>
