daraja_wrapper

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 11 Imported by: 0

README

Go

daraja_wrapper

Meant to be a wrapper library for the daraja API from safaricom Mpesa/Lipa na Mpesa

Reason

  • Needed a project to help me better understand golang and testing of projects.

WIP

  • Check milestones for next feature updates to be done.

Documentation

Index

Constants

View Source
const Authentication_url = "https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials"
View Source
const Lipa_na_mpesa_url = "https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest"

Variables

This section is empty.

Functions

func SecurityCredentials

func SecurityCredentials(password, cert_file []byte) (string, error)

`SecurityCredentials` - This function is for generating the `SecurityCredentials` used in the parameters for mpesa API `password` is the 'Initiator Security Password' `cert_file` is the contents of the cetificate(Leaving the getting of the file to the user)

Types

type Auth

type Auth struct {
	Key, Secret string
	Prod        bool
}

func (*Auth) GetAuthKey

func (a *Auth) GetAuthKey() (Token, error)

func (Auth) String

func (a Auth) String() string

type LipaNaMpesaPayStruct

type LipaNaMpesaPayStruct struct {
	BusinessShortCode, Password, Timestamp                      string
	TransactionType, Amount, PartyA, PartyB                     string
	PhoneNumber, CallBackURL, AccountReference, TransactionDesc string
}

func (*LipaNaMpesaPayStruct) GenPasswordAndAssign

func (l *LipaNaMpesaPayStruct) GenPasswordAndAssign(pass_key string)

func (*LipaNaMpesaPayStruct) LipaNaMpesaPayment

func (l *LipaNaMpesaPayStruct) LipaNaMpesaPayment(a *Auth, pass_key string) (LipaNaMpesaResp, error)

`LipaNaMpesaPayment` - 'Lipa na M-Pesa Online Payment' Lipa na M-Pesa Online Payment API is used to initiate a M-Pesa transaction on behalf of a customer using STK Push. This is the same technique mySafaricom App uses whenever the app is used to make payments.

type LipaNaMpesaResp

type LipaNaMpesaResp map[string]interface{}

type Token

type Token struct {
	Token  string `json:"access_token"`
	Expiry string `json:"expires_in"`
}

Token - This is the token received from the daraja API. The `Token` struct is used to validate various actions done on the API

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL