How it works
- Your server → Yeri
Create a payment
Your server creates a payment with your secret API key and gets back a
checkout_url. - Customer → pay.yeripay.com
Redirect the customer
You redirect the customer to
checkout_url(Yeri's hosted payment page,pay.yeripay.com). The customer enters the card, CVV and passes 3-D Secure there. - pay.yeripay.com → your site
The customer comes back
The customer comes back to your
return_url. - Yeri ⇄ your server
Confirm on your server
You confirm the result on your server: a signed webhook (
payment_intent.succeeded) and/orGET /v1/payment_intents/{id}.
API keys
The business owner creates keys at admin.yeripay.com → Online payments → API keys. A key is shown once; store it in your server's secret store, never in browser or mobile code.
| Key | Mode | Money | Cards |
|---|---|---|---|
sk_live_… | live | real | real cards |
sk_test_… | test | none (simulation) | only the test cards below |
Test and live are separate worlds: a test key never sees live payments, saved cards or webhook endpoints (and the other way round). Responses carry "livemode": true|false.
Send the key in the Authorization header of every request:
Authorization: Bearer sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA revoked or wrong key answers 401 {"error": "invalid_api_key"}.
Create a payment
From your server, send POST /v1/payment_intents:
curl https://pay.yeripay.com/v1/payment_intents \
-H "Authorization: Bearer $YERI_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042" \
-d '{"amount_minor": 1250, "currency": "AZN", "description": "Order #1042",
"return_url": "https://shop.example.com/orders/1042", "locale": "az"}'Request fields
| Field | Type | Description |
|---|---|---|
mode | payment (default) | setup | setup = save a card without charging (needs customer_ref) |
amount_minor | integer | required for payment, 1 … 10 000 000 |
currency | AZN | — |
description | string ≤ 200 | shown on the payment page |
customer_ref | string ≤ 64, [A-Za-z0-9_.:-] | your customer id — enables saved cards |
return_url | https://… ≤ 500 | "Back to shop" button after the payment |
locale | az | en | ru | payment page language |
Response
Response 201 — a payment intent:
{
"id": "pi_8KfT2c1x0aQpZ3mL",
"object": "payment_intent",
"livemode": true,
"mode": "payment",
"status": "requires_payment_method",
"amount_minor": 1250,
"currency": "AZN",
"description": "Order #1042",
"customer_ref": null,
"client_secret": "cs_…",
"checkout_url": "https://pay.yeripay.com/?pi=pi_8KfT2c1x0aQpZ3mL#cs=cs_…",
"card": null,
"saved_card_id": null,
"approval_code": null,
"rrn": null,
"refunded_minor": 0,
"last_error": null,
"created_at": 1763300000
}Redirect the customer to checkout_url as is. The link is valid for 30 minutes; the customer has 3 attempts. Treat client_secret like a password (it opens this payment's page); don't log it.
Idempotency
Send Idempotency-Key (≤ 128 chars, e.g. your order id). Repeating the same request with the same key returns the same intent instead of creating a second one; the same key with a different body answers 409 idempotency_key_mismatch.
Statuses
| Status | Meaning |
|---|---|
requires_payment_method | waiting for the card (or the last attempt was declined and attempts remain) |
requires_action | the customer is on the bank's 3-D Secure screen |
processing | the bank is still deciding — wait for the webhook or poll |
succeeded | paid (or, for setup, the card is saved) — ship the order |
failed | no more attempts or the link expired (last_error says why) |
partially_refundedrefunded | money (partly) returned |
reversed | authorization cancelled before settlement |
Check, refund, reversal
Check a payment
curl https://pay.yeripay.com/v1/payment_intents/pi_8KfT2c1x0aQpZ3mL \
-H "Authorization: Bearer $YERI_SECRET_KEY"Refund and reversal
# partial refund (omit the body for a full refund of what is left)
curl -X POST https://pay.yeripay.com/v1/payment_intents/pi_8KfT2c1x0aQpZ3mL/refund \
-H "Authorization: Bearer $YERI_SECRET_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: refund-1042-1" -d '{"amount_minor": 300}'
# reversal (same day, before settlement)
curl -X POST https://pay.yeripay.com/v1/payment_intents/pi_8KfT2c1x0aQpZ3mL/reverse \
-H "Authorization: Bearer $YERI_SECRET_KEY"502 refund_rejected / reverse_rejected = the bank said no and no money moved; you may retry.Saved cards
Pass customer_ref and the payment page offers "Remember this card". Next time the customer pays with one tap (CVV is not stored anywhere — the bank confirms the customer instead). To save a card without charging, create an intent with "mode": "setup".
List a customer's saved cards, or delete one:
curl https://pay.yeripay.com/v1/customers/cust_77/cards -H "Authorization: Bearer $YERI_SECRET_KEY"
curl -X DELETE https://pay.yeripay.com/v1/customers/cust_77/cards/card_… -H "Authorization: Bearer $YERI_SECRET_KEY"A card has id, brand, last4, exp_month, exp_year. Yeri deletes cards that expired or were not used for 24 months.
Webhooks
Register an HTTPS endpoint once; Yeri POSTs an event to it when a payment reaches a final state.
curl https://pay.yeripay.com/v1/webhook_endpoints \
-H "Authorization: Bearer $YERI_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://shop.example.com/yeri/webhook", "enabled_events": ["*"]}'"secret": "whsec_…" — shown only once, store it next to your API key. Up to 5 endpoints per mode. GET /v1/webhook_endpoints lists them, DELETE /v1/webhook_endpoints/{id} removes one. Test-key endpoints receive only test events.Events
| Event | When |
|---|---|
payment_intent.succeeded | paid / card saved |
payment_intent.failed | no attempts left or expired |
payment_intent.partially_refunded | each partial refund |
payment_intent.refunded | fully refunded |
payment_intent.reversed | reversed |
Event payload
{
"id": "evt_Xq3…",
"object": "event",
"type": "payment_intent.succeeded",
"created": 1763300042,
"livemode": true,
"data": { "object": { "id": "pi_8KfT2c1x0aQpZ3mL", "object": "payment_intent", "status": "succeeded", "…": "…" } }
}data.object is the payment intent without client_secret and checkout_url.
Delivery
Answer any 2xx within 10 seconds (do the slow work afterwards). Anything else — or a timeout — is retried after 1 min, 5 min, 30 min, 1 h, 3 h, 6 h, 12 h, then daily, for about 4 days. Redirects are not followed.
Delivery is at least once: the same event can arrive twice — use id to ignore duplicates. Events can arrive out of order; trust the status inside, or re-read the intent.
Verify the signature
Every request has Yeri-Signature: t=<unix time>,v1=<hex> and Yeri-Event-Id. v1 = HMAC-SHA256(secret, "<t>.<raw body>"). Use the raw body bytes (not re-encoded JSON), compare in constant time, and reject t older than 5 minutes.
import crypto from "node:crypto";
app.post("/yeri/webhook", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("Yeri-Signature") || "";
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
const expected = crypto.createHmac("sha256", process.env.YERI_WEBHOOK_SECRET)
.update(`${parts.t}.`).update(req.body).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) <= 300;
const ok = fresh && parts.v1 && parts.v1.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
if (!ok) return res.sendStatus(400);
const event = JSON.parse(req.body);
if (event.type === "payment_intent.succeeded") { /* mark order paid (once per event.id) */ }
res.sendStatus(200);
});Missed events
GET /v1/events?limit=20&starting_after=evt_…&payment_intent=pi_… lists the last 30 days (newest first, has_more for paging) in the same format, so you can catch up after downtime.
Test mode
Use an sk_test_… key. Nothing is charged; only these cards work (any future expiry date, any 3-digit CVV):
| Card | Result |
|---|---|
4242 4242 4242 42425555 5555 5555 4444 | success |
4000 0000 0000 3220 | 3-D Secure screen — code 123456 succeeds, anything else fails |
4000 0000 0000 0002 | declined (do_not_honor) |
4000 0000 0000 9995 | declined (insufficient_funds) |
4000 0000 0000 0101 | wrong CVV (incorrect_cvc) |
The payment page shows a "Test mode" banner. Real card numbers are refused in test mode.
Errors
Errors are {"error": "<code>"} with an HTTP status; validation errors add "fields": [...].
| Status | Codes |
|---|---|
| 400 | invalid_numberinvalid_expiryinvalid_cvcunsupported_brandcard_or_saved_card_required |
| 401 | invalid_api_key |
| 403 | merchant_disabledonline payments switched off for the business |
| 404 | intent_not_foundcard_not_foundendpoint_not_found |
| 409 | idempotency_key_mismatchintent_not_refundableintent_not_reversibletoo_many_endpoints |
| 410 | intent_expired |
| 422 | invalid_requestamount_requiredcustomer_ref_requiredinvalid_webhook_urlinvalid_event_type |
| 429 | too_many_attempts |
| 502 | acquirer_unavailablerefund_rejectedreverse_rejectedretry later |
| 503 | directory_unavailabletemporary, retry with the same Idempotency-Key |
A declined card is not an error: the intent comes back with status and last_error (e.g. do_not_honor).
Go-live checklist
- The secret key and the webhook secret live only on your server.
- Order is marked paid only after a verified
payment_intent.succeededwebhook (or a server-sideGET). - Webhook handler is idempotent by
event.idand answers2xxfast. Idempotency-Key= your order id on create and refund.- You tested success, decline, 3-D Secure and refund with an
sk_test_key.
Ready to start?
Create a test key, try the integration with the test cards, then switch to a live key.