ebs_fields

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package ebs_fields include all of ebs fields data for both consumer and merchant web services channels. ebs_fields package also includes endpoints and IPs for all EBS payment services. The package uses embed to embed secret file that includes configuration and info we don't like (read: legally obligated) to share, e.g., EBS IPs.

Index

Constants

View Source
const (
	BadRequest          = "BadRequest"
	ParsingError        = "ParsingError"
	InternalServerError = "InternalServerError"
	EBSError            = "EBSError"
)
View Source
const (
	IsAliveEndpoint                  = "isAlive"
	PurchaseEndpoint                 = "purchase"
	PurchaseWithCashBackEndpoint     = "purchaseWithCashBack"
	PurchaseMobileEndpoint           = "purchaseMobile"
	ReverseEndpoint                  = "reverse"
	BalanceEndpoint                  = "getBalance"
	MiniStatementEndpoint            = "getMiniStatement"
	RefundEndpoint                   = "refund"
	BillInquiryEndpoint              = "getBill"
	BillPaymentEndpoint              = "payBill"
	BillPrepaymentEndpoint           = "prepayBill"
	AccountTransferEndpoint          = "doAccountTransfer"
	CardTransferEndpoint             = "doCardTransfer"
	NetworkTestEndpoint              = "isAlive"
	WorkingKeyEndpoint               = "getWorkingKey"
	PayeesListEndpoint               = "getPayeesList"
	CashInEndpoint                   = "cashIn"
	CashOutEndpoint                  = "cashOut"
	GenerateVoucherEndpoint          = "generateVoucher"
	VoucherCashOutWithAmountEndpoint = "cashOutVoucher"
	VoucherCashInEndpoint            = "voucherCashIn"
	GenerateOTPEndpoint              = "generateOTP"
	ChangePINEndpoint                = "changePin"
)
View Source
const (
	PurchaseTransaction             = "PurchaseTransaction"
	PurchaseWithCashBackTransaction = "PurchaseWithCashBack"
	BillPaymentTransaction          = "BillPayment"
	BillInquiryTransaction          = "BillInquiry"
	CardTransferTransaction         = "CardTransfer"
	WorkingKeyTransaction           = "WorkingKeyFields"
	ChangePINTransaction            = "ChangePINTransaction"
	RefundTransaction               = "RefundTransaction"
	CashInTransaction               = "CashInTransaction"
	CashOutTransaction              = "CashOutTransaction"
	MiniStatementTransaction        = "MiniStatementTransaction"
	IsAliveTransaction              = "IsAliveTransaction"
	BalanceTransaction              = "BalanceTransaction"
	PayeesListTransaction           = "PayeesListTransaction"
)
View Source
const (
	ConsumerIsAliveEndpoint           = "isAlive"
	ConsumerWorkingKeyEndpoint        = "getPublicKey"
	ConsumerBalanceEndpoint           = "getBalance"
	ConsumerBillInquiryEndpoint       = "getBill"
	ConsumerBillPaymentEndpoint       = "payment"
	ConsumerCardTransferEndpoint      = "doCardTransfer"
	ConsumerAccountTransferEndpoint   = "doAccountTransfer"
	ConsumerPayeesListEndpoint        = "getPayeesList"
	ConsumerChangeIPinEndpoint        = "changeIPin"
	ConsumerPurchaseEndpoint          = "specialPayment"
	ConsumerStatusEndpoint            = "getTransactionStatus"
	ConsumerQRPaymentEndpoint         = "doQRPurchase"
	ConsumerQRGenerationEndpoint      = "doMerchantsRegistration" // the fuck is wrong with you guys
	ConsumerQRRefundEndpoint          = "doQRRefund"
	ConsumerPANFromMobile             = "checkMsisdnAganistPAN"
	ConsumerCardInfo                  = "getCustomerInfo"
	ConsumerGenerateVoucher           = "generateVoucher"
	ConsumerCashInEndpoint            = "doCashIn"
	ConsumerCashOutEndpoint           = "doCashOut"
	ConsumerTransactionStatusEndpoint = "getTransactionStatus"
	ConsumerComplete                  = "completeTransaction"

	// IPIN generation
	IPinGeneration            = "doGenerateIPinRequest"
	IPinCompletion            = "doGenerateCompletionIPinRequest"
	QRPublicKey               = "getPublicKey"
	MerchantTransactionStatus = "getMerchantTransactions"

	ConsumerRegister             = "register"
	ConsumerCompleteRegistration = "completeCardRegistration"
)

Variables

View Source
var (
	INVALIDPIN   = 53
	SUCCESS      = 0
	INVALIDCARD  = 52
	ROUTINGERROR = 72
)
View Source
var (
	ContentTypeErr = customError{/* contains filtered or unexported fields */}

	EbsGatewayConnectivityErr = customError{/* contains filtered or unexported fields */}
)
View Source
var EBSRes = make(chan CacheCards)
View Source
var EbsFailedTransaction customError
View Source
var SystemClock = &systemClock{}

SystemClock is a clock that returns local time of the system.

Functions

func DeleteBeneficiary added in v0.3.0

func DeleteBeneficiary(card Beneficiary, db *gorm.DB) error

DeleteBeneficiary with a user_id

func DeleteCard

func DeleteCard(card Card, db *gorm.DB) error

DeleteCard with a user_id

func EbsDate added in v0.3.0

func EbsDate() string

EbsDate generates an ebs compliant date format ("ddMMYYhhmmss")

func Encode

func Encode(p *Token) (string, error)

Encode PaymentToken to a URL safe link that can be used for online purchases

func ExpandCard added in v0.3.0

func ExpandCard(card string, userCards []Card) (string, error)

ExpandCard performs a regex search for the first and last 4 digits of a pan and retrieves the matching pan number

func GetDeviceIDsByPan added in v0.3.0

func GetDeviceIDsByPan(pan string, db *gorm.DB) ([]string, error)

GetDeviceIDsByPan retrieves device_ids associated to a card number

func HasPlatformErrorCode

func HasPlatformErrorCode(err error, code ErrorCode) bool

HasPlatformErrorCode checks if the given error contains a specific error code.

func HasSuccessStatus

func HasSuccessStatus(r *Response) bool

HasSuccessStatus returns true if the response status code is in the 2xx range.

func SaveOrUpdates added in v0.3.0

func SaveOrUpdates(db *gorm.DB, entity NoebsDatabase, newVal any) error

Saves or updates any type that implements noebsdatabase. Currently it works best when the case is to only update one field (flag in db e.g., is_valid) In case of no conflicts, it writes to db directly

func UpdateCard

func UpdateCard(card Card, db *gorm.DB) error

UpdateCard only changes a card pan number

Types

type AccountTransferFields

type AccountTransferFields struct {
	CommonFields
	CardInfoFields
	AmountFields
	ToAccount string `json:"toAccount" binding:"required"`
}

type AmountFields

type AmountFields struct {
	TranAmount       float32 `json:"tranAmount" binding:"required" form:"tranAmount"`
	TranCurrencyCode string  `json:"tranCurrencyCode" form:"tranCurrencyCode"`
}

AmountFields transaction amount data

type BalanceFields

type BalanceFields struct {
	CommonFields
	CardInfoFields
}

func (*BalanceFields) MustMarshal

func (f *BalanceFields) MustMarshal() []byte

type Beneficiary added in v0.3.0

type Beneficiary struct {
	Data     string `json:"data"`
	BillType string `json:"bill_type"`
	UserID   uint
	Name     string `json:"name"` // a beneficiary name
}

func NewBeneficiary added in v0.3.0

