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

# Testing

> Use the sandbox environment to develop and test your integration

# Testing

Stable Genius provides a sandbox environment for development and testing. Sandbox mode uses Base Sepolia testnet — no real money moves.

<Info>
  Sandbox access is included with all API keys during private beta. [Request early access](https://stablegenius.co/early-access) to get started.
</Info>

## Sandbox vs Production

|                | Sandbox                          | Production                       |
| -------------- | -------------------------------- | -------------------------------- |
| API key prefix | `sk_test_`                       | `sk_live_`                       |
| Base URL       | `https://api.stablegenius.co/v1` | `https://api.stablegenius.co/v1` |
| Blockchain     | Base Sepolia (testnet)           | Base (mainnet)                   |
| USDC           | Test USDC (free, no value)       | Real USDC                        |
| Webhooks       | Delivered to your endpoint       | Delivered to your endpoint       |
| Settlement     | Simulated (no real ACH)          | Real ACH to merchant bank        |
| Rate limits    | 100 req/min                      | 1,000 req/min                    |

The base URL is the same for both environments. The API key determines which environment you're in.

## Getting Test USDC

To test payments in sandbox mode, you need test USDC on Base Sepolia:

1. Get Base Sepolia ETH from the [Base Sepolia Faucet](https://www.coinbase.com/faucets/base-ethereum-sepolia) for gas fees
2. Get test USDC from the [Circle USDC Faucet](https://faucet.circle.com/) (select Base Sepolia)
3. Import test USDC into your wallet using the testnet USDC contract address

## Testing the Full Flow

### 1. Create a test payment intent

```bash theme={null}
curl -X POST https://api.stablegenius.co/v1/payment-intents \
  -H "Authorization: Bearer sk_test_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 1.00,
    "currency": "usd",
    "merchant_id": "mer_test_abc123",
    "metadata": { "test": "true" }
  }'
```

### 2. Pay with test USDC

Scan the QR code with a wallet configured for Base Sepolia, or send test USDC directly to the `payment_address` returned in the response.

### 3. Verify webhook delivery

Check your webhook endpoint received the `payment_intent.confirmed` event.

### 4. Verify via API

```bash theme={null}
curl https://api.stablegenius.co/v1/payment-intents/pi_test_xyz789 \
  -H "Authorization: Bearer sk_test_abc123"
```

Confirm the status is `confirmed` with the correct `tx_hash` and `net_amount`.

## Test Webhook Events

Trigger test webhook events from the dashboard without sending real transactions:

1. Go to **Settings → Webhooks** in the [dashboard](https://app.stablegenius.co)
2. Click **Send Test Event** next to your webhook endpoint
3. Select the event type (`payment_intent.confirmed`, `settlement.completed`, etc.)
4. We send a test event with realistic sample data to your endpoint

## Testing Checklist

Before going live, verify the following in sandbox:

* [ ] Payment intent creation returns valid QR payload
* [ ] QR code renders correctly on your terminal/app
* [ ] Webhook endpoint returns 200 within 5 seconds
* [ ] Webhook signature verification passes
* [ ] Duplicate event handling works (we send the same event twice)
* [ ] Expired payment intents are handled gracefully
* [ ] Network disconnection and reconnection doesn't break the flow
* [ ] Edge case: customer sends wrong amount

## Going Live

When you're ready to switch to production:

1. Replace `sk_test_` with `sk_live_` in your server configuration
2. Ensure your webhook endpoint is accessible over HTTPS
3. Verify your merchant has completed KYC and linked a real bank account
4. Process a small live payment (\$0.10) to confirm end-to-end

<Warning>
  **Never use `sk_live_` keys in development or test environments.** Live keys process real USDC on Base mainnet.
</Warning>
