Quick Start — Your First Payment in 15 Minutes
This guide walks you through creating a payment transaction from scratch. No prior knowledge of the platform required.
Prerequisites
- Your API key (find it in Partner Area → Settings → API Keys)
curlinstalled, or any HTTP client
Step 1 — Check your connection
curl https://4pay.online/api/v1/health
Expected response:
{ "status": "ok" }
Step 2 — Create a transaction
curl -X POST https://4pay.online/api/v1/transactions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"params": {
"type": "payment",
"amount": 1000,
"currency": "USD",
"txid": "order-12345",
"returnUrl": "https://yoursite.com/success",
"failUrl": "https://yoursite.com/fail"
}
}'
Amount format
amount is in the smallest currency unit (cents, pence, kopecks). 1000 = $10.00 USD.
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "created",
"txid": "order-12345",
"amount": 1000,
"currency": "USD",
"payment_url": "https://4pay.online/pay/550e8400-...",
"created_at": "2026-03-01T10:00:00Z"
}
Redirect your user to payment_url. They will see the hosted payment page where they can complete the payment.
Step 3 — Check the transaction status
curl https://4pay.online/api/v1/transactions/550e8400-e29b-41d4-a716-446655440000 \
-H "x-api-key: YOUR_API_KEY"
Transaction statuses:
| Status | Meaning |
|---|---|
created | Transaction created, awaiting payment |
pending | Submitted to the payment provider |
processing | Being processed by the provider |
charged | Payment successful ✅ |
failed | Payment failed — provider declined |
rejected | Rejected before reaching the provider (no routing, limits) |
cancelled | Cancelled by partner or user |
refunded | Refund completed |
Step 4 — Receive webhook notifications
Instead of polling, set up a notify_url to receive real-time status updates:
curl -X POST https://4pay.online/api/v1/transactions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"params": {
"type": "payment",
"amount": 1000,
"currency": "USD",
"txid": "order-12346",
"returnUrl": "https://yoursite.com/success",
"failUrl": "https://yoursite.com/fail",
"notifyUrl": "https://yoursite.com/webhooks/payment"
}
}'
When the transaction status changes, a POST request will be sent to your notifyUrl. See Webhooks for the full event format and signature verification.
Step 5 — Issue a refund
curl -X PUT https://4pay.online/api/v1/transactions/550e8400-e29b-41d4-a716-446655440000 \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"params": {
"type": "refund",
"amount": 500
}
}'
For a full refund, omit amount or set it equal to the original transaction amount.
Next steps
- Authentication — understand API key vs Bearer token
- Transactions — full reference for all transaction operations
- Webhooks — complete webhook event format and verification
- Sandbox & Testing — test without real money