func NewBeneficiary(number string, billType int, carrier, operator int) Beneficiary

type BillInquiryFields

type BillInquiryFields struct {
	CommonFields
	CardInfoFields
	BillerFields
}

func (*BillInquiryFields) MustMarshal

func (f *BillInquiryFields) MustMarshal() []byte

type BillPaymentFields

type BillPaymentFields struct {
	CommonFields
	CardInfoFields
	AmountFields
	BillerFields
}

func (*BillPaymentFields) MustMarshal

func (f *BillPaymentFields) MustMarshal() []byte

type BillerFields

type BillerFields struct {
	PersonalPaymentInfo string `json:"personalPaymentInfo" binding:"required" form:"personalPaymentInfo"`
	PayeeID             string `json:"payeeId" binding:"required" form:"payeeId"`
}

type CacheBillers added in v0.3.0

type CacheBillers struct {
	Mobile   string `gorm:"primaryKey"`
	BillerID string
}

func GetBillerInfo added in v0.3.0

func GetBillerInfo(mobile string, db *gorm.DB) (CacheBillers, error)

func UpdateBiller added in v0.3.0

func UpdateBiller(mobile, biller string, db *gorm.DB) (CacheBillers, error)

func (*CacheBillers) Save added in v0.3.0

func (c *CacheBillers) Save(db *gorm.DB, flipBiller bool) error

type CacheCards added in v0.3.0

type CacheCards struct {
	gorm.Model
	Pan       string `json:"pan" gorm:"uniqueIndex"`
	Expiry    string `json:"exp_date"`
	Name      string `json:"name"`
	Mobile    string `json:"mobile" gorm:"-:all"`
	Password  string `json:"password" gorm:"-:all"`
	PublicKey string `json:"user_pubkey" gorm:"-:all"`
	IsValid   *bool  `json:"is_valid"`
}

func (CacheCards) GetPk added in v0.3.0

func (c CacheCards) GetPk() string

func (CacheCards) NewCardFromCached added in v0.3.0

func (c CacheCards) NewCardFromCached(id int) Card

func (CacheCards) OverrideField added in v0.3.0

func (c CacheCards) OverrideField() string

type Card

type Card struct {
	gorm.Model
	Pan     string `json:"pan"`
	Expiry  string `json:"exp_date"`
	Name    string `json:"name"`
	IPIN    string `json:"ipin" gorm:"column:ipin"` // set gorm db name to ipin to avoid conflict with the field name in the struct
	UserID  uint
	IsMain  bool   `json:"is_main" gorm:"default:false"`
	CardIdx string `json:"card_index" gorm:"-:all"`
	IsValid *bool  `json:"is_valid"`
}

Card represents a single card in noebs.

type CardInfoFields

type CardInfoFields struct {
	Pan     string `json:"PAN" binding:"required" form:"PAN"`
	Pin     string `json:"PIN" binding:"required" form:"PIN"`
	Expdate string `json:"expDate" binding:"required" form:"expDate"`
}

CardInfoFields implements a payment card info

type CardTransferFields

type CardTransferFields struct {
	CommonFields
	CardInfoFields
	AmountFields
	ToCard string `json:"toCard" binding:"required"`
}

func (*CardTransferFields) MustMarshal

func (f *CardTransferFields) MustMarshal() []byte

type CashInFields

type CashInFields struct {
	PurchaseFields
}

func (*CashInFields) MustMarshal

func (f *CashInFields) MustMarshal() []byte

type CashOutFields

type CashOutFields struct {
	PurchaseFields
}

func (*CashOutFields) MustMarshal

func (f *CashOutFields) MustMarshal() []byte

type ChangePINFields

type ChangePINFields struct {
	CommonFields
	CardInfoFields
	NewPIN string `json:"newPIN" binding:"required"`
}

func (*ChangePINFields) MustMarshal

func (f *ChangePINFields) MustMarshal() []byte

type Clock

type Clock interface {
	Now() time.Time
}

Clock is used to query the current local time.

type CommonFields

type CommonFields struct {
	SystemTraceAuditNumber int    `json:"systemTraceAuditNumber,omitempty" binding:"required" form:"systemTraceAuditNumber"`
	TranDateTime           string `json:"tranDateTime,omitempty" binding:"required" form:"tranDateTime"`
	TerminalID             string `json:"terminalId,omitempty" binding:"required,len=8" form:"terminalId"`
	ClientID               string `json:"clientId,omitempty" binding:"required" form:"clientId"`
}

type Configs added in v0.3.0

type Configs struct {
	DB *gorm.DB
}

type ConsumerAmountFields

type ConsumerAmountFields struct {
	TranAmount       float32 `json:"tranAmount" binding:"required" form:"tranAmount"`
	TranCurrencyCode string  `json:"tranCurrency" form:"tranCurrency"`
}

type ConsumerBalanceFields

type ConsumerBalanceFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
}

func (*ConsumerBalanceFields) MustMarshal

func (f *ConsumerBalanceFields) MustMarshal() []byte

type ConsumerBillInquiryFields

type ConsumerBillInquiryFields struct {
	ConsumerCommonFields
	ConsumersBillersFields
	ConsumerCardHolderFields
}

func (*ConsumerBillInquiryFields) MustMarshal

func (f *ConsumerBillInquiryFields) MustMarshal() []byte

func (*ConsumerBillInquiryFields) PopulateFields

func (c *ConsumerBillInquiryFields) PopulateFields()

type ConsumerBillPaymentFields

func (*ConsumerBillPaymentFields) MustMarshal

func (f *ConsumerBillPaymentFields) MustMarshal() []byte

type ConsumerCardHolderFields

type ConsumerCardHolderFields struct {
	Pan     string `json:"PAN" form:"PAN" binding:"required"`
	Ipin    string `json:"IPIN" form:"IPIN" binding:"required"`
	ExpDate string `json:"expDate" form:"expDate" binding:"required"`
}

func (*ConsumerCardHolderFields) MustMarshal

func (f *ConsumerCardHolderFields) MustMarshal() []byte

type ConsumerCardInfoFields

type ConsumerCardInfoFields struct {
	ConsumerCommonFields
	PAN string `json:"PAN" binding:"required"`
}

type ConsumerCardTransferAndMobileFields

type ConsumerCardTransferAndMobileFields struct {
	ConsumerCardTransferFields
	Mobile string `json:"mobile_number"`
}

type ConsumerCardTransferFields

type ConsumerCardTransferFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	AmountFields
	ToCard      string  `json:"toCard" binding:"required"`
	DynamicFees float32 `json:"dynamicFees,omitempty"`
}

func (*ConsumerCardTransferFields) MustMarshal

func (p2p *ConsumerCardTransferFields) MustMarshal() []byte

MustMarshal panics if not able to marshal repsonse

type ConsumerCashInFields

type ConsumerCashInFields struct {
	ConsumerCardTransferFields
}

type ConsumerCashoOutFields

type ConsumerCashoOutFields struct {
	ConsumerCardTransferFields
}

type ConsumerCommonFields

type ConsumerCommonFields struct {
	ApplicationId string `json:"applicationId" form:"applicationId" binding:"required"`
	TranDateTime  string `json:"tranDateTime" form:"tranDateTime" binding:"required"`
	UUID          string `json:"UUID" form:"UUID" binding:"required"`
	DeviceID      string `json:"device_id,omitempty"`
}

func (*ConsumerCommonFields) DelDeviceID added in v0.3.0

func (c *ConsumerCommonFields) DelDeviceID()

type ConsumerCompleteRegistrationFields

