diff --git a/Daraja.App/Program.cs b/Daraja.App/Program.cs
index 2d6fda6..1e3fe3b 100644
--- a/Daraja.App/Program.cs
+++ b/Daraja.App/Program.cs
@@ -22,12 +22,15 @@ static async Task Main(string[] args)
var grantType = config["GrantType"];
var passKey = config["PassKey"];
- var gateway = new DarajaGateway(endpoint, consumerKey, consumerSecret, passKey);
+ if (endpoint != null && consumerKey != null && consumerSecret != null && passKey != null)
+ {
+ var gateway = new DarajaGateway(endpoint, consumerKey, consumerSecret, passKey);
- var darajaClient = await gateway.GetDarajaClientAsync();
+ var darajaClient = await gateway.GetDarajaClientAsync();
- if (darajaClient != null)
- await MakeStkPush(gateway, darajaClient);
+ if (darajaClient != null)
+ await MakeStkPush(gateway, darajaClient);
+ }
}
private static async Task MakeStkPush(DarajaGateway darajaGateway, DarajaClient darajaClient)
diff --git a/MpesaDaraja/Interfaces/IDarajaClient.cs b/MpesaDaraja/Interfaces/IDarajaClient.cs
index f07d7e3..73c7dc2 100644
--- a/MpesaDaraja/Interfaces/IDarajaClient.cs
+++ b/MpesaDaraja/Interfaces/IDarajaClient.cs
@@ -47,7 +47,7 @@ internal interface IDarajaClient
/// Response from initiating the STK Push
/// The object used to initiate the stk push
///
- Task<(bool isCompleted, PushQueryResponse response)> QueryStkPushStatus(PushResponse pushResponse,
+ Task<(bool isCompleted, PushQueryResponse? pushQueryResponse)> QueryStkPushStatus(PushResponse pushResponse,
StkData stkData);
}
diff --git a/MpesaDaraja/Models/PushQueryResponse.cs b/MpesaDaraja/Models/PushQueryResponse.cs
index 19c5e0e..4bb26e0 100644
--- a/MpesaDaraja/Models/PushQueryResponse.cs
+++ b/MpesaDaraja/Models/PushQueryResponse.cs
@@ -12,21 +12,42 @@ namespace MpesaDaraja.Models
///
public class PushQueryResponse
{
+ ///
+ /// This is a Numeric status code that indicates the status of the transaction submission. 0 means successful submission and any other code means an error occurred.
+ ///
[JsonProperty("ResponseCode")]
public string? ResponseCode { get; set; }
+ ///
+ /// Response description is an acknowledgment message from the API that gives the status of the request submission usually maps to a specific ResponseCode value.
+ /// It can be a Success submission message or an error description
+ ///
[JsonProperty("ResponseDescription")]
public string? ResponseDescription { get; set; }
+ ///
+ /// This is a global unique Identifier for any submitted payment request.
+ ///
[JsonProperty("MerchantRequestID")]
public string? MerchantRequestId { get; set; }
+ ///
+ /// This is a global unique identifier of the processed checkout transaction request.
+ ///
[JsonProperty("CheckoutRequestID")]
public string? CheckoutRequestId { get; set; }
+ ///
+ /// This is a numeric status code that indicates the status of the transaction processing.
+ /// 0 means successful processing and any other code means an error occurred or the transaction failed.
+ ///
[JsonProperty("ResultCode")]
public string? ResultCode { get; set; }
+ ///
+ /// Result description is a message from the API that gives the status of the request processing, usually maps to a specific ResultCode value.
+ /// It can be a Success processing message or an error description message.
+ ///
[JsonProperty("ResultDesc")]
public string? ResultDesc { get; set; }
}
diff --git a/MpesaDaraja/Models/PushResponse.cs b/MpesaDaraja/Models/PushResponse.cs
index 8c1d12d..032c95e 100644
--- a/MpesaDaraja/Models/PushResponse.cs
+++ b/MpesaDaraja/Models/PushResponse.cs
@@ -10,7 +10,7 @@ namespace MpesaDaraja.Models
///
/// Result after initiating an stk push
///
- public class PushResult
+ public class PushResponse
{
///
/// This is a global unique Identifier for any submitted payment request.
diff --git a/MpesaDaraja/Models/StkData.cs b/MpesaDaraja/Models/StkData.cs
index 6a59a34..d6c1664 100644
--- a/MpesaDaraja/Models/StkData.cs
+++ b/MpesaDaraja/Models/StkData.cs
@@ -7,6 +7,9 @@
namespace MpesaDaraja.Models
{
+ ///
+ /// Defines the class for initiating online payment on behalf of a customer.
+ ///
public class StkData
{
///
@@ -77,6 +80,9 @@ public class StkData
[JsonProperty("TransactionDesc")]
public string? TransactionDesc { get; set; }
+ ///
+ /// Creates an instance of the class
+ ///
public StkData()
{
Timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");