b2c_app_v1

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const B2CTable = "b2c_transactions"

B2CTable is table name for b2c transactions

View Source
const SourceKey = "source"

Variables

This section is empty.

Functions

func GetMpesaB2CPushKey

func GetMpesaB2CPushKey(msisdn string) string

GetMpesaSTKPushKey retrives key storing initiator key

func GetMpesaRequestKey

func GetMpesaRequestKey(requestId string) string

GetMpesaRequestKey is key that initiates data

func NewB2CAPI

func NewB2CAPI(ctx context.Context, opt *Options) (b2c.B2CV1Server, error)

NewB2CAPI creates a B2C API for mpesa

func PaymentProto

func PaymentProto(db *Payment) (*b2c.B2CPayment, error)

func StatProto

func StatProto(db *DailyStat) (*b2c.DailyStat, error)

StatProto gets mpesa statistics protobuf from model

func ValidateB2COptions

func ValidateB2COptions(opt *B2COptions) error

ValidateB2COptions validates b2c options

func ValidateOptions

func ValidateOptions(opt *Options) error

ValidateOptions validates options required by stk service

Types

type B2COptions

type B2COptions struct {
	ConsumerKey                string
	ConsumerSecret             string
	AccessTokenURL             string
	QueueTimeOutURL            string
	ResultURL                  string
	InitiatorUsername          string
	InitiatorEncryptedPassword string
	// contains filtered or unexported fields
}

B2COptions contains options for doing b2c with mpesa

type DailyStat

type DailyStat struct {
	ID                     uint   `gorm:"primaryKey;autoIncrement"`
	OrgShortCode           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"`
	SuccessfulTransactions int32
	FailedTransactions     int32
	TotalAmountTransacted  float32        `gorm:"index;type:float(15)"`
	TotalCharges           float32        `gorm:"index;type:float(15)"`
	CreatedAt              time.Time      `gorm:"autoCreateTime"`
	UpdatedAt              time.Time      `gorm:"autoCreateTime"`
	DeletedAt              gorm.DeletedAt `gorm:"index"`
}

DailyStat contains statistics for a day

func StatModel

func StatModel(pb *b2c.DailyStat) (*DailyStat, error)

StatModel gets mpesa statistics model from protobuf message

func (*DailyStat) TableName

func (*DailyStat) TableName() string

TableName ...

type Options

type Options struct {
	// PublishChannel     string
	QueryBalanceURL    string
	B2CURL             string
	ReversalURL        string
	SQLDB              *gorm.DB
	RedisDB            *redis.Client
	Logger             grpclog.LoggerV2
	AuthAPI            *auth.API
	HTTPClient         httpClient
	B2COptions         *B2COptions
	TransactionCharges float32
}

Options contains options for starting b2c service

type Payment

type Payment 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)"`

	Msisdn            string  `gorm:"index;type:varchar(15)"`
	OrgShortCode      string  `gorm:"index;type:varchar(15)"`
	CommandId         string  `gorm:"index;type:varchar(30)"`
	TransactionAmount float32 `gorm:"index;type:float(10)"`

	ConversationID           string `gorm:"index;type:varchar(50);not null"`
	OriginatorConversationID string `gorm:"index;type:varchar(50);not null"`
	ResponseDescription      string `gorm:"type:varchar(300)"`
	ResponseCode             string `gorm:"index;type:varchar(10)"`
	ResultCode               string `gorm:"index;type:varchar(10)"`
	ResultDescription        string `gorm:"type:varchar(300)"`

	WorkingAccountFunds float32        `gorm:"type:float(10)"`
	UtilityAccountFunds float32        `gorm:"type:float(10)"`
	MpesaCharges        float32        `gorm:"type:float(10)"`
	SystemCharges       float32        `gorm:"type:float(10)"`
	RecipientRegistered bool           `gorm:"index;type:tinyint(1)"`
	MpesaReceiptId      sql.NullString `gorm:"index;type:varchar(50);unique"`
	ReceiverPublicName  string         `gorm:"type:varchar(50)"`

	B2CStatus string `gorm:"index;type:varchar(30);column:b2c_status"`
	Source    string `gorm:"index;type:varchar(30)"`
	Tag       string `gorm:"index;type:varchar(30)"`
	Succeeded string `gorm:"index;type:enum('YES','NO', 'UNKNOWN');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;type:datetime(6);not null"`
}

Payment is B2C payment model

func (*Payment) TableName

func (*Payment) TableName() string

TableName is table name for model

Jump to

Keyboard shortcuts

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