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

View Source
const (
	// FailedTxList is redis list for failed mpesa transactions
	FailedTxList = "mpesa:stk:failedtx:list"
)

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, mpesaAPI c2b.LipaNaMPESAServer,
) (_ stk.StkPushAPIServer, err error)

NewStkAPI creates a singleton instance of mpesa stk API

func STKTransactionModel

func STKTransactionModel(pb *stk.StkTransaction) (*stk_model.STKTransaction, error)

STKTransactionModel converts protobuf mpesa message to MPESASTKTransaction

func STKTransactionPB

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

STKTransactionPB returns the protobuf message of mpesa payment model

func ValidateOptions

func ValidateOptions(opt *Options) error

ValidateOptions validates options required by stk service

func ValidateOptionsSTK

func ValidateOptionsSTK(opt *OptionsSTK) error

ValidateOptionsSTK validates stk options

func ValidateStkTransaction

func ValidateStkTransaction(payload *stk.StkTransaction) error

ValidateStkTransaction validates STK transaction

Types

type HTTPClient

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

HTTPClient makes mocking test easier

type Options

type Options struct {
	SQLDB                     *gorm.DB
	RedisDB                   *redis.Client
	Logger                    grpclog.LoggerV2
	AuthAPI                   auth.API
	OptionsSTK                *OptionsSTK
	HTTPClient                HTTPClient
	UpdateAccessTokenDuration time.Duration
	WorkerDuration            time.Duration
	InitiatorExpireDuration   time.Duration
	PublishChannel            string
	DisableMpesaService       bool
}

Options contain parameters passed for creating stk service

type OptionsSTK

type OptionsSTK 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
}

OptionsSTK contains options for sending push stk

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