type ConsumerCompleteRegistrationFields struct {
	ConsumerCommonFields
	OTP              string `json:"otp" binding:"required"`  // encrypted for fucks sake. fuck ebs
	IPIN             string `json:"IPIN" binding:"required"` // also encrypted fml forever
	ExtraInfo        string `json:"extraInfo,omitempty"`
	OriginalTranUUID string `json:"originalTranUUID" binding:"required"`
	Password         string `json:"userPassword" binding:"required"`
	// Those are noebs-specific fields and shouldn't go to EBS
	NoebsPassword string `json:"password,omitempty"`
	Mobile        string `json:"mobile,omitempty"`
}

type ConsumerGenerateIPINFields

type ConsumerGenerateIPINFields struct {
	Username     string `json:"userName"`
	TranDateTime string `json:"tranDateTime" binding:"required"`
	UUID         string `json:"UUID" binding:"required"`
}

type ConsumerGenerateIPin

type ConsumerGenerateIPin struct {
	ConsumerGenerateIPINFields
	Password     string `json:"password"`
	Pan          string `json:"pan"`
	MobileNumber string `json:"phoneNumber" binding:"required"`
	Expdate      string `json:"expDate"`
}

func (*ConsumerGenerateIPin) MustMarshal

func (gi *ConsumerGenerateIPin) MustMarshal() []byte

type ConsumerGenerateIPinCompletion

type ConsumerGenerateIPinCompletion struct {
	ConsumerGenerateIPINFields
	Password string `json:"password" binding:"required"`
	Pan      string `json:"pan" binding:"required"`
	Expdate  string `json:"expDate" binding:"required"`
	Otp      string `json:"otp"  binding:"required"`
	Ipin     string `json:"ipin" binding:"required"`
}

func (*ConsumerGenerateIPinCompletion) MustMarshal

func (gip *ConsumerGenerateIPinCompletion) MustMarshal() []byte

type ConsumerGenerateVoucherFields

type ConsumerGenerateVoucherFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	AmountFields
	VoucherNumber string `json:"voucherNumber" binding:"required"`
}

type ConsumerIPinFields

type ConsumerIPinFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	NewIPIN string `json:"newIPIN" binding:"required"`
}

func (*ConsumerIPinFields) MustMarshal

func (f *ConsumerIPinFields) MustMarshal() []byte

type ConsumerIsAliveFields

type ConsumerIsAliveFields struct {
	ConsumerCommonFields
}

func (*ConsumerIsAliveFields) MustMarshal

func (f *ConsumerIsAliveFields) MustMarshal() []byte

type ConsumerPANFromMobileFields

type ConsumerPANFromMobileFields struct {
	ConsumerCommonFields
	EntityID string `json:"entityId" binding:"required"`
	Last4PAN string `json:"last4PANDigits" binding:"required"`
}

type ConsumerPurchaseFields

type ConsumerPurchaseFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	AmountFields
	// PaymentDetails    []PaymentDetails `json:"paymentDetails,omitempty" form:"paymentDetails"`
	ServiceProviderId string  `json:"serviceProviderId" binding:"required"`
	DynamicFees       float32 `json:"dynamicFees,omitempty"`
}

func (*ConsumerPurchaseFields) MustMarshal

func (f *ConsumerPurchaseFields) MustMarshal() []byte

type ConsumerQRCompleteFields

type ConsumerQRCompleteFields struct {
	ConsumerCommonFields
	OrigUUID   string `json:"originalTranUUID" binding:"required"`
	OrigTranID string `json:"originalTransactionId,omitempty"`
	OTP        string `json:"OTP,omitempty"`
}

type ConsumerQRPaymentFields

type ConsumerQRPaymentFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	ConsumerAmountFields
	QRCode     *string `json:"QRCode,omitempty" form:"QRCode" binding:"required_without=MerchantID"`
	MerchantID *string `json:"merchantID,omitempty" binding:"required_without=QRCode"`
}

func (*ConsumerQRPaymentFields) MustMarshal

func (f *ConsumerQRPaymentFields) MustMarshal() []byte

type ConsumerQRRefundFields

type ConsumerQRRefundFields struct {
	ConsumerCommonFields
	Pan                   string `json:"PAN,omitempty" form:"PAN"`
	Ipin                  string `json:"IPIN,omitempty" form:"IPIN"`
	ExpDate               string `json:"expDate,omitempty" form:"expDate"`
	OriginalTranUUID      string `json:"originalTranUUID" binding:"required"`
	AuthenticationType    string `json:"authenticationType,omitempty"`
	OriginalTransactionId string `json:"originalTransactionId,omitempty"`
	MerchantID            string `json:"merchantID,omitempty"`
	Last4PAN              string `json:"last4PANDigits,omitempty"`
	OTP                   string `json:"OTP,omitempty"`
}

func (*ConsumerQRRefundFields) MustMarshal

func (f *ConsumerQRRefundFields) MustMarshal() []byte

type ConsumerQRRegistration

type ConsumerQRRegistration struct {
	ConsumerCommonFields
	QRMerchantFields
}

type ConsumerQRStatus

type ConsumerQRStatus struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	Last4PAN   string `json:"last4PANDigits,omitempty"`
	MerchantID string `json:"merchantID,omitempty" binding:"required"`
	ListSize   int    `json:"listSize,omitempty"`
}

type ConsumerRegistrationFields

type ConsumerRegistrationFields struct {
	ConsumerCommonFields
	EntityFields
	RegistrationType string `json:"registrationType"`
	PhoneNo          string `json:"phoneNo"`
	PanCategory      string `binding:"required" json:"panCategory"`
}

ConsumerRegistrationFields the first step in card issuance

type ConsumerSpecificFields

type ConsumerSpecificFields struct {
	UUID            string  `json:"UUID" form:"UUID" binding:"required,len=36"`
	Ipin            string  `json:"IPIN" form:"IPIN" binding:"required"`
	PAN             string  `json:"PAN"`
	ExpDate         string  `json:"expDate"`
	PanCategory     string  `json:"panCategory"`
	FromAccountType string  `json:"fromAccountType" form:"fromAccountType"`
	ToAccountType   string  `json:"toAccountType" form:"toAccountType"`
	AccountCurrency string  `json:"accountCurrency" form:"accountCurrency"`
	AcqTranFee      float32 `json:"acqTranFee" form:"acqTranFee"`
	IssuerTranFee   float32 `json:"issuerTranFee" form:"issuerTranFee"`

	// billers
	BillInfo string `json:"billInfo" form:"billInfo"`
	Payees   string `json:"payees" form:"payees"`

	// tran time
	OriginalTranUUID     string `json:"originalTranUUID" form:"originalTranUUID"`
	OriginalTranDateTime string `json:"originalTranDateTime" form:"originalTranDateTime"`

	// User settings
	Username     string `json:"userName" Form:"userName"`
	UserPassword string `json:"userPassword" form:"userPassword"`

	// Entities
	EntityType  string `json:"entityType" form:"entityType"`
	EntityId    string `json:"entityId" form:"entityId"`
	EntityGroup string `json:"entityGroup" form:"entityGroup"`
	PubKeyValue string `json:"pubKeyValue" form:"pubKeyValue"`
	Email       string `json:"email" form:"email"`
	ExtraInfo   string `json:"extraInfo" form:"extraInfo"`

	OriginalTransactionId  string                 `json:"originalTransactionId" form:"originalTransactionId"` // for QR, sometimes
	MBR                    string                 `json:"mbr" form:"mbr"`
	PhoneNo                string                 `json:"phoneNo" form:"phoneNo"`
	NewIpin                string                 `json:"newIPIN" form:"newIPIN"`
	NewUserPassword        string                 `json:"newUserPassword" form:"newUserPassword"`
	SecurityQuestion       string                 `json:"securityQuestion" form:"securityQuestion"`
	SecurityQuestionAnswer string                 `json:"securityQuestionAnswer" form:"securityQuestionAnswer"`
	AdminUserName          string                 `json:"adminUserName" form:"adminUserName"`
	DynamicFees            float32                `json:"dynamicFees,omitempty" form:"dynamicFees"`
	TransactionID          string                 `json:"transactionId,omitempty" form:"transactionId"`
	MerchantID             string                 `json:"merchantID,omitempty" form:"merchantID"`
	AuthenticationType     string                 `json:"authenticationType,omitempty" form:"authenticationType"`
	OriginalTransaction    map[string]interface{} `json:"originalTransaction" form:"originalTransaction"`
	OriginalTranType       string                 `json:"originalTranType" form:"originalTranType"`
	FinancialInstitutionID string                 `json:"financialInstitutionId" form:"financialInstitutionId"`
}

type ConsumerStatusFields

type ConsumerStatusFields struct {
	ConsumerCommonFields
	OriginalTranUUID string `json:"originalTranUUID" binding:"required"`
}

func (*ConsumerStatusFields) MustMarshal

func (f *ConsumerStatusFields) MustMarshal() []byte

type ConsumerTransactionStatusFields

type ConsumerTransactionStatusFields struct {
	ConsumerCommonFields
	OriginalTranUUID string `json:"originalTranUUID" form:"originalTranUUID" binding:"required"`
}

type ConsumerWorkingKeyFields

type ConsumerWorkingKeyFields struct {
	ConsumerCommonFields
}

func (*ConsumerWorkingKeyFields) MustMarshal

func (f *ConsumerWorkingKeyFields) MustMarshal() []byte

type ConsumersBillersFields

type ConsumersBillersFields struct {
	PayeeId     string `json:"payeeId" form:"payeeId" binding:"required"`
	PaymentInfo string `json:"paymentInfo" form:"paymentInfo" binding:"required"`
}

func (*ConsumersBillersFields) MustMarshal

func (f *ConsumersBillersFields) MustMarshal() []byte

type ConsumrAccountTransferFields

type ConsumrAccountTransferFields struct {
	ConsumerCommonFields
	ConsumerCardHolderFields
	AmountFields
	ToAccount string `json:"toAccount" binding:"required"`
}

type CreateErrFn

type CreateErrFn func(r *Response) error

CreateErrFn is a function that creates an error from a given Response.

type DefaultValidator

type DefaultValidator struct {
	// contains filtered or unexported fields
}

func (*DefaultValidator) Engine

func (v *DefaultValidator) Engine() interface{}

func (*DefaultValidator) ValidateStruct

func (v *DefaultValidator) ValidateStruct(obj interface{}) error

type DisputeFields

type DisputeFields struct {
	Time    string  `json:"time,omitempty"`
	Service string  `json:"service,omitempty"`
	UUID    string  `json:"uuid,omitempty"`
	STAN    int     `json:"stan,omitempty"`
	Amount  float32 `json:"amount,omitempty"`
}

func (*DisputeFields) New

type DynamicFeesFields

type DynamicFeesFields struct {
	CardTransferfees   float32 `json:"p2p_fees"`
	CustomFees         float32 `json:"custom_fees"`
	SpecialPaymentFees float32 `json:"special_payment_fees"`
}

DynamicFeesFields for p2p and mohe dynamic fees case

func NewDynamicFeesWithDefaults added in v0.3.0

func NewDynamicFeesWithDefaults() DynamicFeesFields

type EBSMapFields

type EBSMapFields struct {
	// these
	Balance          map[string]interface{} `json:"balance,omitempty"`
	PaymentInfo      string                 `json:"paymentInfo,omitempty"`
	BillInfo         map[string]interface{} `json:"billInfo,omitempty"`
	LastTransactions []QRPurchase           `json:"lastTransactions,omitempty"`
}

special case to handle ebs non-DB-able fields e.g., hashmaps and other complex types

type EBSParserFields

type EBSParserFields struct {
	EBSMapFields
	EBSResponse
	OriginalTransaction EBSResponse `json:"originalTransaction,omitempty"`
}

you have to update this to account for the non-db-able fields

func EBSHttpClient

func EBSHttpClient(url string, req []byte) (int, EBSParserFields, error)

EBSHttpClient the client to interact with EBS

func (*EBSParserFields) MarshalBinary

func (p *EBSParserFields) MarshalBinary() ([]byte, error)

To allow Redis to use this struct directly in marshaling

func (*EBSParserFields) UnmarshalBinary

func (p *EBSParserFields) UnmarshalBinary(data []byte) error

To allow Redis to use this struct directly in marshaling

type EBSResponse

type EBSResponse struct {
	gorm.Model
	TokenID                uint
	TerminalID             string  `json:"terminalId,omitempty"`
	SystemTraceAuditNumber int     `json:"systemTraceAuditNumber,omitempty"`
	ClientID               string  `json:"clientId,omitempty"`
	PAN                    string  `json:"PAN,omitempty"`
	ServiceID              string  `json:"serviceId,omitempty"`
	TranAmount             float32 `json:"tranAmount,omitempty"`
	PhoneNumber            string  `json:"phoneNumber,omitempty"`
	FromAccount            string  `json:"fromAccount,omitempty"`
	ToAccount              string  `json:"toAccount,omitempty"`
	FromCard               string  `json:"fromCard,omitempty"`
	ToCard                 string  `json:"toCard,omitempty"`
	OTP                    string  `json:"otp,omitempty"`
	OTPID                  string  `json:"otpId,omitempty"`
	TranCurrencyCode       string  `json:"tranCurrencyCode,omitempty"`
	EBSServiceName         string  `json:"-,omitempty"`
	WorkingKey             string  `json:"workingKey,omitempty" gorm:"-"`
	PayeeID                string  `json:"payeeId,omitempty"`
	// Consumer fields
	PubKeyValue     string `json:"pubKeyValue,omitempty" form:"pubKeyValue"`
	UUID            string `json:"UUID,omitempty" form:"UUID" gorm:"primaryKey;not null;"`
	ResponseMessage string `json:"responseMessage,omitempty"`
	ResponseStatus  string `json:"responseStatus,omitempty"`
	ResponseCode    int    `json:"responseCode"`
	ReferenceNumber string `json:"referenceNumber,omitempty"`
	ApprovalCode    string `json:"approvalCode,omitempty"`
	VoucherNumber   string `json:"voucherNumber,omitempty"`
	VoucherCode     string `json:"voucherCode,omitempty"`
	//FIXME(adonese): #166 ministatement records need to be properly parsed to sqlite compatible type
	MiniStatementRecords MinistatementDB `json:"miniStatementRecords,omitempty" gorm:"type:text[]"` //make this gorm-able
	DisputeRRN           string          `json:"DisputeRRN,omitempty"`
	AdditionalData       string          `json:"additionalData,omitempty"`
	TranDateTime         string          `json:"tranDateTime,omitempty"`
	TranFee              *float32        `json:"tranFee,omitempty"`
	AdditionalAmount     *float32        `json:"additionalAmount,omitempty"`
	AcqTranFee           *float32        `json:"acqTranFee,omitempty"`
	IssTranFee           *float32        `json:"issuerTranFee,omitempty"`
	TranCurrency         string          `json:"tranCurrency,omitempty"`

	// QR payment fields
	MerchantID               string  `json:"merchantID,omitempty"`
	GeneratedQR              string  `json:"generatedQR,omitempty"`
	Bank                     string  `json:"bank,omitempty"`
	Name                     string  `json:"name,omitempty"`
	CardType                 string  `json:"card_type,omitempty"`
	LastPAN                  string  `json:"last4PANDigits,omitempty"`
	TransactionID            string  `json:"transactionId,omitempty"`
	CheckDuplicate           string  `json:"checkDuplicate,omitempty"`
	AuthenticationType       string  `json:"authenticationType,omitempty"`
	AccountCurrency          string  `json:"accountCurrency,omitempty"`
	ToAccountType            string  `json:"toAccountType,omitempty"`
	FromAccountType          string  `json:"fromAccountType,omitempty"`
	EntityID                 string  `json:"entityId,omitempty"`
	EntityType               string  `json:"entityType,omitempty"`
	Username                 string  `json:"userName,omitempty"`
	DynamicFees              float32 `json:"dynamicFees,omitempty"`
	QRCode                   string  `json:"QRCode,omitempty"`
	ExpDate                  string  `json:"expDate,omitempty"` // FIXME(adonese): don't store it in database
	FinancialInstitutionID   string  `json:"financialInstitutionId,omitempty"`
	CreationDate             string  `json:"creationDate,omitempty"`
	PanCategory              string  `json:"panCategory,omitempty"`
	EntityGroup              string  `json:"entityGroup,omitempty"`
	MerchantAccountType      string  `json:"merchantAccountType,omitempty"`
	MerchantAccountReference string  `json:"merchantAccountReference,omitempty"`
	MerchantName             string  `json:"merchantName,omitempty"`
	MerchantCity             string  `json:"merchantCity,omitempty"`
	MobileNo                 string  `json:"mobileNo,omitempty"`
	MerchantCategoryCode     string  `json:"merchantCategoryCode,omitempty"`
	PostalCode               string  `json:"postalCode,omitempty"`
}

EBSResponse represent a struct that captures all of EBS response fields and map them into Transaction table We should really split this up between consumer and merchant. It is just too complicated to manage now

func (EBSResponse) GetByUUID added in v0.3.0

func (res EBSResponse) GetByUUID(uuid string, db *gorm.DB) (EBSResponse, error)

func (EBSResponse) GetEBSUUID added in v0.3.0

func (e EBSResponse) GetEBSUUID(originalUUID string, db *gorm.DB, noebsConfig *NoebsConfig) (EBSResponse, error)

func (*EBSResponse) MaskPAN

func (res *EBSResponse) MaskPAN()

MaskPAN returns the last 4 digit of the PAN. We shouldn't care about the first 6

func (EBSResponse) TableName

func (EBSResponse) TableName() string

TableName overrides the default table name for gorm

type EntityFields

type EntityFields struct {
	EntityID    string `json:"entityId"`    // starts with 249 initials
	EntityType  string `json:"entityType"`  //defaults to "Phone No"
	EntityGroup string `json:"entityGroup"` // defaults to 1
}

type ErrDetails

type ErrDetails map[string]interface{}

func ErrorToString

func ErrorToString(e validator.FieldError) ErrDetails

type ErrorCode

type ErrorCode string

ErrorCode represents the platform-wide error codes that can be raised by Admin SDK APIs.

const (
	// InvalidArgument is a OnePlatform error code.
	InvalidArgument ErrorCode = "INVALID_ARGUMENT"

	// FailedPrecondition is a OnePlatform error code.
	FailedPrecondition ErrorCode = "FAILED_PRECONDITION"

	// OutOfRange is a OnePlatform error code.
	OutOfRange ErrorCode = "OUT_OF_RANGE"

	// Unauthenticated is a OnePlatform error code.
	Unauthenticated ErrorCode = "UNAUTHENTICATED"

	// PermissionDenied is a OnePlatform error code.
	PermissionDenied ErrorCode = "PERMISSION_DENIED"

	// NotFound is a OnePlatform error code.
	NotFound ErrorCode = "NOT_FOUND"

	// Aborted is a OnePlatform error code.
	Aborted ErrorCode = "ABORTED"

	// AlreadyExists is a OnePlatform error code.
	AlreadyExists ErrorCode = "ALREADY_EXISTS"

	// ResourceExhausted is a OnePlatform error code.
	ResourceExhausted ErrorCode = "RESOURCE_EXHAUSTED"

	// Cancelled is a OnePlatform error code.
	Cancelled ErrorCode = "CANCELLED"

	// DataLoss is a OnePlatform error code.
	DataLoss ErrorCode = "DATA_LOSS"

	// Unknown is a OnePlatform error code.
	Unknown ErrorCode = "UNKNOWN"

	// Internal is a OnePlatform error code.
	Internal ErrorCode = "INTERNAL"

	// Unavailable is a OnePlatform error code.
	Unavailable ErrorCode = "UNAVAILABLE"

	// DeadlineExceeded is a OnePlatform error code.
	DeadlineExceeded ErrorCode = "DEADLINE_EXCEEDED"
)

type ErrorDetails

type ErrorDetails struct {
	Message string      `json:"message"`
	Code    int         `json:"code"`
	Status  string      `json:"status"`
	Details interface{} `json:"details"`
}

type ErrorResponse

type ErrorResponse struct {
	ErrorDetails
}

type FirebaseError

type FirebaseError struct {
	ErrorCode ErrorCode
	String    string
	Response  *http.Response
	Ext       map[string]interface{}
}

FirebaseError is an error type containing an error code string.

func NewFirebaseError

func NewFirebaseError(resp *Response) *FirebaseError

NewFirebaseError creates a new error from the given HTTP response.

func NewFirebaseErrorOnePlatform

func NewFirebaseErrorOnePlatform(resp *Response) *FirebaseError

NewFirebaseErrorOnePlatform parses the response payload as a GCP error response and create an error from the details extracted.

If the response failes to parse, or otherwise doesn't provide any useful details NewFirebaseErrorOnePlatform creates an error with some sensible defaults.

func (*FirebaseError) Error

func (fe *FirebaseError) Error() string

type GenerateVoucherFields

type GenerateVoucherFields struct {
	PurchaseFields
	PhoneNumber string `json:"phoneNumber" binding:"required"`
}

type HTTPClient

type HTTPClient struct {
	Client      *http.Client
	RetryConfig *RetryConfig
	CreateErrFn CreateErrFn
	SuccessFn   SuccessFn
	Opts        []HTTPOption
}

HTTPClient is a convenient API to make HTTP calls.

This API handles repetitive tasks such as entity serialization and deserialization when making HTTP calls. It provides a convenient mechanism to set headers and query parameters on outgoing requests, while enforcing that an explicit context is used per request. Responses returned by HTTPClient can be easily unmarshalled as JSON.

HTTPClient also handles automatically retrying failed HTTP requests.

func NewHTTPClient

func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*HTTPClient, string, error)

NewHTTPClient creates a new HTTPClient using the provided client options and the default RetryConfig.

NewHTTPClient returns the created HTTPClient along with the target endpoint URL. The endpoint is obtained from the client options passed into the function.

func WithDefaultRetryConfig

func WithDefaultRetryConfig(hc *http.Client) *HTTPClient

WithDefaultRetryConfig creates a new HTTPClient using the provided client and the default RetryConfig.

The default RetryConfig retries requests on all low-level network errors as well as on HTTP ServiceUnavailable (503) error. Repeatedly failing requests are retried up to 4 times with exponential backoff. Retry delay is never longer than 2 minutes.

func (*HTTPClient) Do

func (c *HTTPClient) Do(ctx context.Context, req *Request) (*Response, error)

Do executes the given Request, and returns a Response.

If a RetryConfig is specified on the client, Do attempts to retry failing requests.

