stk

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMpesaRequestKey

func GetMpesaRequestKey(requestId string) string

GetMpesaRequestKey is key that initiates data

func GetMpesaSTKPushKey

func GetMpesaSTKPushKey(msisdn string) string

GetMpesaSTKPushKey retrives key storing initiator key

func NewStkAPI

func NewStkAPI(ctx context.Context, opt *Options) (_ stk.StkPushV2Server, err error)

NewStkAPI creates a singleton instance of mpesa stk API

func STKTransactionPB

func STKTransactionPB(db *stk_model.STKTransaction) (*stk.StkTransaction, error)

STKTransactionPB returns the protobuf message of mpesa payment model

func ValidateOptionSTK

func ValidateOptionSTK(opt *OptionSTK) error

ValidateOptionSTK validates stk options

func ValidateOptions

func ValidateOptions(opt *Options) error

ValidateOptions validates options required by stk service

Types

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient makes mocking test easier

type OptionSTK

type OptionSTK struct {
	AccessTokenURL    string
	PassKey           string
	ConsumerKey       string
	ConsumerSecret    string
	BusinessShortCode string
	AccountReference  string
	Timestamp         string
	CallBackURL       string
	PostURL           string
	QueryURL          string
	// contains filtered or unexported fields
}

OptionSTK contains options for sending push stk

type Options

type Options struct {
	SQLDB                     *gorm.DB
	RedisDB                   *redis.Client
	Logger                    grpclog.LoggerV2
	AuthAPI                   auth.API
	OptionSTK                 *OptionSTK
	HTTPClient                HTTPClient
	UpdateAccessTokenDuration time.Duration
}

Options contain parameters passed for creating stk service

type STKRequestBody

type STKRequestBody struct {
	BusinessShortCode string `json:"BusinessShortCode,omitempty"`
	Password          string `json:"Password,omitempty"`
	Timestamp         string `json:"Timestamp,omitempty"`
	TransactionType   string `json:"TransactionType,omitempty"`
	Amount            string `json:"Amount,omitempty"`
	PartyA            string `json:"PartyA,omitempty"`
	PartyB            string `json:"PartyB,omitempty"`
	PhoneNumber       string `json:"PhoneNumber,omitempty"`
	CallBackURL       string `json:"CallBackURL,omitempty"`
	AccountReference  string `json:"AccountReference,omitempty"`
	TransactionDesc   string `json:"TransactionDesc,omitempty"`
}

STKRequestBody is STK push request payload

Jump to

Keyboard shortcuts

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