Merchants
Setting up to accept payments
Create your application, its keys and webhook, choose where the money goes, and connect your own M-Pesa, e-Mola or card account.
A merchant accepts payments through an application: one website, app or till, in one mode. Its keys, its webhook endpoint and the provider accounts it may use all belong to it, so two applications of the same business never mix.
Where the money goes depends on your arrangement with KulPay:
- Your own provider account (direct). You connect your own M-Pesa, e-Mola or card acquirer account; customers' money lands there. KulPay records the payments and its fees.
- Through KulPay (collecting or managed). KulPay's provider accounts take the money and KulPay settles it to your approved account on a schedule, less fees. No provider contract of your own is needed.
- KulPay balance. Customers pay from their KulPay wallet; the money reaches your KulPay business account at once.
If you use the KulPay app, it does every step of this page for you: see Setting up in the KulPay app.
Before you start
Your KulPay business account and a key with keys:manage (and connectors:write to connect your own provider account), from your onboarding.
The flow at a glance
| # | Who | What happens |
|---|---|---|
| 1 | Your team | Creates the application for one website or app, in test mode first. |
| 2 | Your team | Issues the application's key and registers its webhook endpoint. |
| 3 | Your team | Connects your own provider account through KulPay's secure credentials page, when you take money directly. |
| 4 | Your team | Repeats in live mode once the integration is tested. |
1. Create the application
Your team.
POST /v1/merchant-applications · API reference
One per website, app or till, per mode. external_ref is your own reference: creating with the same one again returns the existing application.
Request
{
"mode": "test",
"name": "Online shop",
"external_ref": "shop-web"
}
Response
{
"id": "3KUXQ43bztiuf9tCMNgbcrYvne3",
"object": "merchant_application",
"account_id": "3KUXPz8rTq1Lm2Nb4Vc6Xs7Za9e",
"mode": "test",
"name": "Online shop",
"external_ref": "shop-web",
"status": "active",
"created_at": "2026-10-22T09:30:00Z",
"updated_at": "2026-10-22T09:30:00Z"
}
2. Issue the application's key
Your team.
POST /v1/api-keys · API reference
With application_id, every request made with the key is that application's: its payments, its webhooks, its limits. Give it only the scopes your server needs.
Request
{
"name": "Online shop server",
"type": "rk",
"scopes": [
"payments:read",
"payments:write",
"refunds:write"
],
"application_id": "3KUXQ43bztiuf9tCMNgbcrYvne3"
}
3. Register the application's webhook
Your team.
POST /v1/webhook-endpoints · API reference
With application_id, the endpoint receives only that application's payment events. Store the signing secret from the answer. See Receiving webhooks.
Request
{
"url": "https://shop.example.co.mz/kulpay/webhooks",
"event_types": [
"payment.*",
"refund.*"
],
"application_id": "3KUXQ43bztiuf9tCMNgbcrYvne3"
}
4. Connect your own provider account
Your team, when customers' money should land in your own M-Pesa, e-Mola or card account.
POST /v1/connector-sessions · API reference
Opens a short, single-use session on KulPay's secure credentials page. Send the person who holds the provider credentials to its url: they type them there, straight to KulPay, and they are encrypted at once. KulPay (and the KulPay app, when you use it) never sees them. fields names the credentials the page asks for (leave it out for M-Pesa, e-Mola and Stripe: the page then asks for that provider's own, one field each, and KulPay adds the provider's address and timeout); allowed_application_ids limits the account to your application.
Request
{
"mode": "live",
"method": "mpesa",
"driver": "mpesa",
"label": "Shop M-Pesa 8812345",
"fields": [
"api_key",
"public_key",
"service_provider_code"
],
"allowed_application_ids": [
"3KUXQ43bztiuf9tCMNgbcrYvne3"
],
"ttl_seconds": 900
}
Response
{
"id": "3KUXR7nM4kQp2Xc9VbT1wYz5LhG",
"object": "connector_session",
"mode": "live",
"method": "mpesa",
"driver": "mpesa",
"label": "Shop M-Pesa 8812345",
"fields": [
"api_key",
"public_key",
"service_provider_code"
],
"status": "open",
"expires_at": "2026-10-22T09:45:00Z",
"token": "kcs_…",
"url": "https://gateway.kulpay.pavulla.com/connector-setup?token=kcs_…"
}
The credentials each method needs: M-Pesa api_key, public_key, service_provider_code; e-Mola username, password, key, partner_code, service_provider_code; card secret_key, webhook_secret.
5. Check the connection
Your team.
GET /v1/connector-sessions/{id} · API reference
completed once the credentials were saved, with the binding_id of the connected account; expired if nobody used the page in time (open a new one).
States
| State | What it means |
|---|---|
open | The credentials page is waiting. |
completed | The credentials are saved and checked; the account is connected. |
expired | Not used in time. Open a new session. |
Events
| Event | What it tells you |
|---|---|
config.merchant_application.created | An application was created. |
credential.connector_session.completed | Provider credentials were saved through the secure page. |
Errors that matter here
Every error is application/problem+json with a stable code; branch on the code, not the message. The full list is in the error catalogue.
| Error | When | What to do |
|---|---|---|
410 connector_session_expired | The credentials page was opened after the session expired. | Open a new session. |
409 connector_session_used | The session was already used. | Open a new session to change the credentials. |
409 no_connector_binding | A payment needs a provider account the application has none of. | Connect the account, or use KulPay's collection. |
Testing it
Do everything in test mode first: create the application, issue a test key, register a test endpoint. In test mode, payments use simulated providers, so you can test before connecting real credentials.