If SuccessFn is set on the client or on the request, the response is validated against that function. If this validation fails, returns an error. These errors are created using the CreateErrFn on the client or on the request. If neither is set, CreatePlatformError is used as the default error function.

func (*HTTPClient) DoAndUnmarshal

func (c *HTTPClient) DoAndUnmarshal(ctx context.Context, req *Request, v interface{}) (*Response, error)

DoAndUnmarshal behaves similar to Do, but additionally unmarshals the response payload into the given pointer.

Unmarshal takes place only if the response does not represent an error (as determined by the Do function) and v is not nil. If the unmarshal fails, an error is returned even if the original response indicated success.

type HTTPEntity

type HTTPEntity interface {
	Bytes() ([]byte, error)
	Mime() string
}

HTTPEntity represents a payload that can be included in an outgoing HTTP request.

func NewJSONEntity

func NewJSONEntity(v interface{}) HTTPEntity

NewJSONEntity creates a new HTTPEntity that will be serialized into JSON. All use NewJSONEntity to marshall respective fields onto HTTPEntity interface

type HTTPOption

type HTTPOption func(*http.Request)

HTTPOption is an additional parameter that can be specified to customize an outgoing request.

func WithHeader

func WithHeader(key, value string) HTTPOption

WithHeader creates an HTTPOption that will set an HTTP header on the request.

func WithQueryParam

func WithQueryParam(key, value string) HTTPOption

WithQueryParam creates an HTTPOption that will set a query parameter on the request.

func WithQueryParams

func WithQueryParams(qp map[string]string) HTTPOption

WithQueryParams creates an HTTPOption that will set all the entries of qp as query parameters on the request.

type IPINResponse

type IPINResponse struct {
	UUID            string `json:"UUID"`
	TranDateTime    int    `json:"tranDateTime"`
	ResponseMessage string `json:"responseMessage"`
	ResponseStatus  string `json:"responseStatus"`
	PubKeyValue     string `json:"pubKeyValue"`
	ResponseCode    int64  `json:"responseCode"`
	Pan             string `json:"pan"`
	ExpDate         string `json:"expDate"`
	Username        string `json:"userName"`
}

type ImportantEBSFields

type ImportantEBSFields struct {
}

type IsAliveFields

type IsAliveFields struct {
	CommonFields
}

func (*IsAliveFields) MustMarshal

func (f *IsAliveFields) MustMarshal() []byte

type ItemID

type ItemID struct {
	ID     int  `json:"id,omitempty" binding:"required"`
	IsMain bool `json:"is_main"`
}

type Merchant

type Merchant struct {
	MerchantID           string `json:"merchant_id" form:"merchant_id" gorm:"index"`
	MerchantName         string `json:"name" form:"name" binding:"required" gorm:"column:name"`
	MerchantCity         string `json:"city" form:"city" binding:"required" gorm:"column:city"`
	MerchantMobileNumber string `json:"mobile" form:"mobile" binding:"required,max=10" gorm:"column:mobile; index:,unqiue"`
	IDType               int    `json:"id_type" form:"id_type" binding:"required" gorm:"column:id_type"`
	IDNo                 string `json:"id_no" form:"id_no" binding:"required" gorm:"column:id_no"`
	TerminalID           string `json:"-" gorm:"-"`
	PushID               string `json:"push_id" gorm:"column:push_id"`
	Password             string `json:"password"`
	IsVerifed            bool   `json:"is_verified"`
	BillerID             string `json:"biller_id"`
	EBSBiller            string `json:"ebs_biller"`
	CardNumber           string `json:"card" gorm:"column:card"`
	Hooks                string `json:"hooks" gorm:"hooks"`
	URL                  string `json:"url" gorm:"url"`
}

Merchant constructs ebs qualfied merchant

func (*Merchant) Details

func (m *Merchant) Details() []mLabel

func (*Merchant) MarshalBinary

func (m *Merchant) MarshalBinary() ([]byte, error)

func (*Merchant) ToMap

func (m *Merchant) ToMap() map[string]interface{}

type MerchantRegistrationFields

type MerchantRegistrationFields struct {
	ConsumerCommonFields
	Merchant
	//allowed fields are CARD only for now. CF ebs document
	MerchantAccountType string `json:"merchantAccountType" binding:"required"`
	// this is the pan
	MerchantAccountReference string `json:"merchantAccountReference" binding:"required"`
	ExpDate                  string `json:"expDate" binding:"required"`
}

func (*MerchantRegistrationFields) MustMarshal

func (f *MerchantRegistrationFields) MustMarshal() []byte

type MiniStatementFields

type MiniStatementFields struct {
	CommonFields
	CardInfoFields
}

func (*MiniStatementFields) MustMarshal

func (f *MiniStatementFields) MustMarshal() []byte

type MinistatementDB

type MinistatementDB []map[string]interface{}

func (*MinistatementDB) Scan

func (m *MinistatementDB) Scan(value interface{}) error

func (MinistatementDB) Value

func (m MinistatementDB) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type MobileRedis

type MobileRedis struct {
	Mobile   string `json:"mobile" binding:"required"`
	Provider string `json:"provider"`
	IsMain   bool   `json:"is_main"`
}

type MockClock

type MockClock struct {
	Timestamp time.Time
}

MockClock can be used to mock current time during tests.

func (*MockClock) Now

func (m *MockClock) Now() time.Time

Now returns the timestamp set in the MockClock.

type NoebsConfig

type NoebsConfig struct {
	OneSignal    string `json:"onesignal_key"`
	DatabasePath string `json:"db_path"`
	SMSAPIKey    string `json:"sms_key"`
	SMSSender    string `json:"sms_sender"`
	SMSGateway   string `json:"sms_gateway"`
	RedisPort    string `json:"redis_port"`
	JWTKey       string `json:"jwt_secret"`
	Sentry       string `json:"sentry"`
	Port         string `json:"port"`

	IsConsumerProd bool `json:"is_consumer_prod"`
	IsMerchantProd bool `json:"is_merchant_prod"`

	ConsumerQAIP string `json:"consumer_qa"`
	MerchantQAIP string `json:"merchant_qa"`
	ConsumerProd string `json:"consumer_prod"`
	MerchantProd string `json:"merchant_prod"`

	ConsumerIP string
	MerchantIP string
	IPINIp     string

	// Those should be depricated they are confusing with no good use case
	IPIN   string `json:"ipin_prod"`
	IPINQA string `json:"ipin_qa"`

	ConsumerID string `json:"-"` // The ID that will be used within noebs to identify the consumer
	MerchantID string `json:"-"` // The ID that will be used within noebs to identify the merchant

	ConsumerQAID string `json:"consumer_qa_id"` // EBS application ID for mobile and card not present services prod)
	MerchantQAID string `json:"merchant_qa_id"` // EBS client ID for pos and merchant services (prod)

	ConsumerProdID string `json:"consumer_prod_id"` // EBS application ID for mobile and card not present services prod)
	MerchantProdID string `json:"merchant_prod_id"` // EBS client ID for pos and merchant services (prod)

	// IPIN generation configs
	EBSIPINUsername string `json:"ipin_username"`
	EBSIPINPassword string `json:"ipin_password"`

	// Bill inquiry specific hard-coded card holder information
	// We highly don't recommend to store data, but this can be an exception
	BillInquiryPAN     string `json:"pan"`
	BillInquiryPIN     string `json:"pin"`
	BillInquiryIPIN    string `json:"ipin"`
	BillInquiryExpDate string `json:"exp_date"`
	EBSConsumerKey     string `json:"pub_key"`
	EBSIpinKey         string `json:"ipin_key"`

	// server config
	Cors    []string `json:"cors"`
	IsDebug bool     `json:"is_debug"` // set as true if you want to have more debug options

	// SMS message
	SMSMessage string `json:"sms_message"`

	// This the base of the link for payment links
	PaymentLinkBase string `json:"payment_link_base"`
}

