Mpesa Daraja SDK implementation for .net.
For More Info check Safaricom Mpesa Documentation
nugget install
using MpesaSDK.NET.Dtos.InitiateRequests;
using MpesaSDK.NET.Dtos.Responses;
using MpesaSDK.NET.Enums;
...
//http client
using HttpClient client = new() { Timeout = TimeSpan.FromSeconds(10) };
//mpesa client
MpesaClient mpesaClient = new MpesaClient(client, new MpesaClientOptions
{
ConsumerKey = "your-consumerkey",
ConsumerSecret = "your-consumer-secret",
IsSandBox = true /* change this flag to false if Production */
});
var result = await mpesaclient.STKPushAsync(...);
var result = await mpesaclient.StkPushQueryAsync(...);
var result = await mpesaclient.B2CAsync(...);
var result = await mpesaclient.B2BAsync(...);
To get MPesa Security credetials for both B2B and B2C use method below.
string credential = "pass".ToMpesaSecurityCredential();
var result = await mpesaclient.C2BRegisterUrlAsync(...);
var result = await mpesaclient.C2BSimulateTransactionAsync(...);
var result = await mpesaclient.AccountBalanceAsync(...);
var result = await mpesaclient.TransactionStatusAsync(...);
var result = await mpesaclient.ReversalAsync(...);
Check sample callback api MpesaSDK.NET.CallbackAPI
Docs to be updated soon.
Apache LICENSE-2.0 read more