Accept card payments with PayRivox
Everything your developer needs to take card payments on your website or app: create a payment from your server, send the customer to our secure payment page, and get the result by webhook.
API base URL: https://api.payrivox.com
How it works
- Your server creates a payment with your secret API key and gets a checkout_url.
- You send the customer to the checkout_url. Card details are entered on our secure payment page, never on your site.
- The customer pays (with 3-D Secure when the bank asks for it) and comes back to your return_url.
- We send a webhook to your server with the result (payment.completed or payment.failed).
- Ship the order once the payment is completed. Your balance is paid out according to your settlement terms.
Never trust the return to your site alone: always confirm with the webhook or by checking the payment.
API keys
You receive two kinds of secret keys from your PayRivox account manager:
| Key | Use |
|---|---|
sk_test_… | Test mode. Use test cards, no real money moves. Your dashboard shows these payments while you are in test mode. |
sk_live_… | Live mode. Real cards and real money. Issued once your integration has been tested. |
Send the key in the Authorization header of every request, from your server only:
Authorization: Bearer sk_test_...
Keep keys secret: never put them in a website, an app or a public repository. If a key may have leaked, ask us to revoke it and issue a new one. Limit: 300 requests per minute per key.
Create a payment
Create a payment from your server:
curl -X POST https://api.payrivox.com/v1/payments \
-H "Authorization: Bearer sk_test_..." \
-H "Idempotency-Key: order-1001" \
-H "Content-Type: application/json" \
-d '{
"amount": 2500,
"currency": "EUR",
"reference": "order-1001",
"description": "Headphones",
"customer": {
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@example.com",
"phone": "+905321234567",
"address": "Bagdat Cd. 1",
"city": "Istanbul",
"zip": "34710",
"country": "TR",
"ip": "203.0.113.7"
},
"return_url": "https://your-shop.com/thank-you"
}'| Field | Required | Meaning |
|---|---|---|
amount | Yes | In the smallest unit: 2500 = 25.00 (cents, kuruş). |
currency | Yes | EUR, USD, GBP or TRY. |
reference | No | Your own order number (up to 100 characters). Shown in the dashboard and in webhooks. |
description | No | Shown to the customer on the payment page. |
description_tr | No | Turkish description, shown to Turkish-speaking customers instead. |
customer | Recommended | first_name, last_name, email, phone (optional, with country code), address, city, zip, country (2 letters; state for US, CA and AU). The card processor needs these (phone is optional): anything you leave out, the customer is asked on the payment page. |
customer.ip | Recommended | Your customer's IP address, for fraud checks. |
return_url | No | Where the customer goes back to after paying (also after a failed payment). |
Send an Idempotency-Key header (for example your order number): if a request is retried, you get the same payment back instead of a second charge.
Response
{
"id": "cmv8x2k1q0001abcd",
"object": "payment",
"status": "pending",
"amount": 2500,
"currency": "EUR",
"reference": "order-1001",
"checkout_url": "https://…",
"card": null,
"fee": 243,
"net_amount": 2257,
"failure_reason": null,
"created_at": "2026-10-19T10:00:00.000Z",
"updated_at": "2026-10-19T10:00:00.000Z"
}fee is our fee for this payment and net_amount is what you receive. checkout_url is only present while the payment is pending.
Send the customer to pay
Redirect the customer's browser to checkout_url. The page is available in English and Turkish and handles 3-D Secure.
After paying the customer returns to your return_url. Show them a "thank you, we are confirming your payment" page and wait for the webhook (usually seconds).
Direct card API (H2H)
If your systems are PCI DSS compliant, you can send the card details directly from your server instead of using our payment page. Add a card object (and the payer's browser details) to the same create-payment request.
curl -X POST https://api.payrivox.com/v1/payments \
-H "Authorization: Bearer sk_test_..." \
-H "Idempotency-Key: order-1002" \
-H "Content-Type: application/json" \
-d '{
"amount": 75000,
"currency": "TRY",
"reference": "order-1002",
"return_url": "https://your-shop.com/thank-you",
"customer": {
"first_name": "Jane", "last_name": "Doe",
"email": "jane@example.com", "phone": "+905321234567",
"address": "Bagdat Cd. 1", "city": "Istanbul", "zip": "34710",
"country": "TR", "ip": "203.0.113.7"
},
"card": {
"number": "4538977399606732",
"holder": "JANE DOE",
"exp_month": 12,
"exp_year": 2028,
"cvc": "123"
},
"browser": {
"accept_header": "text/html,application/xhtml+xml",
"user_agent": "Mozilla/5.0 (...)",
"language": "tr-TR",
"color_depth": 24,
"screen_height": 900,
"screen_width": 1440,
"timezone_offset": -180,
"java_enabled": false
}
}'
# Card step failed? Send the card again for the same payment:
curl -X POST https://api.payrivox.com/v1/payments/{id}/card \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{ "card": { ... }, "browser": { ... } }'| Field | Required | Meaning |
|---|---|---|
card | Yes | Card: number, holder (name on card), exp_month, exp_year, cvc. |
customer + customer.ip | Yes | first_name, last_name, email, phone (optional, with country code), address, city, zip, country (2 letters; state for US, CA and AU). The card processor needs these (phone is optional): anything you leave out, the customer is asked on the payment page. |
browser | Yes | The payer's browser details, collected from the payer's browser: accept_header, user_agent, language, color_depth, screen_height, screen_width, timezone_offset, java_enabled. All are required by the bank for 3-D Secure. |
After the card is sent, we wait a few seconds for the processor's decision and answer with the payment and a next_action field. If status is completed or failed, it is final. If next_action is {"type": "redirect_3ds", "url": "..."}, the card's bank asks for 3-D Secure: redirect the payer to that url; they confirm on their bank's page and come back to your return_url. If the status is pending and next_action is null, do not redirect: wait for the webhook (or call GET /v1/payments/{id}, which also returns next_action).
All customer fields, including customer.ip, are required for card payments. If the card step fails, the error includes details.payment_id: fix the problem and send the card again for that payment with POST /v1/payments/{id}/card.
Card data must only travel between your PCI DSS compliant servers and our API over HTTPS. Never store the CVC, and never log card numbers.
Payment statuses
| Status | Meaning |
|---|---|
pending | Created, the customer has not paid yet. Payments still pending after 24 hours fail with failure_reason "expired". |
completed | Paid. Ship the order. |
failed | Declined by the bank or not completed. failure_reason may say why. |
review | Paid but held for a manual check. Wait for completed or rejected. |
on_hold | Held by our team. Wait for a final status. |
rejected | Stopped after review. The customer is not charged (or is refunded). |
refunded | The full amount was returned to the customer. |
Check a payment
curl https://api.payrivox.com/v1/payments/{id} -H "Authorization: Bearer sk_test_..."
curl "https://api.payrivox.com/v1/payments?limit=20" -H "Authorization: Bearer sk_test_..."Use this when you did not receive a webhook, or to show the latest status. The list returns your most recent payments (limit up to 100).
Refunds
curl -X POST https://api.payrivox.com/v1/payments/{id}/refund -H "Authorization: Bearer sk_test_..."Refunds the full amount to the customer's card. The amount is taken from your balance; the payment fee is not returned. Only completed payments can be refunded.
Webhooks
Set your webhook URL (https) in the dashboard under Developers. We send a POST with a JSON body { id, type, created_at, data } whenever something happens. data is the same payment object the API returns.
| Event | Meaning |
|---|---|
payment.completed | The customer paid. |
payment.failed | The payment was declined or expired. |
payment.refunded | The payment was refunded. |
payment.rejected | The payment was rejected after review. |
payment.review | The payment is being reviewed. |
chargeback.created | The customer disputed the payment with their bank. |
test.ping | Sent by the "Send test event" button. |
Every request carries a PayRivox-Signature header. Check it with your signing secret (shown under Developers) before trusting the message:
// Node.js / Express
const crypto = require("crypto");
app.post("/payrivox/webhook", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("PayRivox-Signature"); // t=1760000000,v1=5f3a…
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", process.env.PAYRIVOX_WEBHOOK_SECRET)
.update(t + "." + req.body).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300; // reject replays
if (!fresh || !crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body); // { id, type, created_at, data }
if (event.type === "payment.completed") {
// mark order event.data.reference as paid (once: use event.id to ignore repeats)
}
res.sendStatus(200);
});<?php
$body = file_get_contents("php://input");
parse_str(str_replace(",", "&", $_SERVER["HTTP_PAYRIVOX_SIGNATURE"] ?? ""), $sig);
$expected = hash_hmac("sha256", $sig["t"] . "." . $body, getenv("PAYRIVOX_WEBHOOK_SECRET"));
if (abs(time() - (int)$sig["t"]) > 300 || !hash_equals($expected, $sig["v1"] ?? "")) {
http_response_code(400); exit;
}
$event = json_decode($body, true);
http_response_code(200);Answer with any 2xx status within 10 seconds. Otherwise we retry after 1, 5 and 15 minutes, then 1, 3, 6, 12 and 24 hours. The same event can arrive more than once: use its id to process it only once.
Testing
With a test key, use these cards on the payment page. Any cardholder name and any future expiry date work (for example 12/30).
| Card number | CVV | Result |
|---|---|---|
4538 9773 9960 6732 | 123 | Approved |
4538 9773 9960 6732 | 101 | Declined (expired card) |
4538 9773 9960 6732 | 116 | Declined (insufficient funds) |
4538 9773 9960 6732 | 321 | 3-D Secure check, then approved |
Test cards only work with test keys. Never use a real card in test mode.
Errors
{ "error": { "code": "invalid_request", "message": "Invalid request", "details": { … } } }| HTTP | code | Meaning |
|---|---|---|
| 401 | unauthorized | Missing, wrong or revoked API key. |
| 404 | not_found | The payment does not exist or belongs to another account. |
| 422 | invalid_request | A field is missing or has the wrong format; details lists the fields. |
| 4xx/5xx | payment_error | The payment could not be created (for example the account is not active). |
| 429 | rate_limited | Too many requests: slow down and retry. |
Going live
- Run a full test: approved, declined, 3-D Secure and a refund, with your webhook receiving each event.
- Make sure you check the webhook signature and ignore repeated events.
- Ask your PayRivox account manager for your live key and replace the test key on your server.
- Make one small real payment and refund it.
- Keep your keys and webhook secret safe; rotate them if someone leaves your team.
Questions? Contact your PayRivox account manager.