NoebsConfig contains all about noebs configuration, including ebs ips and ports, redis ips, and so on. The file currently reads from `ebs_fields/.secrets.json` using go embedding fs. NoebsConfig can be accessed via [NoebsSecrets] which is initialized in the ebs_fields package in the init method.

func (*NoebsConfig) Defaults

func (n *NoebsConfig) Defaults()

type NoebsDatabase added in v0.3.0

type NoebsDatabase interface {
	OverrideField() string
	GetPk() string
}

NoebsDatabase is an interface that can be used throughout the codebase to make the process of many sql operations more seamless

type PayeesListFields

type PayeesListFields struct {
	CommonFields
}

type PaymentDetails

type PaymentDetails struct {
	Account     string  `json:"account,omitempty" form:"account"`
	Amount      float64 `json:"amount,omitempty" form:"amount"`
	Description string  `json:"description,omitempty" form:"description"`
}

type PurchaseFields

type PurchaseFields struct {
	WorkingKeyFields
	CardInfoFields
	AmountFields
}

func (*PurchaseFields) MustMarshal

func (f *PurchaseFields) MustMarshal() []byte

type PurchaseWithCashBackFields

type PurchaseWithCashBackFields struct {
	PurchaseFields
}

func (*PurchaseWithCashBackFields) MustMarshal

func (f *PurchaseWithCashBackFields) MustMarshal() []byte

type QRMerchantFields

type QRMerchantFields struct {
	MerchantAccountType      string `json:"merchantAccountType" form:"merchantAccountType" binding:"required"`
	MerchantAccountReference string `json:"merchantAccountReference" form:"merchantAccountReference" binding:"required"`
	MerchantName             string `json:"merchantName" form:"merchantName" binding:"required"`
	MerchantCity             string `json:"merchantCity" form:"merchantCity" binding:"required"`
	MobileNo                 string `json:"mobileNo" form:"mobileNo" binding:"required"`
	IDType                   string `json:"idType" form:"idType" binding:"required"`
	IdNo                     string `json:"idNo" form:"idNo" binding:"required"`
	ExpDate                  string `json:"expDate" form:"expDate" binding:"required_if=MerchantAccountType CARD"`
}

type QRPurchase

type QRPurchase struct {
	AcqTranFee               string `json:"acqTranFee,omitempty"`
	ApplicationID            string `json:"applicationId,omitempty"`
	AuthenticationType       string `json:"authenticationType,omitempty"`
	IssuerTranFee            string `json:"issuerTranFee,omitempty"`
	MerchantAccountExpDate   string `json:"merchantAccountExpDate,omitempty"`
	MerchantAccountReference string `json:"merchantAccountReference,omitempty"`
	MerchantAccountType      string `json:"merchantAccountType,omitempty"`
	MerchantCity             string `json:"merchantCity,omitempty"`
	MerchantID               string `json:"merchantID,omitempty"`
	MerchantMobileNo         string `json:"merchantMobileNo,omitempty"`
	MerchantName             string `json:"merchantName,omitempty"`
	Pan                      string `json:"pan,omitempty"`
	ResponseCode             int64  `json:"responseCode,omitempty"`
	ResponseMessage          string `json:"responseMessage,omitempty"`
	ResponseStatus           string `json:"responseStatus,omitempty"`
	TranAmount               int64  `json:"tranAmount,omitempty"`
	TranDateTime             string `json:"tranDateTime,omitempty"`
	TranType                 string `json:"tranType,omitempty"`
	TransactionID            string `json:"transactionId,omitempty"`
	UUID                     string `json:"uuid,omitempty"`
}

type QrData added in v0.3.0

type QrData struct {
	UUID   string `json:"uuid"`
	ToCard string `json:"toCard,omitempty"`
	Amount int    `json:"amount,omitempty"`
}

type QuickPaymentFields

type QuickPaymentFields struct {
	EncodedPaymentToken string `json:"token"`
	ConsumerCardTransferFields
}

func (QuickPaymentFields) MarshallP2pFields

func (q QuickPaymentFields) MarshallP2pFields() []byte

type RefundFields

type RefundFields struct {
	PurchaseFields
	OriginalSTAN int `json:"originalSystemTraceAuditNumber" binding:"required"`
}

func (*RefundFields) MustMarshal

func (f *RefundFields) MustMarshal() []byte

type Request

type Request struct {
	Method      string
	URL         string
	Body        HTTPEntity
	Opts        []HTTPOption
	SuccessFn   SuccessFn
	CreateErrFn CreateErrFn
}

Request contains all the parameters required to construct an outgoing HTTP request.

type Response

type Response struct {
	Status int
	Header http.Header
	Body   []byte
	// contains filtered or unexported fields
}

Response contains information extracted from an HTTP response.

func (*Response) LowLevelResponse

func (r *Response) LowLevelResponse() *http.Response

LowLevelResponse returns an http.Response that represents the underlying low-level HTTP response.

This always returns a buffered copy of the original HTTP response. Body can be read from the returned response with no impact on the underlying HTTP connection. Closing the Body on the returned response is a No-op.

type RetryCondition

type RetryCondition func(resp *http.Response, networkErr error) bool

RetryCondition determines if an HTTP request should be retried depending on its last outcome.

type RetryConfig

type RetryConfig struct {
	MaxRetries       int
	CheckForRetry    RetryCondition
	ExpBackoffFactor float64
	MaxDelay         *time.Duration
}

RetryConfig specifies how the HTTPClient should retry failing HTTP requests.

A request is never retried more than MaxRetries times. If CheckForRetry is nil, all network errors, and all 400+ HTTP status codes are retried. If an HTTP error response contains the Retry-After header, it is always respected. Otherwise retries are delayed with exponential backoff. Set ExpBackoffFactor to 0 to disable exponential backoff, and retry immediately after each error.

If MaxDelay is set, retries delay gets capped by that value. If the Retry-After header requires a longer delay than MaxDelay, retries are not attempted.

type ReverseFields

type ReverseFields struct {
	PurchaseFields
}

func (*ReverseFields) MustMarshal

func (f *ReverseFields) MustMarshal() []byte

type SuccessFn

type SuccessFn func(r *Response) bool

SuccessFn is a function that checks if a Response indicates success.

type Token added in v0.3.0

type Token struct {
	gorm.Model
	UserID uint

	User   User   `gorm:"-" json:",-"`
	Amount int    `json:"amount,omitempty"`
	CartID string `json:"cart_id,omitempty"`
	UUID   string `json:"uuid,omitempty" gorm:"not null;unique;uniqueIndex"`
	Note   string `json:"note,omitempty"`

	ToCard       string        `json:"toCard,omitempty"`
	EBSResponses []EBSResponse `json:"transaction,omitempty"`
	IsPaid       bool          `json:"is_paid"`
	// contains filtered or unexported fields
}

Token a struct to represent a noebs payment order Noebs payment order is an abstraction layer built on top of EBS card transfer the idea is to allow noebs users to freely accept and transfer funds, without much of hassle that is needed when trying to register as a merchant. Any user can simply generate a payment token from noebs companioned apps and then proceed with payment. Another method is to generate a QR code which can be scanned by the other end to transfer money. A payment token includes the following information, more to come later:

  1. UUID a unique UUID v4 per each operation, this is requested from ebs via [POST]/payment_token
  2. ID a unique ID per each payment token, this is an optional field left for the user to supply. In e-commerce cases, an ID represent the order ID.
  3. Amount the amount to be transferred. Amount is required. A zero amount denotes a free payment.
  4. UserID the user ID of the user who is making the payment. UserID is required.
  5. Mobile: the receipient of the payment mobile. This is an optional field
  6. Note: an optional text note to be sent to the recipient.

