KulmiPay Python SDK
Python SDK for the KulmiPay API. Use it to create hosted checkout sessions, collect M-Pesa and PesaLink payments, send payouts, manage wallets, and create or retrieve refunds.
Install
pip install kulmipay
Configure
Use sandbox credentials with sandbox=True while testing. Use live credentials with the default live host.
from kulmipay import APIService
service = APIService(
token="ISSecretKey_live_xxxxxxxxxxxxxxxx",
publishable_key="ISPubKey_live_xxxxxxxxxxxxxxxx",
)
sandbox_service = APIService(
token="ISSecretKey_test_xxxxxxxxxxxxxxxx",
publishable_key="ISPubKey_test_xxxxxxxxxxxxxxxx",
sandbox=True,
)
For self-hosted deployments, pass base_url:
service = APIService(
token="YOUR_SECRET_KEY",
publishable_key="YOUR_PUBLIC_KEY",
base_url="https://payments.example.com/api/v1",
)
Checkout
checkout = service.collect.checkout(
amount=1500,
currency="KES",
email="customer@example.com",
phone_number="254712345678",
api_ref="ORDER-1001",
redirect_url="https://merchant.example/thank-you",
unique_api_ref=True,
)
print(checkout["url"])
M-Pesa STK Push
response = service.collect.mpesa_stk_push(
phone_number="254712345678",
amount="1500.00",
api_ref="ORDER-1001",
mobile_tarrif="BUSINESS-PAYS",
)
invoice_id = response["invoice"]["invoice_id"]
PesaLink Collection
response = service.collect.pesalink(
amount="5000.00",
api_ref="ORDER-BANK-1001",
email="customer@example.com",
first_name="Jane",
last_name="Doe",
bank_tarrif="BUSINESS-PAYS",
)
Payment Status
status = service.collect.status(invoice_id=invoice_id)
print(status)
Send Money
transactions = [
{
"name": "Jane Doe",
"account": "254712345678",
"amount": "1000",
"narrative": "Refund",
"idempotency_key": "refund-1001",
}
]
file = service.transfer.mpesa(
currency="KES",
transactions=transactions,
requires_approval="YES",
)
approval = service.transfer.approve({
"tracking_id": file["tracking_id"],
"transactions": file["transactions"],
})
status = service.transfer.status(file["tracking_id"])
Supported providers:
| Method | Provider |
|---|---|
service.transfer.mpesa(...) |
MPESA-B2C |
service.transfer.mpesa_b2b(...) |
MPESA-B2B |
service.transfer.bank(...) |
PESALINK |
service.transfer.p2p(...) |
P2P |
Wallets
wallets = service.wallets.retrieve()
wallet = service.wallets.create(
currency="KES",
label="Payroll Wallet",
can_disburse=True,
)
transactions = service.wallets.transactions(wallet["wallet_id"])
Refunds
Refunds use the chargebacks endpoint internally.
refund = service.refunds.create(
invoice_id="GQ7KZ2XPNM",
amount="1500.00",
reason="Duplicate payment",
)
refunds = service.refunds.retrieve()
one_refund = service.refunds.details(refund["chargeback_id"])
Error Handling
The SDK raises KulmiPayBadRequest, KulmiPayUnauthorized, KulmiPayNotAllowed, or KulmiPayServerError for common API errors.
Metadata
Release files for kulmipay 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kulmipay-1.0.0.tar.gz | 9.2 kB | Without provenance | Details for kulmipay-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kulmipay-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for kulmipay-1.0.0-py3-none-any.whl |
Total release size: 17.8 kB
Release files / kulmipay-1.0.0.tar.gz
| Download URL | kulmipay-1.0.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1551dd408cae81bde9c58b695d0568bc2dc0a2fb5d47058698d57b184ae790ec
|
|
BLAKE2b-256 checksum How to use checksums |
96ca90f898c2eac0d4498e0ab42579ef20ac3f2f3c0c499aeded022fada56590
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / kulmipay-1.0.0-py3-none-any.whl
| Download URL | kulmipay-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81cec1ed151bebadd282f8a9ca5b5891fb57dca02cb14bcc21b03336a6391cc6
|
|
BLAKE2b-256 checksum How to use checksums |
a3168da7cb35a333838a90a43d733461771d30036fe1fdf98631e95be4097033
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for kulmipay 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.