c2b

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: 23 Imported by: 0

Documentation

Index

Constants

View Source
const C2Bs = "c2b_transactions"

C2Bs is table for mpesa payments

View Source
const (
	FailedTxList = "mpesa:payments:failedtx:list"
)

FailedTxList is redis list for failed mpesa transactions

Variables

This section is empty.

Functions

func AddPrefix

func AddPrefix(key, prefix string) string

AddPrefix adds a prefix to redis key

func C2BPayment

func C2BPayment(MpesaDB *PaymentMpesa) (*c2b.C2BPayment, error)

C2BPayment returns the protobuf message of mpesa payment model

func GetBlastFilePB

func GetBlastFilePB(blastFileDB *BlastFile) (*c2b.BlastFile, error)

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 GetStatPB

func GetStatPB(statDB *Stat) (*c2b.Stat, error)

GetStatPB gets mpesa statistics protobuf from model

func NewAPIServerMPESA

func NewAPIServerMPESA(ctx context.Context, opt *Options) (c2b.LipaNaMPESAServer, error)

NewAPIServerMPESA creates a singleton instance of mpesa API server

func ValidateC2BPayment

func ValidateC2BPayment(payment *c2b.C2BPayment) error

ValidateC2BPayment validates MPESA transaction

func ValidateOptions

func ValidateOptions(opt *Options) error

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

func GetBlastFileDB(blastFilePB *c2b.BlastFile) (*BlastFile, error)

GetBlastFileDB gets the blast file model from protobuf message

func (*BlastFile) TableName

func (*BlastFile) TableName() string

TableName ...

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

func (*BlastReport) TableName

func (*BlastReport) TableName() string

TableName ...

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

func (*QueueBulk) TableName

func (*QueueBulk) TableName() string

TableName ...

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

func (*Scopes) TableName

func (*Scopes) TableName() string

TableName ...

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

func GetStatDB

func GetStatDB(statPB *c2b.Stat) (*Stat, error)

GetStatDB gets mpesa statistics model from protobuf message

func (*Stat) TableName

func (*Stat) TableName() string

TableName ...

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

func (*UploadedFileData) TableName

func (*UploadedFileData) TableName() string

TableName ...

Jump to

Keyboard shortcuts

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