func Decode

func Decode(data string) (Token, error)

Decode a noebs payment token to an internal PaymentToken that we understand

func GetAllTokens

func GetAllTokens(db *gorm.DB) ([]Token, error)

GetAllTokens associated to a user.

func GetAllTokensByUserID

func GetAllTokensByUserID(userID uint, db *gorm.DB) ([]Token, error)

GetAllTokens associated to a user.

func GetAllTokensByUserIDAndCartID

func GetAllTokensByUserIDAndCartID(userID uint, cartID string, db *gorm.DB) ([]Token, error)

GetAllTokens associated to a user.

func GetTokenByUUID

func GetTokenByUUID(uuid string, db *gorm.DB) (Token, error)

GetTokenByUUID gets a preloaded token with the user's ID and their cards

func GetTokenWithResult

func GetTokenWithResult(uuid string, db *gorm.DB) (Token, error)

GetTokenByUUID gets a preloaded token with the user's ID and their cards

func GetTokenWithTransaction

func GetTokenWithTransaction(uuid string, db *gorm.DB) (Token, error)

GetTokenWithTransaction preloads a token with its transaction

func GetUserTokens

func GetUserTokens(mobile string, db *gorm.DB) ([]Token, error)

NewUserByMobile Retrieves a user from the database by mobile (username)

func NewPaymentToken

func NewPaymentToken(mobile string, db *gorm.DB) (*Token, error)

NewPaymentToken creates a new payment token and assign it to a user

func NewToken

func NewToken(db *gorm.DB) *Token

NewToken creates a new paymenttoken struct and populate it with a database

func (Token) UpsertTransaction added in v0.3.0

func (p Token) UpsertTransaction(transaction EBSResponse, uuid string) error

UpsertCards to an existing noebs user. It uses gorm' relation to amends a user cards When adding a card, make sure the card.ID is set to zero value so that gorm wouldn't confuse it for an update

type TokenCard

type TokenCard struct {
	CardInfoFields
	Fingerprint string `json:"fingerprint" binding:"required"`
}

type User

type User struct {
	gorm.Model
	Password      string `binding:"required,min=8,max=20" json:"password"`
	Fullname      string `json:"fullname"`
	Birthday      string `json:"birthday"`
	Mobile        string `json:"mobile" gorm:"primaryKey;not null;unique;uniqueIndex"`
	Email         string `json:"email"`
	Password2     string `json:"password2" gorm:"-"`
	IsMerchant    bool   `json:"is_merchant" gorm:"default:false"`
	PublicKey     string `json:"user_pubkey"`
	DeviceID      string `json:"device_id"`
	OTP           string `json:"otp"`
	SignedOTP     string `json:"signed_otp"`
	Tokens        []Token
	Beneficiaries []Beneficiary

	Cards           []Card
	FirebaseIDToken string `json:"firebase_token"`
	NewPassword     string `json:"new_password" gorm:"-"`
	IsPasswordOTP   bool   `json:"is_password_otp" gorm:"default:false"`
	Pan             string `json:"pan" gorm:"column:main_card"`
	ExpDate         string `json:"exp_date" gorm:"column:main_expdate"`
	// contains filtered or unexported fields
}

User contains User table in noebs. It should be kept simple and only contain the fields that are needed.

func GetCardsOrFail added in v0.3.0

func GetCardsOrFail(mobile string, db *gorm.DB) (*User, error)

GetCardsOrFail returns a user model and fails if user doesn't exist. It preloads an existing user model with their cards. The user model itself might be used for other cases, that's why we are not just returning Card NOTE: we are not masking cards here which is really *very* insecure to say the least.

func GetUser added in v0.3.0

func GetUser(mobile string, db *gorm.DB) (*User, error)

GetUser retrieves a user via their mobile number

func GetUserByCard added in v0.3.0

func GetUserByCard(pan string, db *gorm.DB) (User, error)

GetUserByCard retrieves a noebs user by their PAN

func GetUserByMobile added in v0.3.0

func GetUserByMobile(mobile string, db *gorm.DB) (User, error)

GetUserByMobile Retrieves a user from the database by mobile (username)

func NewUser

func NewUser(db *gorm.DB) *User

func NewUserWithBeneficiaries added in v0.3.0

func NewUserWithBeneficiaries(mobile string, db *gorm.DB) (*User, error)

func NewUserWithCards added in v0.3.0

func NewUserWithCards(mobile string, db *gorm.DB) (*User, error)

func (User) DeleteCards

func (u User) DeleteCards(cards []Card) error

DeleteCards soft-deletes a card of list of cards associated to a user

func (User) EncodePublickey

func (u User) EncodePublickey() string

EncodePublickey a helper function to encode publickey since it has ---BEGIN and new lines

func (User) EncodePublickey32 added in v0.3.0

func (u User) EncodePublickey32() string

EncodePublickey a helper function to encode publickey since it has ---BEGIN and new lines

func (User) GenerateOtp added in v0.3.0

func (u User) GenerateOtp() (string, error)

GenerateOtp for a noebs user

func (*User) GetAllTokens

func (u *User) GetAllTokens() ([]Token, error)

GetAllTokens associated to a user. This requires a populated model (u.Mobile != "")

func (*User) HashPassword

func (u *User) HashPassword() error

func (*User) NewPaymentToken

func (u *User) NewPaymentToken(amount int, note string, cartID string) (*Token, error)

NewPaymentToken creates a new payment token and assign it to a user

func (*User) SanitizeName

func (u *User) SanitizeName()

func (*User) SavePaymentToken

func (u *User) SavePaymentToken(pt *Token) error

SavePaymentToken saves the payment token to the database

func (User) UpsertBeneficiary added in v0.3.0

func (u User) UpsertBeneficiary(beneficiary []Beneficiary) error

UpsertBeneficiary adds or updates a beneficiary to a user

func (User) UpsertCards

func (u User) UpsertCards(cards []Card) error

UpsertCards to an existing noebs user. It uses gorm' relation to amends a user cards When adding a card, make sure the card.ID is set to zero value so that gorm wouldn't confuse it for an update

FIXME(adonese): since we are using gorm.Model in Card table, gorm thinks it is an ID for the card (a primary key) and as a result will do an update instead of insert

func (User) VerifyOtp added in v0.3.0

func (u User) VerifyOtp(code string) bool

GenerateOTP for a noebs user

type ValidationError

type ValidationError struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type VoucherCashInFields

type VoucherCashInFields struct {
	CommonFields
	VoucherNumber string `json:"voucherNumber" binding:"required"`
	AmountFields
	ApprovalCode string `json:"approvalCode,omitempty"`
	CardInfoFields
}

type VoucherCashOutFields

type VoucherCashOutFields struct {
	CommonFields
	PhoneNumber   string  `json:"phoneNumber" binding:"required"`
	VoucherNumber string  `json:"voucherNumber" binding:"required"`
	TranAmount    float32 `json:"tranAmount" binding:"required" form:"tranAmount"`
}

type WorkingKeyFields

type WorkingKeyFields struct {
	CommonFields
}

func (*WorkingKeyFields) MustMarshal

func (f *WorkingKeyFields) MustMarshal() []byte

Jump to

Keyboard shortcuts

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