← Back to Skills Marketplace
nevilpaulo

M-Pesa Daraja

by Nevil Paul · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
75
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install mpesa-daraja
Description
Build, review, test, or explain Safaricom M-Pesa Daraja API integrations for STK Push/Lipa na M-Pesa Online, C2B validation and confirmation, B2C payouts, tr...
README (SKILL.md)

M-Pesa Daraja

Operating Rules

  • Treat this as a payment-integration skill, not permission to move money.
  • Default to Daraja sandbox endpoints and test credentials unless the user explicitly asks for production guidance.
  • Never store consumer secrets, passkeys, initiator passwords, security credentials, access tokens, callback payloads with phone numbers, or transaction IDs in committed files.
  • Ask before calling any live/production endpoint or sending any request that could trigger a payment prompt, payout, reversal, or customer-facing callback.
  • Prefer environment variables and secret managers over `.env` files in shared repos. If `.env.example` is needed, use placeholder values only.
  • Make callbacks idempotent: verify request shape, persist raw event safely, deduplicate by CheckoutRequestID/ConversationID/TransactionID, then process business state transitions.

Workflow

  1. Identify the payment flow:
    • STK Push / Lipa na M-Pesa Online for customer-initiated checkout.
    • C2B for paybill/till customer payments with validation and confirmation callbacks.
    • B2C for business payouts to customers or agents.
    • Transaction Status / Reversal for reconciliation and recovery.
  2. Confirm runtime context: language/framework, sandbox vs production, callback URL availability, persistence layer, and compliance constraints.
  3. Design the integration around these boundaries:
    • token generation and caching
    • request signing/password generation
    • outbound Daraja client
    • callback receiver
    • idempotency/reconciliation
    • observability without leaking personal or payment data
  4. Use `references/examples.md` when the user asks for sample OpenClaw prompts, implementation examples, or architecture snippets.
  5. Use `references/test-cases.md` when the user asks for QA scenarios, unit tests, integration tests, sandbox tests, or production-readiness checks.
  6. Use `scripts/validate_daraja_fixture.py` to sanity-check example STK Push request and callback JSON fixtures before writing tests around them.

Implementation Guidance

  • Keep Daraja client code small and injectable so app tests can mock HTTP calls.
  • Generate the STK password as `base64(shortcode + passkey + timestamp)` with timestamp format `YYYYMMDDHHmmss`.
  • Use OAuth access tokens from Daraja and cache them until shortly before expiry.
  • Expose public HTTPS callback URLs in sandbox using a stable tunnel or deployed test environment; avoid local-only callback URLs.
  • Return fast from callbacks after durable persistence; do heavier fulfillment asynchronously when possible.
  • Log correlation IDs, response codes, and internal order IDs. Mask phone numbers, names, access tokens, credentials, and raw security credentials.
  • Model payment state explicitly, for example: `pending`, `prompt_sent`, `paid`, `failed`, `cancelled`, `expired`, `reversed`, `manual_review`.

Common OpenClaw Requests

  • "Use $mpesa-daraja to add STK Push checkout to this Django app."
  • "Use $mpesa-daraja to write sandbox test cases for our M-Pesa checkout."
  • "Use $mpesa-daraja to review this Daraja callback handler for idempotency and secret leakage."
  • "Use $mpesa-daraja to create an OpenClaw automation that drafts M-Pesa reconciliation reports without touching production APIs."

Deliverables To Prefer

  • For implementation: client module, callback route, typed request/response models, masked logging, tests, and `.env.example`.
  • For review: findings ordered by payment risk, security risk, idempotency/reconciliation risk, then code quality.
  • For planning: flow diagram in text, endpoint list, secret list, callback contract, test plan, and production checklist.
  • For troubleshooting: exact failing step, expected Daraja response, likely causes, and the smallest safe verification step.
Usage Guidance
Treat this as an incomplete review: the VirusTotal telemetry is clean, but the artifact files were not readable in this run, so installation should wait for a successful artifact inspection.
Capability Tags
cryptocan-make-purchasesrequires-oauth-tokenrequires-sensitive-credentials
Capability Assessment
Purpose & Capability
Not assessable from artifact contents because metadata.json and artifact files could not be read in this run.
Instruction Scope
Not assessable from artifact contents because the supplied files were unavailable to the reviewer due to sandbox execution failure.
Install Mechanism
Not assessable from artifact contents; no install spec evidence was available.
Credentials
Not assessable from artifact contents; no capability or runtime evidence was available.
Persistence & Privilege
Not assessable from artifact contents; no evidence of persistence or privilege behavior was available.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install mpesa-daraja
  3. After installation, invoke the skill by name or use /mpesa-daraja
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release: Safaricom M-Pesa Daraja integration planning, implementation guidance, sandbox testing, callback idempotency checks, and production-readiness review.
Metadata
Slug mpesa-daraja
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is M-Pesa Daraja?

Build, review, test, or explain Safaricom M-Pesa Daraja API integrations for STK Push/Lipa na M-Pesa Online, C2B validation and confirmation, B2C payouts, tr... It is an AI Agent Skill for Claude Code / OpenClaw, with 75 downloads so far.

How do I install M-Pesa Daraja?

Run "/install mpesa-daraja" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is M-Pesa Daraja free?

Yes, M-Pesa Daraja is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does M-Pesa Daraja support?

M-Pesa Daraja is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created M-Pesa Daraja?

It is built and maintained by Nevil Paul (@nevilpaulo); the current version is v1.0.0.

💬 Comments