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

# Quickstart

> Step-by-step guide to implement your first payment

## Environments

| Environment | Admin Dashboard                                            | API                       |
| ----------- | ---------------------------------------------------------- | ------------------------- |
| Sandbox     | [app.sandbox.zafapay.com](https://app.sandbox.zafapay.com) | `api.sandbox.zafapay.com` |
| Production  | [app.zafapay.com](https://app.zafapay.com)                 | `api.zafapay.com`         |

<Note>
  Use the Sandbox environment for development and testing. Switching to production only requires changing the API endpoint URL.
</Note>

## 1. Get Access Token

Get your access token from the "Merchant Settings" page in the merchant dashboard.

```bash theme={null}
# All API requests require an Authorization header
Authorization: Bearer YOUR_ACCESS_TOKEN
```

<Note>
  For detailed instructions, see [Authentication](/en/api-reference/authentication).
</Note>

## 2. Create Payment

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.sandbox.zafapay.com/v1/payments \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 100,
      "currency": "usd",
      "external_id": "order_12345"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.sandbox.zafapay.com/v1/payments', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      amount: 100,
      currency: 'usd',
      external_id: 'order_12345'
    })
  });

  const payment = await response.json();
  console.log(payment.payment_url);
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "status": "pending",
  "transaction_id": "tx_abc123",
  "gateway_transaction_id": "depot_xxxxx",
  "payment_url": "https://pay.sandbox.zafapay.com/checkout/tx_abc123?sig=xxxxxxxxxxxxxxxx"
}
```

## 3. Redirect Customer

Redirect the customer to the `payment_url` from the response.
After payment completion, the customer is redirected to the URL configured for your account in the merchant dashboard (`success_redirect_url` / `failure_redirect_url`).

To send each payment to a different page, pass `success_url`, `failure_url`, or `cancel_url` when creating the payment — they override the dashboard defaults for that payment only. `request_id`, `transaction_id`, and `status` are appended to the URL as query parameters.

## 4. Verify Payment Result

```bash theme={null}
curl https://api.sandbox.zafapay.com/v1/payments/tx_abc123 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

**Response:**

```json theme={null}
{
  "id": "tx_abc123",
  "status": "completed",
  "amount": 100,
  "currency": "usd"
}
```

## Next Steps

<Columns cols={2}>
  <Card title="API Reference" icon="book" href="/en/api-reference/introduction">
    Complete API endpoint documentation
  </Card>

  <Card title="Implement Refunds" icon="rotate-left" href="/en/api-reference/payments/refund">
    How to refund payments
  </Card>
</Columns>
