Documentation ¶
Index ¶
- Constants
- func GetMpesaRequestKey(requestId string) string
- func GetMpesaSTKPushKey(msisdn string) string
- func NewStkAPI(ctx context.Context, opt *Options, mpesaAPI c2b.LipaNaMPESAServer) (_ stk.StkPushAPIServer, err error)
- func STKTransactionModel(pb *stk.StkTransaction) (*stk_model.STKTransaction, error)
- func STKTransactionPB(db *stk_model.STKTransaction) (*stk.StkTransaction, error)
- func ValidateOptions(opt *Options) error
- func ValidateOptionsSTK(opt *OptionsSTK) error
- func ValidateStkTransaction(payload *stk.StkTransaction) error
- type HTTPClient
- type Options
- type OptionsSTK
- type STKRequestBody
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 ¶
GetMpesaRequestKey is key that initiates data
func GetMpesaSTKPushKey ¶
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 ¶
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 ¶
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
Click to show internal directories.
Click to hide internal directories.