Logo Lanfrica

korobosta/golang-mpesa

Domain:

digital infrastructure

Record type:

software
Creator:
kor
Host:
# What is golang-mpesa **golang-mpesa** is an golang mpesa package that helps developers to call mpesa apis without much hussle. The package helps in generating tokens, making stk push, performing transaction query requests and even saving the transactions in the database. ## How to setup Get the package with following command : ```bash go get github.com ``` ## Functions The package provides the following functions: - **GenerateMpesaToken** : For generating mpesa access tokens - **StkPush** : For making stk push to the customer phone - **GetStkPushResponse** : For getting the stk push callback data from mpesa and saving it in the database. - **DecodeStkCallbackResponse** A function for decoding mpesa stk response data. - **SaveMpesaPaymentConfirmation** : This functions takes the mpesa payment confirmation response and saves it in the database - **TransactionQuery** : This function makes the transaction query request to MPESA - **GetTransactionQueryResponse** : This is a callback function for taking transaction query response and saving the payment in the database. - **EncryptWithPublicKey** : This function encrypts the password with MPESA public key to form the security credentail Configuration: For easy configuration of the package, we have created a model called ***Config*** so that all static variables required can be initialized at once. The configuration can be done as shown below. ```Go import ( "github.com" ) //Configuration function for all static mpesa variables func MpesaConfig() mpesa.Config { var config = mpesa.Config{} //Mandatory Fiels config.MpesaConsumerKey = "your-consumer-key" config.MpesaConsumerSecret = "your-consumer-secret" config.MpesaShortCode = "your-mpesa-short code" //e.g 174379 config.Initiator = "Your initiator username" // e.g testapi config.InitiatorPassword = "Your Initation Password" // e.g Safaricom1234!! config.TransQueryOriginatorConversationID ="your transactio …

Languages