Master Safaricom Daraja API with PHP and JavaScript

Master Safaricom Daraja API with PHP and JavaScript

Stop struggling with M-Pesa integrations. Start building them.

Free preview

Watch Episode 1 before you pay

This is the first lesson of the course, in full. No account and no payment needed.

The other 12 chapters open the moment you enroll.

Course table of contents

01EP1. Free preview: start hereFree preview

Episode 1 of the course, free to watch before you buy. Watch it first, then decide if the full twelve weeks are right for you.

02Week 1. HTML5, forms and how the web worksLocked

Frontend: HTML5 structure and forms. Backend: how the web and a backend actually work, with PHP basics. Daraja: what M-Pesa and the Daraja API are. Project: build a simple business website.

03Week 2. CSS3, responsive design and your first serverLocked

Frontend: CSS3 and responsive design. Backend: server concepts, HTTP and APIs, handling requests in PHP. Daraja: the developer portal and the sandbox. Project: a responsive business landing page.

04Week 3. JavaScript fundamentals, PHP and Node.jsLocked

Frontend: JavaScript fundamentals. Backend: PHP and JavaScript side by side, then Node.js setup and fundamentals. Daraja: authentication concepts. Project: an interactive frontend.

05Week 4. DOM, events, forms and your first backend APILocked

Frontend: the DOM, events and forms. Backend: Express.js and routing. Daraja: getting your Daraja credentials. Project: a frontend talking to your first backend API.

06Week 5. Fetch, JSON and REST APIsLocked

Frontend: fetch and AJAX, working with JSON. Backend: REST APIs. Daraja: OAuth and access tokens. Project: connect the frontend to the backend.

07Week 6. UI components, databases and STK Push conceptsLocked

Frontend: modern JavaScript and UI components. Backend: database fundamentals. Daraja: STK Push concepts and the request you are about to send. Project: a payment initiation system.

08Week 7. Project structure, CRUD and STK Push implementationLocked

Frontend: project structure that holds together past one file. Backend: CRUD operations. Daraja: implementing STK Push for real. Project: customer and payment records.

09Week 8. Authentication UI and callback URLsLocked

Frontend: building the authentication UI. Backend: user authentication. Daraja: callback URLs and what arrives when Safaricom calls you back. Project: login plus payment flow.

10Week 9. Dashboards, security and payment statusLocked

Frontend: dashboard design. Backend: authorization and security. Daraja: payment status handling, from pending to paid to failed. Project: an admin dashboard.

11Week 10. Optimization, deployment and going liveLocked

Frontend: optimization. Backend: deployment and environment variables. Daraja: production considerations before you take real money. Project: deploy your full-stack application.

12Week 11. Final project and advanced Daraja integrationLocked

Frontend: final project development. Backend: final project development. Daraja: advanced Daraja integration. Project: a complete M-Pesa application.

13Week 12. Polish, testing and presentationLocked

Frontend: final polish. Backend: testing and debugging. Daraja: testing payment flows end to end. Project: final project and presentation.

What you will learn

You will build a working M-Pesa payment system, from the first page a customer lands on to the callback that tells your app the money arrived.

  • A storefront that takes an order and fires an M-Pesa prompt at the customer
  • A backend that authenticates against the Daraja API with OAuth 2.0
  • STK Push, callback handling and payment status tracking
  • A database of customers, orders and payments
  • An admin view showing what was paid and what failed

You build it in PHP and JavaScript, because both jobs get done in Kenyan agencies. PHP for the classic sites that already carry the business, JavaScript for the modern API layer.

How the twelve weeks are built

Three tracks run in parallel, and every week ends with a project that runs.

Frontend HTML5 and CSS3 first, then JavaScript, the DOM, forms, fetch and JSON, UI components, authentication screens, dashboards and optimization.

Backend PHP at the start so the fundamentals land, then Node.js and Express, REST APIs, databases, CRUD, authentication, authorization, deployment, environment variables and testing.

Daraja The developer portal and sandbox, getting your credentials, OAuth access tokens, what an STK Push really does, implementing it, callback URLs, payment status handling, what changes when you go live, and testing payment flows end to end.

The twelve weeks, phase by phase

Weeks 1 to 3, the foundations HTML5 structure and forms, CSS3 and responsive design, JavaScript fundamentals. On the server, how the web works, PHP basics, HTTP and APIs, then Node.js setup. On the Daraja side, what M-Pesa and Daraja are, the developer portal and the sandbox. Projects: a business website, a responsive landing page and an interactive frontend.

Weeks 4 to 6, your first API and your first payment The DOM, events and forms, Express routing, REST APIs, database fundamentals, modern JavaScript and UI components. Then the Daraja part that matters: your credentials, OAuth access tokens and STK Push concepts. Projects: a frontend talking to a backend, then a payment initiation system.

Weeks 7 to 9, the full payment flow Frontend project structure, authentication UI, user authentication, authorization and dashboard design. On the Daraja side, implementing STK Push for real, callback URLs and payment status handling. Projects: customer and payment records, a login plus payment flow, and an admin dashboard.

Weeks 10 to 12, shipping it Optimization, deployment, environment variables, final project work, testing and debugging, and presentation. Daraja production considerations, advanced integration and testing payment flows. You deploy the full-stack application, complete your M-Pesa application and present the finished project.

Who is this course for?

  • PHP developers who now need to take M-Pesa payments
  • JavaScript and Node.js developers adding payments to an existing app
  • Freelancers and agencies building payment pages for Kenyan clients
  • Anyone who has copied Daraja code from a blog and still does not know what arrives on the callback

What you need

  • A laptop and a browser. Nothing exotic.
  • An M-Pesa phone number for the payment steps, yours or a test one.
  • A Safaricom Daraja developer account. Week 4 walks you through getting one, and you can apply while you follow the course.
  • Basic programming sense. You should have written a function before. You do not need to be a senior engineer.

How access works

  1. Pay once with M-Pesa at checkout.
  2. Sign in or create an account with the same email address.
  3. Every lesson opens on the course page and stays open. Come back to week 7 whenever you need it.

There are no live sessions to attend and nothing to renew. Episode 1 is free, so you can judge the teaching before you pay.

Questions people ask

Do I need to know PHP already? No. Week 1 introduces PHP from zero. If you already write PHP you will move faster, but you will not be lost.

Is this live or recorded? Recorded video lessons. Watch them in order, pause, and repeat the part you need.

Do I get the source code? You write it. Each lesson walks through the code for that step, and every week ends with a project that runs.

How long do I have access? Your account keeps the lessons for as long as the site is running. There is no expiry date on your purchase.

What if I am not ready for the Daraja account? Week 4 is dedicated to your credentials and the sandbox. You can follow the whole course before your production credentials are approved.

What happens if my M-Pesa payment does not go through? You see it on the checkout page straight away and you can retry. Nothing is delivered until the payment confirms.

Still deciding?

Start with Episode 1. It is free and it is the same teaching you get in the paid weeks.

If you would rather talk it through first, WhatsApp us on 0740 408 496.

ENROLL IN THE COURSE

This is independent developer education and is not an official Safaricom training programme.