KPay API Docs

Get Started

Welcome to the K-Pay API. This guide will help you integrate KPay into your application for seamless payments.

Item Value
Live Endpoint pay.esicia.rw
Sandbox Endpoint pay.esicia.com
Port 443
Protocol HTTPS

Authentication

API access is granted using Basic Authentication over HTTPS. You must also provide a list of whitelisted IPs from which your application will send requests.

# cURL Example
curl --user "your_username:your_password" https://pay.esicia.com/api/

Supported Payment Methods

The KPay API supports a variety of payment methods to cater to your customers' needs.

MTN Mobile Money
Airtel Money
Visa
MasterCard
SPENN
SmartCash

Payment Request

To initiate a payment, send a POST request with a JSON body to our endpoint. Below are the required and optional parameters.

Parameters

Parameter Severity Type Description
action Required string 'pay' or 'checkstatus'
msisdn Required string Mobile number (e.g., 25078xxxxxxx)
email Required string Customer's email address.
details Required string Payment details/description.
refid Required string Unique payment reference from your system.
amount integer Payment amount in RWF.
currency Optional string 'RWF' or 'USD'. Defaults to 'RWF'.
cname Required string Name of the person paying.
cnumber Required string Customer number at the payment processor.
pmethod Required string 'cc', 'momo', 'bank', 'spenn', 'smartcash'.
retailerid Required string Your unique retailer ID.
returl Required string Postback URL for async response (webhook).
redirecturl Required string URL for redirection after payment.
bankid Required string Financial institution ID (see Bank Codes).
logourl Optional string URL to your logo for the checkout page.

Request Body Example

{
    "msisdn": "0783300000",
    "details": "Order #123",
    "refid": "15947234071471114",
    "amount": 4200,
    "currency": "RWF",
    "email": "customer@example.com",
    "cname": "John Doe",
    "cnumber": "123456789",
    "pmethod": "momo",
    "retailerid": "02",
    "returl": "https://yourdomain.com/api/paymentack",
    "redirecturl": "https://yourdomain.com/payment-success",
    "bankid": "63510"
}

Successful Response (Pending)

{
    "reply": "PENDING",
    "url": "https://pay.esicia.com/checkout/A12343983489",
    "success": 1,
    "authkey": "m43snbf9oivnmersqh6mnllbh5",
    "tid": "E6974831594723691",
    "refid": "15947234071471114",
    "retcode": 0
}

Asynchronous Postback

Once a payment is completed, KPay will send an asynchronous POST request to the returl you provided. Your listener should expect the following data format and respond with a confirmation.

Successful Mobile Money Payment

{
    "tid": "A441489693051",
    "refid": "1489693046",
    "momtransactionid": "616730887",
    "payaccount": "0783300000",
    "statusid": "01",
    "statusdesc": "Successfully processed transaction."
}

Expected Response from Your Server

{
    "tid": "A441489693051",
    "refid": "1489693046",
    "reply": "OK"
}

Check Transaction Status

You can check the status of any transaction by sending a request with the transaction's tid or your refid. We recommend relying on this method over the postback for confirmation.

Request Body

{
    "tid": "A441489693051",
    "refid": "1489693046",
    "action": "checkstatus"
}

Response (Transaction Not Found)

{
    "tid": "",
    "refid": "",
    "momtransactionid": "",
    "statusid": "611",
    "statusdesc": "Transaction not found"
}

KPay Error Codes

These codes represent the status in the retcode (payment request) and statusid (postback) fields.

ID Description
0 No error. Transaction being processed.
01 Successful payment.
02 Payment failed.
03 Pending transaction.
401 Missing authentication header.
500 Non HTTPS request.
600 Invalid username / password combination.
602 Location / IP not whitelisted.
603 Missing required parameters.
608 Duplicate refid used.
611 Transaction not found.

Bank & Institution Codes

Use these codes for the bankid parameter in your payment requests.

Bank ID Bank Name Short Name
040 BANQUE DE KIGALI BK
130 COMPAGNIE GENERALE DE BANQUES COGEBANQUE
63510 MTN MOBILE MONEY MTN MOMO
63514 AIRTEL MONEY AIRTEL MONEY
000 VISA / MASTERCARD CARDS
63502 SPENN SPENN

Test Cards

Use these card numbers for testing in the sandbox environment.

Mastercard

Card Number Type
5101 1800 0000 0007 Commercial Credit
5555 4444 3333 1111 Consumer
2222 4000 6000 0007 Debit

Visa

Card Number Type
4988 4388 4388 4305 Classic
4111 1111 1111 1111 Consumer
4000 1600 0000 0004 Debit