MPESA


How to integrate

This integration can be completed in 3 easy steps:

1. Collect required data from user

2. Post required data to the endpoint

3. Handle the server response when customer validates payment



Required Parameters
Param Required? Description
enc_key yes Your encryption Key
amount Yes Amount (in the lowest currency value - pesewas or cent) you are debiting customer. Do not skip this when creating subscriptions.
transaction_ref Yes The Transaction Reference is a unique reference generated by the merchant that enables them identify & track transactions internally.
phone Yes Phone number of customer
description Yes Field containing the description you want recorded with the transaction.


Request Sample
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.marasoftpay.live/mobile_money/initiate_payment',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
  'enc_key' => 'MSFT_Enc_MUKYSWE2TZJRQYQFSGM6FWDOPCIRBNF1669977335',
  'amount' => '20',
  'phone' => 'phone number',
  'transaction_ref' => 'transaction reference',
  'description' => 'description'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
    router.get("/generate-dynamic-account", (req,res) => {
    const enc_key = "your encryption key";
    const amount = "amount";
    const transaction_ref = "transaction reference";
    
    const data = { enc_key, amount, transaction_ref };
    
    const url = "https://api.marasoftpay.live/generate_dynamic_account/";
    
    axios
        .post(url,data)
        .then((response) => {
            console.log(response);
        })
        .catch((error)=>{
            console.log(error);
        })
    })
Handling Webhooks

After a payment has been successfully processed, Marasoft Pay will send a webhook notification to the URL that you specify. For more information on how to utilize webhooks, please refer Webhooks section of this documentation