Mpesa.SDK 1.0.1

.NET Standard 2.0
NuGet\Install-Package Mpesa.SDK -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Mpesa.SDK --version 1.0.1
<PackageReference Include="Mpesa.SDK" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mpesa.SDK --version 1.0.1
#r "nuget: Mpesa.SDK, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mpesa.SDK as a Cake Addin
#addin nuget:?package=Mpesa.SDK&version=1.0.1

// Install Mpesa.SDK as a Cake Tool
#tool nuget:?package=Mpesa.SDK&version=1.0.1

Mpesa.SDK

Mpesa.SDK is a Library for .NET that implements the Daraja API which is documented at Safaricom. It creates a simple interface that can be used to call the M-Pesa API.

.NET Usage

Installation

PM> Install-Package Mpesa.SDK

Usage

Create an MpesaApiOptions
var options = new MpesaApiOptions
{
  ShortCode = "",
  Initiator = "",
  InitiatorPassword = "",
  PassKey = "",
  IsLive = true,
  QueueTimeOutURL = "",
  ResultURL = ""
};
Create the api
var api = new MpesaApi("<Consumer Key>", "<Consumer Secret>", options);
Start making calls

Query the account balance

var balance = await api.Account.QueryBalance();
if (!balance.Success)
  Console.WriteLine(balance.Error.ErrorMessage);

Query Transaction Status

var transaction = await api.Account.QueryTransactionStatus("OJ68HHO4H", IdentifierTypeEnum.Organization);
if (!transaction.Success)
 Console.WriteLine(transaction.Error.ErrorMessage);

Reverse Transaction

var reverse = await api.Account.RequestReversal("OIT8YS6I8Y", "850", "Accounting error");
if (!reverse.Success)
 Console.WriteLine(reverse.Error.ErrorMessage);

STK Push

var stkQuery = await api.LipaNaMpesa.QueryStatus("ws_CO_30102020004040278972");
if (!stkQuery.Success)
 Console.WriteLine(stkQuery.Error.ErrorMessage);
 
Console.WriteLine(stkQuery.Data.CheckoutRequestID);

B2C Send Money

var b2c = await api.B2CClient.SendMoney("254722000000", "1000");
if (!b2c.Success)
 Console.WriteLine(b2c.Error.ErrorMessage);
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Mpesa.SDK:

Package Downloads
Mpesa.SDK.AspNetCore

This is a M-PESA SDK to allow you to integrate Safaricom Daraja API for ASP.Net Core. It relies on Apesa.SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 389 11/3/2020
1.0.0 315 10/31/2020