Core API
Payment Links
Create shareable URLs for collecting M-Pesa payments without writing server code.
Create a Payment Link (API)
Create a checkout session and get a shareable payment link:
bash
curl -X POST "https://paynexus.co.ke/api/checkout/sessions" \
-H "X-API-Key: sk_your_secret_key_here" \
-H "Content-Type: application/json" \
-d '{
"amount": 100,
"description": "Consulting services - June 2026",
"reference": "INV-2026-001",
"return_url": "https://yoursite.com/thanks",
"cancel_url": "https://yoursite.com/cancelled"
}'
Response
json
{
"success": true,
"data": {
"session_id": "cs_live_abc123...",
"checkout_url": "https://paynexus.co.ke/checkout/s/cs_live_abc123...",
"expires_at": "2026-06-21T21:25:00+03:00"
}
}
Hosted Checkout URL Parameters
Generate a direct checkout link without creating a session first:
text
https://paynexus.co.ke/checkout/pay/ACC_ZVTDYYYL?amount=100&description=Invoice+Payment&return_url=https://yoursite.com/thanks
| Parameter | Required | Description |
|---|---|---|
amount |
Yes | Payment amount in KES |
description |
No | Payment description |
return_url |
No | Redirect after successful payment |
cancel_url |
No | Redirect after cancelled/failed payment |
Payment Page Links
Use pre-configured payment pages created in the dashboard:
text
https://paynexus.co.ke/pay/your-page-slug
With optional invoice parameter:
text
https://paynexus.co.ke/pay/your-page-slug?invoice=INV-2026-001
Browser SDK Integration
Add hosted checkout without exposing API keys:
html
Payment Link Features
Custom Branding
Set logo, colors, and business name for a branded checkout experience.
Fixed or Open Amounts
Pre-set prices or let customers enter their own amount.
Expiration
Set expiry dates for payment pages and links.
Custom Fields
Collect additional customer information during checkout.
Invoice Integration
Link payment pages to specific invoices for automatic reconciliation.
Redirect Parameters
After payment, customers are redirected with these query parameters:
text
?reference=PNXABC123&status=completed&amount=100&session_id=cs_live_abc123
| Parameter | Description |
|---|---|
reference | Unique PayNexus payment reference |
status | Payment status (completed, failed, cancelled) |
amount | Payment amount in KES |
session_id | Checkout session ID |