Documentation ¶
Index ¶
- Constants
- func AddPrefix(key, prefix string) string
- func C2BPayment(MpesaDB *PaymentMpesa) (*c2b.C2BPayment, error)
- func GetBlastFilePB(blastFileDB *BlastFile) (*c2b.BlastFile, error)
- func GetExportPB(exportDB *BlastReport) (*c2b.BlastReport, error)
- func GetStatPB(statDB *Stat) (*c2b.Stat, error)
- func NewAPIServerMPESA(ctx context.Context, opt *Options) (c2b.LipaNaMPESAServer, error)
- func ValidateC2BPayment(payment *c2b.C2BPayment) error
- func ValidateOptions(opt *Options) error
- type BlastFile
- type BlastReport
- type Options
- type PaymentMpesa
- type QueueBulk
- type Scopes
- type Stat
- type UploadedFileData
Constants ¶
const C2Bs = "c2b_transactions"
C2Bs is table for mpesa payments
const (
FailedTxList = "mpesa:payments:failedtx:list"
)
FailedTxList is redis list for failed mpesa transactions
Variables ¶
This section is empty.
Functions ¶
func C2BPayment ¶
func C2BPayment(MpesaDB *PaymentMpesa) (*c2b.C2BPayment, error)
C2BPayment returns the protobuf message of mpesa payment model
func GetBlastFilePB ¶
GetBlastFilePB gets blast file protobuf message from blast file model
func GetExportPB ¶
func GetExportPB(exportDB *BlastReport) (*c2b.BlastReport, error)
GetExportPB gets protobuf message from db model
func NewAPIServerMPESA ¶
NewAPIServerMPESA creates a singleton instance of mpesa API server
func ValidateC2BPayment ¶
func ValidateC2BPayment(payment *c2b.C2BPayment) error
ValidateC2BPayment validates MPESA transaction
func ValidateOptions ¶
ValidateOptions validates options required by stk service
Types ¶
type BlastFile ¶
type BlastFile struct { ID uint `gorm:"primaryKey;autoIncrement"` ReferenceName string `gorm:"index;type:varchar(50);not null;unique"` FileName string `gorm:"index;type:varchar(50);not null"` UploaderNames string `gorm:"index;type:varchar(50);not null"` TotalMsisdn int32 `gorm:"index;type:int(10);not null"` UploadedAt time.Time `gorm:"autoCreateTime"` }
BlastFile is model for uplaoded file
func GetBlastFileDB ¶
GetBlastFileDB gets the blast file model from protobuf message
type BlastReport ¶
type BlastReport struct { ID uint `gorm:"primaryKey;autoIncrement"` Originator string `gorm:"index;type:varchar(25);not null"` Initiator string `gorm:"index;type:varchar(50);not null"` Source string `gorm:"index;type:varchar(20);not null"` BlastFile string `gorm:"index;type:varchar(50)"` Message string `gorm:"type:text(500);not null"` TotalExported int32 `gorm:"index;type:int(10);not null;default:0"` ExportFilter []byte `gorm:"type:json;"` CreatedAt time.Time `gorm:"autoCreateTime"` }
BlastReport is model for export statistics
func GetExportDB ¶
func GetExportDB(exportPB *c2b.BlastReport) (*BlastReport, error)
GetExportDB gets export db model from protobuf message
type Options ¶
type Options struct { PublishChannel string RedisKeyPrefix string SQLDB *gorm.DB RedisDB *redis.Client Logger grpclog.LoggerV2 AuthAPI auth.API PaginationHasher *hashids.HashID }
Options contains options for starting mpesa service
type PaymentMpesa ¶
type PaymentMpesa struct { PaymentID uint `gorm:"primaryKey;autoIncrement"` TransactionType string `gorm:"type:varchar(50);not null"` TransactionID string `gorm:"type:varchar(50);not null;unique"` MSISDN string `gorm:"index;type:varchar(15);not null"` Names string `gorm:"type:varchar(50)"` ReferenceNumber string `gorm:"index;type:varchar(20)"` Amount float32 `gorm:"type:float(10);not null"` OrgAccountBalance float32 `gorm:"type:float(10)"` BusinessShortCode int32 `gorm:"index;type:varchar(10);not null"` TransactionTime time.Time `gorm:"autoCreateTime"` CreateTime time.Time `gorm:"autoCreateTime"` Processed bool `gorm:"type:tinyint(1);not null"` }
PaymentMpesa contains mpesa transaction details
func C2BPaymentDB ¶
func C2BPaymentDB(MpesaPB *c2b.C2BPayment) (*PaymentMpesa, error)
C2BPaymentDB converts protobuf mpesa message to C2BMpesa
func (*PaymentMpesa) TableName ¶
func (*PaymentMpesa) TableName() string
TableName returns the name of the table
type QueueBulk ¶
type QueueBulk struct { RecordID uint `gorm:"primaryKey;autoIncrement;column:RecordID"` Originator string `gorm:"index;type:varchar(25);not null;default:'20453';column:Originator"` Destination string `gorm:"index;type:varchar(15);not null;column:Destination"` Message string `gorm:"type:text(500);column:Message"` MessageTimeStamp time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;column:MessageTimeStamp"` MessageDirection string `gorm:"type:varchar(5);column:MessageTimeStamp"` SMSCID string `gorm:"index;type:varchar(20);column:SMSCID"` Command bool `gorm:"type:varchar(20);column:command"` }
QueueBulk contains exported data for bulk
type Scopes ¶
type Scopes struct { UserID string `gorm:"primaryKey;type:varchar(15)"` Scopes []byte `gorm:"type:json"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoCreateTime"` DeletedAt gorm.DeletedAt `gorm:"index"` }
Scopes is model user scopes
type Stat ¶
type Stat struct { StatID uint `gorm:"primaryKey;autoIncrement"` ShortCode string `gorm:"index;type:varchar(20);not null"` AccountName string `gorm:"index;type:varchar(20);not null"` Date string `gorm:"index;type:varchar(10);not null"` TotalTransactions int32 `gorm:"type:int(10);not null"` TotalAmount float32 `gorm:"type:float(12);not null"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoCreateTime"` DeletedAt gorm.DeletedAt `gorm:"index"` }
Stat is model containing transactions statistic
type UploadedFileData ¶
type UploadedFileData struct { ID uint `gorm:"primaryKey;autoIncrement"` Msisdn string `gorm:"index;type:varchar(15);not null"` FileID string `gorm:"index;type:varchar(10);not null"` CreatedAt time.Time `gorm:"autoCreateTime"` }
UploadedFileData contains data contained in the uploaded file