Skip to content

MPESA callback de-serialization using System.Text.Json implementation

License

Notifications You must be signed in to change notification settings

cymushier/MPESACallbackDeserialization

Repository files navigation

MPESA Callback Data Deserialization

MPESA callback de-serialization using System.Text.Json implementation

Background

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.

Abc...

  1. Go through the models definitions in the Models folder. These define the base data for MPESA callback data.
  2. Check in the Converters folder to review the JsonConverter for KeyValueParameter. If using ASP.NET Core - note that the converter has been registered on the KeyValueParameter model, another is to register it in dependencies container.
  3. For ASP.NET Core controller view, the CallbackResponse is the data type to receive from the callback.
  4. 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.

NOTE

  • This implementation contains sample data and can be extended to suit any dynamic data as may be required.

About

MPESA callback de-serialization using System.Text.Json implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages