This PR introduces mpesa-rails-express app in templates as the base template for mpesa express product for a rails app.
This templates uses ruby 3.2.2 and rails 7.1.3 as the default versions. Aside from the default gem dependencies it has 2 gem dependencies gem 'dotenv' to help load variables defined in a .env file and gem rest-client to make http requests.
The logic is defined in app/controllers/api/example_controller.rb which includes two concern files stk and callback defined under app/controllers/concerns/example/stk.rb and app/controller/concerns/exaple/callback.rb respectively.
example_controller.rb contains methods shared between all products
load_variables - loads required values from .env file and saves them to a variable.
generate_access_token_request, retrieve_access_token and send_access_token_request are used to send and retrieve for the tokens required for authenticating your API calls.
The concerns are defined separately to give them a single responsibility, stk.rb for stk push request and callback.rb for checking the status of the stk push.
What
This PR introduces
mpesa-rails-express
app intemplates
as the base template for mpesa express product for a rails app.This templates uses
ruby 3.2.2
andrails 7.1.3
as the default versions. Aside from the default gem dependencies it has 2 gem dependenciesgem 'dotenv'
to help load variables defined in a.env
file andgem rest-client
to make http requests.The logic is defined in
app/controllers/api/example_controller.rb
which includes two concern files stk and callback defined underapp/controllers/concerns/example/stk.rb
andapp/controller/concerns/exaple/callback.rb
respectively.example_controller.rb
contains methods shared between all productsload_variables
- loads required values from.env
file and saves them to a variable.generate_access_token_request
,retrieve_access_token
andsend_access_token_request
are used to send and retrieve for the tokens required for authenticating your API calls.The concerns are defined separately to give them a single responsibility,
stk.rb
for stk push request andcallback.rb
for checking the status of the stk push.Responses are in
JSON
format.Screenshots