Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ayiemba committed Mar 18, 2019
1 parent 053f4fe commit a5950a0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docfx_project/articles/accountbalance.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ var AccountBalanceObject = new AccountBalanceDto

var accountbalancerequest = await _mpesaClient.QueryAccountBalanceAsync(AccountBalanceObject, accesstoken, RequestEndPoint.QueryAccountBalance); //async method
var accountbalancerequest = await _mpesaClient.QueryAccountBalance(AccountBalanceObject, accesstoken, RequestEndPoint.QueryAccountBalance); //non-async method
var accountbalancerequest = await _mpesaClient.QueryAccountBalance(AccountBalanceObject, accesstoken, RequestEndPoint.QueryAccountBalance); //non-async method - avoid if you can
```
2 changes: 1 addition & 1 deletion docfx_project/articles/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Mpesa APIs require an accesstoken for authentication/authorization to use the AP
//Async
var accesstoken = await _mpesaClient.GetAuthTokenAsync(ConsumerKey, ConsumerSecret, RequestEndPoint.AuthToken);

//Non-Async
//Non-Async (Avoid non-asyn calls if you can)
var accesstoken = await _mpesaClient.GetAuthToken(ConsumerKey, ConsumerSecret, RequestEndPoint.AuthToken);
```

Expand Down
15 changes: 8 additions & 7 deletions docfx_project/articles/roadmap.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
## MpesaLib Roadmap

#### Version 3.1.x (Q1 2019)
- Error handling/logging
- Writing Tests
- Improved Documentation
- [x] Error handling/logging
- [x] Improved Documentation
- [x] Performance improvements


#### Version 3.2.x (Q2 2019)
- Performance improvements
- Web and Mobile Samples
- [ ] Writing Tests
- [ ] Web and Mobile Samples

#### MpesaLib.UI (Q3 2019)
- Configurable ASP.NET Core UI plugin from M-PESA checkout scenarios (A separate Nuget Package)
- [ ] Configurable ASP.NET Core UI plugin from M-PESA checkout scenarios (A separate Nuget Package)

#### MpesaLib.Mobile.UI (Q4 2019)
- Xamarin Forms UI plugins for M-PESA Checkout scenarios (A separate Nuget Package)
- [ ] Xamarin Forms UI plugins for M-PESA Checkout scenarios (A separate Nuget Package)
2 changes: 1 addition & 1 deletion docfx_project/articles/stkpush.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var MpesaExpressObject = new LipaNaMpesaOnlineDto
Passkey = "", //get passkey from daraja
PhoneNumber = "",
TransactionDesc = "test"
//Note that you don't have to provide password and timestamp, these are calculated for you automatically provided you enter passkey.
//Note that you don't have to provide Password and Timestamp, these are calculated for you automatically provided you enter passkey.
};

//Make payment request
Expand Down
4 changes: 2 additions & 2 deletions docfx_project/articles/stkpushstatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var QueryLipaNaMpesaTransactionObject = new LipaNaMpesaQueryDto
{
BusinessShortCode = "174379",
CheckoutRequestID = "",
Password = "", //this will change in future to use passkey
Timestamp = "" //this will be taken care of with future release of MpesaLib
Password = "",
Timestamp = ""

};

Expand Down
29 changes: 27 additions & 2 deletions docfx_project/articles/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,37 @@ The Security Credential helper class is in MpesaLib.Helpers namespace.
This class helps you generate the required credential to be used to authorize the above mentioned APIs.

```c#
using MpesaLib.Helpers; // Add this to your class
using MpesaLib.Helpers; // add this to your class or namespace
//get path to Mpesa public certificate. There are different certs for development and for production, ensure to use the correct one)
//get path of Mpesa public certificate. There are different certs for development and for production, ensure to use the correct one)
string certificate = @"C:\Dev\MpesaLibSamples\WebApplication1\Certificate\prod.cer";

//generate security credential as follows...
var SecutityCredential = Credentials.EncryptPassword(certificate, "Initiator Password");

```

## Error handling
MpesaClient Throws ```MpesaApiException``` whenever A 200 status code is not returned. It is your role as the developer to catch
the exception and continue processing in your aplication. Snippet below shows how you can catch the MpesaApiException.

```c#
using MpesaLib.Helpers.Exceptions; // add this to you class or namespace

try
{
return await _mpesaClient.MakeLipaNaMpesaOnlinePaymentAsync(MpesaPayment, accesstoken, RequestEndPoint.LipaNaMpesaOnline);
}
catch (MpesaApiException e)
{
_logger.LogError($"An Error Occured, Status Code {e.StatusCode}: {e.Content}");

//check the status code and return what is appropriate for your case. e.Content has the error message from Mpesa inform of a json string (not object) incase you do things like tying to transact 0 shillings or more than the 70k limit per transaction, or your shorcode is wrong or your accesstoken is not valid etc.
return BadRequest(); //I am just being lazy here.
}

```

0 comments on commit a5950a0

Please sign in to comment.