POST /api/v1/payments with type: "card".
Idempotency-Key required — requests without it are rejected with 400 IDEMPOTENCY_KEY_REQUIRED. Idempotency.
Returns 201 with status: "pending" and a payment_url for hosted card checkout, or 200 when replaying an existing Idempotency-Key.
Body
| Field | Required | Notes |
|---|---|---|
amount, currency, type, customer, phone | yes | type must be "card". Currencies: TZS, USD, KES, UGX |
customer | yes | firstname, lastname, email, address, city, state, postcode, country |
redirect_url, cancel_url | yes | Hosted checkout return URLs |
network | no | Validated against the supported operator list when provided; not needed for card |
reference, metadata | no | Duplicate live reference → 409 DUPLICATE_REFERENCE |
webhook_url | no | Recommended — status events; overrides merchant default |
callback_url | no | Optional — one-shot terminal notification; omit unless you need a separate callback endpoint |
What the customer sees
- You receive
payment_urlin the response (the link is also sent to the customer’s email and phone). - Redirect the customer’s browser to that URL.
- They enter card details on the hosted checkout page (PCI scope stays with PayGrid).
- They are redirected to your
redirect_url(success) orcancel_url(cancelled). - PayGrid sends a webhook with the final status.
Error semantics
| HTTP | error_code | Meaning |
|---|---|---|
| 400 | IDEMPOTENCY_KEY_REQUIRED | Missing Idempotency-Key header |
| 400 | VALIDATION_ERROR | Missing/invalid amount, currency, type, customer, or phone |
| 400 | PAYMENT_FAILED | Missing redirect_url, cancel_url, or a billing address field (customer.address, city, state, postcode, country) |
| 402 | PAYMENT_DECLINED | Payment declined immediately — no charge; details has transaction_id, status: "failed", and reference |
| 409 | DUPLICATE_REFERENCE | A live (pending/processing/completed) payment with this reference exists; failed, cancelled, or expired attempts do not block a retry |
| 502 | PROVIDER_UNAVAILABLE / PROVIDER_ERROR | Temporary upstream outage — retry with the same Idempotency-Key |
API reference
Create Card Payment

