V-Pay API Documentation
Welcome to the V-Pay API. This documentation covers everything you need to integrate payments into your application — from authentication to webhooks.
The V-Pay API is a RESTful HTTP API. All requests are made over HTTPS and all responses are returned as JSON. You can accept MTN Mobile Money and card payments (Visa and Mastercard, on V-Pay's hosted checkout page).
http://vonsung.rw/api/
— All API endpoints are relative to this base URL.
What you can build
Quick Start
Get from zero to your first payment in five steps. This guide uses cURL but the same steps apply to any HTTP client.
apiUser and apiKey for testing, or the live pair for production./auth/ by passing apiUser and apiKey in your request header./pay/ with the customer's phone number, amount, external reference and other required parameters in the request body. Send the access token from the previous step as Authorization: Bearer …, together with the apiUser and apiKey headers./transaction/status/ or — better — set up a webhook to receive real-time payment confirmation.Authentication
# Generate access token curl --location --request POST 'http://vonsung.rw/api/auth/' \ --header 'apiUser: your_api_user' \ --header 'apiKey: your_api_key' \ --data ''
import requests url = "http://vonsung.rw/api/auth/" payload = "" headers = { 'apiUser': 'your_api_user', 'apiKey': 'your_api_key' } response = requests.request("POST", url, headers=headers, data=payload)
var myHeaders = new Headers(); myHeaders.append("apiUser", "your_api_user"); myHeaders.append("apiKey", "your_api_key"); var raw = ""; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("http://vonsung.rw/api/auth/", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'http://vonsung.rw/api/auth/', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( 'apiUser: your_api_user', 'apiKey: your_api_key' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
Response
{
"access":"eyJhbGciOiJIUzI1NiIsInR5cxxxxxxxxxxxxx",
"refresh":"eyJhbGciOiJIUzI1NiIsInR5cxxxxxxxxxxxxx",
"mode":"live",
"expires_in":"300.0 seconds"
}
POST /auth/ returns an access token. Send it as Authorization: Bearer <access>. Calls that create something also need your apiUser and apiKey headers, so every request is tied to both the token and the account it belongs to:
| Endpoint | Authorization: Bearer | apiUser + apiKey headers |
|---|---|---|
POST /auth/ | — | Required |
POST /auth/refresh/ | — (refresh token in the body) | — |
GET /validate-token/ | Required | — |
POST /pay/ | Required | Required |
POST /payment_links/create/ | Required | Required |
POST /transaction/status/ | — | Required |
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cxxxxxxxxxxxxx apiUser: your_api_user apiKey: your_api_key Content-Type: application/json
Token lifetime and refresh
The access token lasts 300 seconds (expires_in in the response). When it expires, API calls return 401. Either call /auth/ again, or exchange the refresh token for a new access token without sending your keys:
curl --location --request POST 'http://vonsung.rw/api/auth/refresh/' \ --header 'Content-Type: application/json' \ --data-raw '{"refresh": "eyJhbGciOiJIUzI1NiIsInR5cxxxxxxxxxxxxx"}'
{
"access": "eyJhbGciOiJIUzI1NiIsInR5cxxxxxxxxxxxxx"
}
If the refresh token has expired too, the call returns 401: call /auth/ again.
Credentials
| Environment | apiUser starts with | apiKey starts with | Use |
|---|---|---|---|
| Sandbox | vpay_sandbox_ | sk_sandbox_ | Testing. Payments are simulated; no real money moves. |
| Live | vpay_live_ | sk_live_ | Production. Real payments are processed. |
Environments
V-Pay provides two isolated environments. Use sandbox for all development and testing — it mirrors production exactly without moving real funds.
| Environment | Base URL | Notes |
|---|---|---|
| Sandbox | http://vonsung.rw/api/Use sandbox apiUser and apiKey | Simulated payments, full webhook support, test phone numbers available |
| Live | http://vonsung.rw/api/Use live apiUser and apiKey | Real transactions processed against Mobile Money & Bank Cards |
Sandbox test numbers
In sandbox you can use any phone number registered on MTN Mobile Money, such as your own. V-Pay checks with MTN that the number is an active MoMo account, then records a simulated successful payment: no prompt is sent to the phone and no money moves. A number that isn't registered on MoMo is refused with 400.
Live: approved IP addresses and domains
Live requests are only accepted from sources you have registered and V-Pay has approved, like approved domains on other payment platforms. Add them in your dashboard under Settings → API → Security; V-Pay reviews each request.
| Your integration | Register |
|---|---|
| Server-to-server (your backend calls V-Pay) | Your server's public IP address, e.g. 41.186.10.20. |
| From a website in the browser | Your website domain, e.g. https://shop.rw. Its subdomains (www.shop.rw, app.shop.rw) are included. |
Both checks are on by default. If you only call V-Pay from your server, you can ask to turn the domain check off (or the IP check, if you only call from a browser) in the same place.
A live request from anywhere else is refused with 403 and "code": "SOURCE_NOT_APPROVED"; the response tells you the IP address and domain V-Pay saw, so you know what to register. Sandbox requests are accepted from anywhere.
Initiate Payment
Start a payment. What happens next depends on payment_method: with mtnrw the customer approves a prompt on their MTN phone; with card, paddle or all you get a payment_url to send the customer to.
Headers
| Header | Description | |
|---|---|---|
Authorization | required | Bearer <access> from /auth/ |
apiUser | required | Your API user (sandbox or live, matching your account mode) |
apiKey | required | Your API key |
Content-Type | required | application/json |
Body parameters
| Parameter | Type | Description |
|---|---|---|
amount required | number | Amount in the given currency, up to 2 decimals. Must fall within your account's minimum and maximum (checked in RWF). |
currency required | string | A supported currency code, e.g. RWF or USD. Other currencies are converted to RWF at V-Pay's current rate. MTN Mobile Money always charges the customer in RWF. |
payer_name required | string | Customer's full name. |
payer_email required | string | Customer's email address. |
payer_phone required | string | Customer's phone number, e.g. 0788123456 or 250788123456. For mtnrw it must be an MTN Rwanda number. |
external_id required | string | Your own order or reference ID. Must be unique: a repeated value is rejected. |
payee_message required | string | Short description shown to the customer. Avoid colons and other special characters (see tip below). |
payment_method optional | string | mtnrw (MTN Mobile Money), card (hosted card page), paddle (hosted page; international cards, PayPal, Apple Pay and Google Pay through Paddle, charged in USD) or all (hosted page with every method enabled on your account). Default: all. |
send_receipt optional | boolean | Email a receipt to the customer. Default: false. |
success_url optional | string | Where the hosted page sends the customer after paying (card / paddle / all). |
integration_type optional | string | How V-Pay answers an mtnrw request. SYNC (default, used when not set): wait until the customer approves or declines, then return the final status. ASYNC: accept the request and return ACCEPTED at once; the final status is sent to your webhook. See Integration modes. |
# Pay API request curl --location 'http://vonsung.rw/api/pay/' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx' \ --header 'Content-Type: application/json' \ --header 'apiUser: your_api_user' \ --header 'apiKey: your_api_key' \ --data-raw '{ "amount": 5000, "currency": "RWF", "payer_name": "Payer full name", "payer_email": "payer@example.com", "payer_phone": "0790000000", "external_id": "TXNID_5473xxxxxx", "payee_message": "Short message", "send_receipt": true, "payment_method": "card" }'
import requests import json url = "http://vonsung.rw/api/pay/" payload = json.dumps({ "amount": 5000, "currency": "RWF", "payer_name": "Payer full name", "payer_email": "payer@example.com", "payer_phone": "0790000000", "external_id": "TXNID_5473xxxxxx", "payee_message": "Short message", "send_receipt": True, "payment_method": "card" }) headers = { 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx', 'Content-Type': 'application/json', 'apiUser': 'your_api_user', 'apiKey': 'your_api_key' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
var settings = { "url": "http://vonsung.rw/api/pay/", "method": "POST", "timeout": 0, "headers": { "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx", "Content-Type": "application/json", "apiUser": "your_api_user", "apiKey": "your_api_key" }, "data": JSON.stringify({ "amount": 5000, "currency": "RWF", "payer_name": "Payer full name", "payer_email": "payer@example.com", "payer_phone": "0790000000", "external_id": "TXNID_5473xxxxxx", "payee_message": "Short message", "send_receipt": true, "payment_method": "card" }) }; $.ajax(settings).done(function (response) { console.log(response); });
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'http://vonsung.rw/api/pay/', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "amount": 5000, "currency": "RWF", "payer_name": "Payer full name", "payer_email": "payer@example.com", "payer_phone": "0790000000", "external_id": "TXNID_5473xxxxxx", "payee_message": "Short message", "send_receipt": true, "payment_method": "card" }', CURLOPT_HTTPHEADER => array( 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx', 'Content-Type: application/json', 'apiUser: your_api_user', 'apiKey: your_api_key' ) )); $response = curl_exec($curl); curl_close($curl); echo $response;
:) and other special characters in payee_message when using MTN MoMo. These can cause silent payment failures at the network level.Integration modes
For mtnrw, choose how your system gets the result with integration_type. It is optional; when it is not set, V-Pay uses SYNC.
| integration_type | What happens | Use it when |
|---|---|---|
SYNC default | V-Pay sends the prompt and keeps the request open (up to 5 minutes) until the customer approves or declines. The response carries the final status: SUCCESSFUL, FAILED or timeout. The webhook is also sent. | Your customer waits on your page or till for the payment to finish. |
ASYNC | V-Pay sends the prompt and answers at once with ACCEPTED. The payment finishes in the background and the final status (SUCCESSFUL or FAILED) is sent to your webhook. | You don't want to hold the connection open (USSD menus, chat bots, background jobs). |
ASYNC, set your webhook URL first (see Webhooks). You can also check any payment with /transaction/status/. USSD is still accepted and works like ASYNC.{
"payer_name": "Jean Mugisha",
"payer_email": "jean@example.com",
"payer_phone": "250788123456",
"amount": 5000,
"currency": "RWF",
"external_id": "ORDER_1001",
"payee_message": "Order 1001",
"payment_method": "mtnrw",
"integration_type": "ASYNC" // leave out (or "SYNC") to wait for the final status
}
Responses
Every response has a status and a message. Status values are upper case; the one exception is timeout. Which response you get depends on the payment method:
| payment_method | What V-Pay does | Response |
|---|---|---|
card, paddle or all | Creates the payment and returns the hosted payment page. | 200 · PENDING with payment_url |
mtnrw (default SYNC) | Sends the prompt to the customer's phone and waits up to 5 minutes for them to approve it. | 200 · SUCCESSFUL202 · FAILED504 · timeout (still pending) |
mtnrw + integration_type: ASYNC | Sends the prompt and answers immediately. The final status goes to your webhook. | 200 · ACCEPTED |
mtnrw in sandbox | Simulates an approved payment for any number registered on MTN MoMo (no prompt, no money moves). | 200 · SUCCESSFUL, mode: sandbox |
mtnrw in SYNC mode, set your HTTP client timeout to at least 310 seconds. For PENDING, ACCEPTED and timeout, the final result arrives by webhook, or check it with /transaction/status/.Card or all: PENDING
{
"status": "PENDING",
"message": "Payment link created. Redirect the customer to payment_url.",
"transaction_id": "VP86583387",
"merchant": "VONSUNG",
"payment_url": "http://vonsung.rw/api/checkout/3f9aab1b-39e6-4188-a239-81a4xxxxxxx"
}
MTN Mobile Money: SUCCESSFUL
{
"status_code": 200,
"status": "SUCCESSFUL",
"message": "Transaction completed successfully.",
"amount": "5000.00",
"currency": "RWF",
"transaction_date": "2026-05-30 08:03:32 PM",
"timezone": "Africa/Kigali",
"transaction_date_gmt": "2026-05-30 06:03:32 PM",
"time_taken": "16 sec",
"payer_name": "Jean Mugisha",
"payer_phone": "250788123456",
"mode": "live",
"transaction_id": "VP86583387",
"merchant": "VONSUNG",
"external_id": "ORDER_1001"
}
MTN Mobile Money: FAILED, timeout, ACCEPTED
{
"status_code": 202,
"status": "FAILED",
"message": "Transaction failed.",
"transaction_id": "VP86583387",
"merchant": "VONSUNG",
"mtn_status": "FAILED"
}
{
"status": "timeout",
"message": "Transaction still PENDING after 5 minutes.",
"transaction_id": "VP86583387",
"merchant": "VONSUNG",
"last_known_status": "PENDING"
}
{
"status_code": 200,
"status": "ACCEPTED",
"message": "Payment request sent to MTN Rwanda. The final status will be sent to your webhook.",
"integration_type": "ASYNC",
"transaction_id": "VP86583387",
"external_id": "ORDER_1001",
"merchant": "VONSUNG"
}
Errors
{
"status": "error",
"message": "Invalid request data.",
"errors": {
"external_id": [
"external_id must be unique."
]
}
}
PENDING, ACCEPTED) or completed (SUCCESSFUL).FAILED).external_id. Details are in errors./auth/ or /auth/refresh/.timeout). Check the status later.Check Payment Status
Get the current status of a payment, refund or transfer. Poll this endpoint if you don't use webhooks, or use it to double-check a webhook.
Headers
| Header | Description | |
|---|---|---|
apiUser | required | Your API user |
apiKey | required | Your API key |
Content-Type | required | application/json (POST only) |
No bearer token is needed for this endpoint.
Parameters
Send exactly one of these: in the JSON body for POST, or in the query string for GET.
| Parameter | Type | Description |
|---|---|---|
transaction_id | string | The V-Pay ID returned by /pay/, e.g. VP86583387. |
external_id | string | Your own reference, as sent to /pay/. |
curl --location 'http://vonsung.rw/api/transaction/status/' \ --header 'apiUser: your_api_user' \ --header 'apiKey: your_api_key' \ --header 'Content-Type: application/json' \ --data-raw '{"transaction_id": "VP86583387"}' # or curl --location 'http://vonsung.rw/api/transaction/status/?external_id=ORDER_1001' \ --header 'apiUser: your_api_user' \ --header 'apiKey: your_api_key'
{
"status": "SUCCESSFUL",
"type": "Payment",
"mode": "live",
"transaction_id": "VP86583387",
"external_id": "ORDER_1001",
"amount": "5000.00",
"amount_rwf": "5000.00",
"net_amount": "4850.00",
"currency": "RWF",
"fee": "150.0",
"payment_method": "mtnrw",
"payer_name": "Jean Mugisha",
"payer_phone": "250788123456",
"payer_email": "jean@example.rw",
"description": "Order 1001",
"transaction_date": "2026-05-30 18:03:32",
"merchant": "VONSUNG",
"disputed": false
}
Refunds (type: Refund) and transfers (type: Transfer) are returned the same way, with their own fields.
Status values
| status | Meaning |
|---|---|
PENDING | Created; waiting for the customer to approve or pay. |
SUCCESSFUL | Paid. The money is in your V-Pay balance. |
FAILED | Declined, cancelled, timed out at the provider, or insufficient funds. |
A payment under dispute keeps its status and has disputed: true. A refund is its own record with type: Refund.
Errors
Errors from this endpoint have status set to the HTTP reason and a message:
{
"status": "Not Found",
"message": "No transaction, transfer, or refund found with the provided ID."
}
transaction_id and external_id, a missing header, or live/sandbox keys that don't match the account or the transaction.Payment Links
Create shareable payment pages programmatically. Useful for e-commerce, invoicing, or collecting payments via WhatsApp or email.
Headers: Authorization: Bearer <access>, apiUser, apiKey and Content-Type: application/json.
Body parameters
| Parameter | Type | Description |
|---|---|---|
title required | string | Name shown on the payment page. |
amount | number | Amount to pay. Required when fixed_amount is true. |
fixed_amount optional | boolean | true (default): the payer pays amount. false: the payer enters the amount. |
currency optional | string | Default RWF. |
link_type optional | string | multiple (default, reusable) or oneoff (single payer). |
payer_name, payer_email | string | Required for oneoff links. |
description optional | string | Shown on the payment page. |
payment_method optional | string | all (default), mtnrw or card. |
success_url optional | string | Where the payer goes after paying. |
expires_at optional | string | ISO 8601, e.g. 2026-12-31T23:59:59. |
max_uses optional | integer | Stop accepting payments after this many. |
curl --location 'http://vonsung.rw/api/payment_links/create/' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cxxxxx' \ --header 'apiUser: your_api_user' \ --header 'apiKey: your_api_key' \ --header 'Content-Type: application/json' \ --data-raw '{"title": "Monthly fee (June)", "amount": 10000, "currency": "RWF", "link_type": "multiple"}'
{
"status": "success",
"slug": "kV3n9xQe2LwA8pTz",
"url": "http://vonsung.rw/pay/kV3n9xQe2LwA8pTz/",
"title": "Monthly fee (June)",
"sandbox": false
}
Errors use the same shape as /pay/: {"status": "error", "message": …} with HTTP 400, 401 or 403.
Webhooks
Webhooks push payment events to your server as they happen, so you don't need to poll.
Add destinations in Dashboard → Settings → API → Webhook. You can have up to 10, each with its own URL, secret and list of events, so for example your shop can receive payments and your accounting system only refunds and payouts. Each destination receives events for all your payments (there is no per-payment callback URL). From the same page you can send a test event, see every delivery with your server's response, and resend one.
What V-Pay sends
A POST with a JSON body. The event name is both in the X-VPay-Event header and in the body's event field.
| Header | Example | Meaning |
|---|---|---|
Content-Type | application/json | |
X-VPay-Event | payment.successful | The event name. |
X-VPay-Signature | sha256=5f2b… | sha256= followed by the HMAC-SHA256 of the raw body, keyed with your webhook secret. |
X-VPay-Delivery | 1842 | The delivery ID. It stays the same on automatic retries, so use it to ignore an event you already processed. |
X-VPay-Attempt | 1 | Which attempt this is (1 to 6). |
X-VPay-Merchant | VONSUNG | Your business name. |
User-Agent | VPay-Webhook/1.0 |
{
"event": "payment.successful",
"transaction_id": "VP86583387",
"external_id": "ORDER_1001",
"status": "SUCCESSFUL",
"amount": "5000.00",
"amount_rwf": "5000.00",
"currency": "RWF",
"fee": "150.0",
"payment_method": "mtnrw",
"payer_name": "Jean Mugisha",
"payer_email": "jean@example.rw",
"payer_phone": "250788123456",
"description": "Order 1001",
"merchant": "VONSUNG",
"timestamp": "2026-05-30 18:03:33.812004+00:00"
}
{
"event": "transfer.successful",
"transfer_id": "VPT1A2B3C4D5E6",
"external_id": "PAYOUT_77",
"status": "SUCCESSFUL",
"amount": "20000.00",
"currency": "RWF",
"fee": "200.0",
"net_amount": "19800.00",
"transfer_method": "mtnrw",
"recipient_name": "Aline Uwase",
"recipient_phone": "250788000111",
"merchant": "VONSUNG",
"timestamp": "2026-05-30 18:10:02.114233+00:00"
}
Event types
| Event | When |
|---|---|
payment.successful | The customer paid. The money is in your V-Pay balance. |
payment.failed | The payment was declined, cancelled or failed. |
payment.pending | The payment was created and is waiting for the customer. |
payment.refunded | A refund to the customer completed. |
transfer.successful | A payout from your balance was delivered. |
transfer.failed | A payout failed. |
"test": true) are not retried.Verifying webhook signatures
Compute the HMAC-SHA256 of the raw request body with your webhook secret and compare it with the part of X-VPay-Signature after sha256=. Reject the request if they differ.
import hmac, hashlib def verify_webhook(raw_body, header, secret): expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, header or "") # Django view if not verify_webhook(request.body, request.headers.get("X-VPay-Signature"), WEBHOOK_SECRET): return HttpResponse(status=401) event = json.loads(request.body) # event["event"], event["transaction_id"], event["status"] …
const crypto = require("crypto"); function verifyWebhook(rawBody, header, secret) { const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex"); const a = Buffer.from(expected), b = Buffer.from(header || ""); return a.length === b.length && crypto.timingSafeEqual(a, b); } // Express: app.post("/webhooks/vpay", express.raw({ type: "application/json" }), handler) if (!verifyWebhook(req.body, req.headers["x-vpay-signature"], process.env.WEBHOOK_SECRET)) { return res.status(401).send("Unauthorized"); }
$raw = file_get_contents('php://input'); $expected = 'sha256=' . hash_hmac('sha256', $raw, $webhookSecret); if (!hash_equals($expected, $_SERVER['HTTP_X_VPAY_SIGNATURE'] ?? '')) { http_response_code(401); exit; } $event = json_decode($raw, true);
SDKs & Libraries
Official client libraries to get up and running faster. Each SDK wraps the REST API with idiomatic methods and built-in error handling.
Error Codes
Errors return a JSON body with status and message. Validation errors from /pay/ add an errors object with the problem for each field. Use the HTTP status code to decide what to do.
{
"status": "error",
"message": "Invalid request data.",
"errors": {
"payment_method": [
"Payment method 'card' is not enabled for your account. Available: mtnrw."
]
}
}
| HTTP | What to do | Meaning |
|---|---|---|
| 400 | Fix the request | Missing or invalid parameters (see errors), duplicate external_id, amount outside your limits, unsupported currency or method. |
| 401 | Get a new token | Missing, invalid or expired token. |
| 403 | Check keys and settings | Wrong credentials, live/sandbox mismatch, blacklisted customer, or a live request from a source that isn't approved (SOURCE_NOT_APPROVED: register your IP address or domain, see Approved IP addresses and domains). |
| 404 | Check the ID | Unknown transaction (status check). |
| 429 | Slow down, retry | Too many requests. |
| 5xx | Retry with backoff | V-Pay or the payment provider is unavailable. |
Rate Limits
V-Pay applies rate limits per API key to ensure stability for all users.
| Plan | Requests / minute | Requests / day |
|---|---|---|
| Starter | 20 req/min | 1,000 req/day |
| Growth | 120 req/min | 50,000 req/day |
| Enterprise | Custom | Custom |
Rate limit headers are returned on every response:
X-RateLimit-Limit: 120 X-RateLimit-Remaining: 118 X-RateLimit-Reset: 1716471600
Changelog
/pay/ parameters and responses, and documented the status check parameters, the webhook body and headers, and the payment links endpoint. Added POST /auth/refresh/, and GET support for /transaction/status/.