MPESA callback de-serialization using System.Text.Json
implementation
With the introduction of System.Text.Json
, dynamic serialization is not yet supported - slated for .NET 5. This therefore
means that serialization within a controller for some dynamic parameters may not be possible unless you revert back to Newtonsoft.Json.
This implementation may also support Newtonsoft.Json when serializing to a concrete type is needed, as long as the converter is updated to reflect that.
- Go through the models definitions in the
Models
folder. These define the base data for MPESA callback data. - Check in the
Converters
folder to review the JsonConverter forKeyValueParameter
. If using ASP.NET Core - note that the converter has been registered on theKeyValueParameter
model, another is to register it in dependencies container. - For ASP.NET Core controller view, the
CallbackResponse
is the data type to receive from the callback. - Run the application to see the processed results. You can modify the various fields for the models and run your test cases with sample json data to check on how the data could be serialized.
- This implementation contains sample data and can be extended to suit any dynamic data as may be required.