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

# Create your first payment

> From a server-side API request to a hosted checkout.

## Prepare your sandbox organization

1. Sign in to the [sandbox dashboard](https://sandbox.gochameleon.xyz).
2. Add an active Arc USDC settlement wallet to your organization.
3. Create a test API key. It starts with `gck_test_`; keep it on your server.
4. Use a buyer wallet with test funds on the sandbox network to complete checkout.

## Create a payment

Set these environment variables in your terminal. Replace the placeholder with your test key; do not commit it.

```bash theme={null}
export GOCHAMELEON_API_URL="https://sandbox-api.gochameleon.xyz"
export GOCHAMELEON_SECRET_KEY="gck_test_REPLACE_ME"
export GOCHAMELEON_IDEMPOTENCY_KEY="order_example_000001"
```

Use a new idempotency key for each new payment attempt. Keep the same key and payload when retrying a timed-out request.

```python Python theme={null}
# Install once: python -m pip install requests
import os
import requests

response = requests.post(
    os.environ["GOCHAMELEON_API_URL"].rstrip("/") + "/api/v1/payments/",
    headers={
        "Authorization": "Bearer " + os.environ["GOCHAMELEON_SECRET_KEY"],
        "Idempotency-Key": os.environ["GOCHAMELEON_IDEMPOTENCY_KEY"],
    },
    json={
        "amount": 1000000,
        "currency": "USDC",
        "reference": "order-000001",
        "metadata": {"order_id": "000001"},
    },
    timeout=30,
)
if not response.ok:
    raise RuntimeError(f"goChameleon {response.status_code}: {response.text}")
payment = response.json()
print("Payment:", payment["id"])
print("Checkout:", payment["checkout_url"])
```

```bash cURL theme={null}
curl --fail-with-body "$GOCHAMELEON_API_URL/api/v1/payments/" \
  -H "Authorization: Bearer $GOCHAMELEON_SECRET_KEY" \
  -H "Idempotency-Key: $GOCHAMELEON_IDEMPOTENCY_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"amount":1000000,"currency":"USDC","reference":"order-000001","metadata":{"order_id":"000001"}}'
```

A new payment returns **201**. An identical retry returns **200** with the same payment ID.

## Open checkout

Redirect the buyer to the returned `checkout_url`. The hosted page connects their wallet and tracks the transaction. Store the payment `id` alongside your order in your database.

You can also supply `success_url` and `cancel_url` with your own HTTPS URLs. The checkout provides links back to your store. Returning to your store does not prove that a payment succeeded.

## Verify the result

Use the **Retrieve a payment** playground, or call the endpoint from your server:

```bash theme={null}
curl --fail-with-body "$GOCHAMELEON_API_URL/api/v1/payments/manage/intents/PAYMENT_ID/" \
  -H "Authorization: Bearer $GOCHAMELEON_SECRET_KEY"
```

Replace `PAYMENT_ID` with the creation response's `id`. Fulfill only when your server verifies `status: confirmed` for the stored payment and expected order amount and asset. Add [signed webhooks](https://docs.gochameleon.xyz/webhooks.md) to receive updates automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.