Documentation ¶
Index ¶
- Constants
- func GetMpesaRequestKey(requestId string) string
- func GetMpesaSTKPushKey(msisdn string) string
- func NewStkAPI(ctx context.Context, opt *Options) (_ stk.StkPushV1Server, err error)
- func ToProto(db *STKTransaction) (*stk.StkTransaction, error)
- func ValidateOptionSTK(opt *OptionSTK) error
- func ValidateOptions(opt *Options) error
- type HTTPClient
- type OptionSTK
- type Options
- type STKRequestBody
- type STKTransaction
Constants ¶
View Source
const StkTable = "stk_transactions"
StkTable is table for mpesa payments
Variables ¶
This section is empty.
Functions ¶
func GetMpesaRequestKey ¶
GetMpesaRequestKey is key that initiates data
func GetMpesaSTKPushKey ¶
GetMpesaSTKPushKey retrives key storing initiator key
func ToProto ¶
func ToProto(db *STKTransaction) (*stk.StkTransaction, error)
ToProto returns the protobuf message of stk transaction
func ValidateOptionSTK ¶
ValidateOptionSTK validates stk options
func ValidateOptions ¶
ValidateOptions validates options required by stk service
Types ¶
type HTTPClient ¶
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
type STKTransaction ¶
type STKTransaction struct { ID uint `gorm:"primaryKey;autoIncrement"` InitiatorID string `gorm:"index;type:varchar(50)"` InitiatorCustomerReference string `gorm:"index;type:varchar(50)"` InitiatorCustomerNames string `gorm:"type:varchar(50)"` PhoneNumber string `gorm:"index;type:varchar(15);not null"` Amount string `gorm:"type:float(10);not null"` ShortCode string `gorm:"index;type:varchar(15)"` AccountReference string `gorm:"index;type:varchar(50)"` TransactionDesc sql.NullString `gorm:"type:varchar(300)"` MerchantRequestID sql.NullString `gorm:"index;type:varchar(50);"` CheckoutRequestID sql.NullString `gorm:"index;type:varchar(50);"` StkResponseDescription sql.NullString `gorm:"type:varchar(300)"` StkResponseCustomerMessage sql.NullString `gorm:"type:varchar(300)"` StkResponseCode sql.NullString `gorm:"index;type:varchar(10)"` ResultCode sql.NullString `gorm:"index;type:varchar(10)"` ResultDescription sql.NullString `gorm:"type:varchar(300)"` MpesaReceiptId sql.NullString `gorm:"index;type:varchar(50);unique"` StkStatus sql.NullString `gorm:"index;type:varchar(30)"` Source sql.NullString `gorm:"index;type:varchar(30)"` Tag sql.NullString `gorm:"index;type:varchar(30)"` // Succeeded bool `gorm:"index;type:tinyint(1)"` // Processed bool `gorm:"index;type:tinyint(1)"` Succeeded string `gorm:"index;type:enum('YES','NO');default:NO"` Processed string `gorm:"index;type:enum('YES','NO');default:NO"` TransactionTime sql.NullTime `gorm:"index;type:datetime(6)"` UpdatedAt time.Time `gorm:"autoUpdateTime;type:datetime(6)"` CreatedAt time.Time `gorm:"index;autoCreateTime;primaryKey;type:datetime(6);not null"` }
STKTransaction contains mpesa stk transaction details
func (*STKTransaction) TableName ¶
func (*STKTransaction) TableName() string
TableName returns the name of the table
Click to show internal directories.
Click to hide internal directories.