Skip to content

Quickstart ​

This guide shows how to accept payments with a Bearer API key (pk_…), send payers to the hosted checkout page, and verify webhooks.

Quick start ​

  1. Get an API key — Merchant admin → Settings → API keys. Create a key with payments:read and payments:write. Store the secret once; only the hash is kept server-side.

  2. Configure a webhook — Set your HTTPS callback URL and copy the signing secret when you rotate it.

  3. Create a payment (one call; confirm runs automatically by default):

bash
export API_BASE="https://api.vikipay.io"
export API_KEY="pk_your_secret"

curl -sS -X POST "$API_BASE/api/v1/payments" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: order-$(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 57000,
    "currency": "ARS",
    "external_id": "order-1001",
    "success_url": "https://merchant.example/paid",
    "fail_url": "https://merchant.example/failed"
  }'

The response includes checkout_url — redirect the payer there (or open it in a browser):

json
{
  "id": "pi_…",
  "status": "requires_action",
  "checkout_url": "https://pay.vikipay.io/r/pi_…",
  "amount_minor": 57000,
  "currency": "ARS"
}
  1. Receive webhooks when the payment reaches a terminal state (payment.succeeded, payment.failed, payment.canceled, or payment.expired).

To use the legacy two-step flow, send "auto_confirm": false on create and call POST /api/v1/payments/{id}/confirm with a new Idempotency-Key.

Payment statuses ​

StatusMeaning
pendingCreated, not yet confirmed (only when auto_confirm is false)
requires_actionPayer must complete transfer on the checkout page
processingProvider is processing
succeededPaid and captured
failedDefinitive failure
expiredOrder lifetime elapsed
canceledCanceled before capture

Errors ​

Errors are JSON: {"error":{"code":"…","message":"…","request_id":"…"}}.

HTTPCodeWhen
400invalid_argumentBad body, missing Idempotency-Key
401unauthorizedMissing or invalid API key
403access_deniedScope or suspended merchant
404not_foundUnknown payment id
409duplicate_external_id / conflictIdempotency or order clash
422no_capable_providerMerchant has no active terminal

Webhooks ​

Event types ​

  • payment.succeeded — funds captured (including manual review acceptance)
  • payment.failed — terminal failure (including manual review rejection)
  • payment.canceled — payer or provider canceled before capture
  • payment.expired — checkout window ended

Envelope:

json
{
  "id": "evt_…",
  "type": "payment.succeeded",
  "created_at": "2026-01-15T12:00:00Z",
  "data": {
    "id": "pi_…",
    "status": "succeeded",
    "amount_minor": 57000,
    "currency": "ARS",
    "merchant_id": "mer_…",
    "captured_minor": 57000,
    "external_id": "order-1001"
  }
}

data is provider-neutral (no provider name or upstream ids).

Headers ​

HeaderDescription
X-Webhook-IdEvent id (use for idempotency)
X-Webhook-TimestampUnix seconds when the delivery was signed
X-Webhook-Signaturesha256=<hex> HMAC of timestamp + "." + raw_body

Reject requests when |now - timestamp| > 5 minutes.

Verify with curl (OpenSSL) ​

bash
BODY='…raw body…'
TS='1736935200'
SECRET='whsec_…'
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
# compare to header value without the sha256= prefix

Node.js ​

javascript
const crypto = require('crypto');

function verify(secret, rawBody, timestamp, signatureHeader) {
  const expected = crypto.createHmac('sha256', secret)
    .update(`${timestamp}.${rawBody}`)
    .digest('hex');
  const got = signatureHeader.replace(/^sha256=/, '');
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(got));
}

Python ​

python
import hmac, hashlib

def verify(secret: str, raw_body: bytes, timestamp: str, signature: str) -> bool:
    msg = f"{timestamp}.".encode() + raw_body
    expected = hmac.new(secret.encode(), msg, hashlib.sha256).hexdigest()
    got = signature.removeprefix("sha256=")
    return hmac.compare_digest(expected, got)

PHP ​

php
function verify_webhook(string $secret, string $rawBody, string $timestamp, string $signature): bool {
    $expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
    $got = str_starts_with($signature, 'sha256=') ? substr($signature, 7) : $signature;
    return hash_equals($expected, $got);
}

Retries and ACK ​

Return 2xx quickly. Non-2xx responses are retried on a fixed schedule (delays after failed attempts 1–8: 30s, 2m, 10m, 30m, 1h, 3h, 6h, 12h), with a small jitter on each delay, for up to 9 delivery attempts (~23 hours of retry spacing after the first try). Operations Resend bypasses the schedule and requeues immediately. Duplicates share the same X-Webhook-Id — treat processing as idempotent.

Idempotency (API) ​

Every POST that creates or confirms a payment requires Idempotency-Key. Repeating the same key with the same body returns the original result without double-charging.

API reference ​

See docs/api/openapi-v1.yaml for paths, Bearer auth (pk_), scopes, and schemas.