M-Pesa STK Push

How to trigger M-Pesa STK push directly without generating a link.

You might want to trigger the M-Pesa STK push directly to the user i.e without introducing additional steps e.g redirecting the user to a URL. With this request, the user gets then M-Pesa prompt to enter their PIN and completes the transaction.

Below is a code example on how to send M-Pesa STK Push.

from intasend import APIService

publishable_key = "INTASEND_PUBLISHABLE_KEY"

service = APIService(publishable_key=publishable_key)

response = service.collect.mpesa_stk_push(phone_number=2547...,
                                  email="[email protected]", amount=10, narrative="Purchase")
use IntaSend\IntaSendPHP\Collection;

$collection = new Collection();

$response = $collection->create(currency="KES", method="M-PESA",amount=10, phone_number="254723...", email="[email protected]", api_ref="order-1");
const IntaSend = require("intasend-node")

let intasend = new IntaSend(
  test_mode=true // set to false when going live

let collection = intasend.collection();
        first_name: 'Joe',
        last_name: 'Doe',
        email: '[email protected]',
        host: 'https://yourwebsite.com',
        amount: 10,
        phone_number: '254722000000',
        api_ref: 'test',
  .then((resp) => {
    // Redirect user to URL to complete payment
     console.log(`STK Push Resp: ${resp}`);
  .catch((err) => {
     console.error(`STK Push Resp error: ${err}`);