# Your first payment

Go from a connected sandbox provider to a payment your server can verify.

## 1. Set up your sandbox

1. Create an account and a project in the dashboard.
2. Select the sandbox environment and connect a supported provider using its test credentials.
3. Create an API key with payments:write and payments:read. Store the secret in your server environment as VEYQO_SECRET_KEY.
4. Create and persist a payment-attempt key for your order. Use it as ORDER_PAYMENT_KEY in the request below.

## 2. Create a payment

Run this request from your server. The example charges NGN 500.00. Use a fresh order reference for each new order and a stable idempotency key for retries of the same operation.

```
curl https://api.veyqo.org/api/v1/payments \
  -H "Authorization: Bearer $VEYQO_SECRET_KEY" \
  -H "Idempotency-Key: $ORDER_PAYMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 50000,
    "currency": "NGN",
    "reference": "ORDER-1001",
    "provider": "paystack",
    "customer": { "email": "customer@example.com" },
    "metadata": { "order_id": "1001" }
  }'
```

## 3. Send the customer to checkout

A successful response has success: true and a data object. Save data.id with your order, then redirect the customer to data.checkout.url. Check the HTTP status and success flag before using these fields.

```
{
  "success": true,
  "data": {
    "id": "pay_example",
    "reference": "ORDER-1001",
    "status": "pending",
    "amount": 50000,
    "currency": "NGN",
    "checkout": { "url": "https://checkout.example.com/session" }
  }
}
```

## 4. Confirm the result on your server

Configure a webhook endpoint in the same sandbox environment and subscribe to payment.succeeded. Verify each signature before reading the event, then match the confirmed payment to your stored order. Use the verify endpoint when you need to ask the provider for the latest result.

```
curl -X POST https://api.veyqo.org/api/v1/payments/pay_example/verify \
  -H "Authorization: Bearer $VEYQO_SECRET_KEY"
```

> Fulfil only after trusted server confirmation of succeeded status, amount, currency and order reference. A browser redirect or callback is not proof of payment.
