What it is
Everything needed to add Pesapal payments (M-Pesa, Airtel Money, Visa, MasterCard) to a PHP site or system in Kenya and East Africa, and to get it right. The integration is small, but mistakes with money are expensive, and the documentation and the sandbox disagree in a few places that matter.
You can use it two ways: as a skill that an AI coding assistant follows, or by taking the PHP client and examples and wiring them in yourself.
What is inside
- scripts/PesapalClient.php: one framework-free class. Token caching, registering the notification address, submitting an order, checking a transaction, refunds and cancellations, with typed errors.
- scripts/: a payments table, working examples of the notification and return pages, a reconciliation job, a self test, and a smoke test against the real sandbox.
- references/: the API distilled from Pesapal's documentation, notifications and callbacks, refunds, recurring payments, the point-of-sale API, testing, and a list of errors and traps.
- SKILL.md: the method, written for an AI coding assistant.
How to use it
- Unzip the download. You get one folder,
pesapal-payments-php. - As a skill for Claude Code: put the folder in
.claude/skills/in your project. Then ask, for example: "Add Pesapal checkout to this shop." - Or by hand: copy
scripts/PesapalClient.phpandscripts/schema.sqlinto your project and followscripts/example_bootstrap.php. - Use your own sandbox keys first. Run
scripts/smoke_sandbox.phpto prove the connection before any real money moves.
The one rule that matters
Never mark an order paid because the customer came back to your site. Mark it paid only after your server has asked Pesapal for the transaction status and the answer says completed, for the right amount. The examples do it this way.
Good to know
- Your keys are yours: nothing in the kit sends them anywhere except to Pesapal.
- This is not an official Pesapal product. Check their current documentation before you go live.
- Going live needs your own merchant account and Pesapal's approval of your site.
Version history
- 1.0.0 (14 November 2026): first public release.
