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
- Variables
- func DeleteBeneficiary(card Beneficiary, db *gorm.DB) error
- func DeleteCard(card Card, db *gorm.DB) error
- func EbsDate() string
- func Encode(p *Token) (string, error)
- func ExpandCard(card string, userCards []Card) (string, error)
- func GetDeviceIDsByPan(pan string, db *gorm.DB) ([]string, error)
- func HasPlatformErrorCode(err error, code ErrorCode) bool
- func HasSuccessStatus(r *Response) bool
- func SaveOrUpdates(db *gorm.DB, entity NoebsDatabase, newVal any) error
- func UpdateCard(card Card, db *gorm.DB) error
- func UpdateUser(user User, db *gorm.DB) error
- func UpdateUserWithKYC(db *gorm.DB, kycRequest *KYCPassport) error
- type AccountTransferFields
- type AmountFields
- type BalanceFields
- type Beneficiary
- type BillInquiryFields
- type BillPaymentFields
- type BillerFields
- type CacheBillers
- type CacheCards
- type Card
- type CardInfoFields
- type CardTransferFields
- type CashInFields
- type CashOutFields
- type ChangePINFields
- type Clock
- type CommonFields
- type Configs
- type ConsumerAmountFields
- type ConsumerBalanceFields
- type ConsumerBillInquiryFields
- type ConsumerBillPaymentFields
- type ConsumerCardHolderFields
- type ConsumerCardInfoFields
- type ConsumerCardTransferAndMobileFields
- type ConsumerCardTransferFields
- type ConsumerCashInFields
- type ConsumerCashoOutFields
- type ConsumerCommonFields
- type ConsumerCompleteRegistrationFields
- type ConsumerGenerateIPINFields
- type ConsumerGenerateIPin
- type ConsumerGenerateIPinCompletion
- type ConsumerGenerateVoucherFields
- type ConsumerIPinFields
- type ConsumerIsAliveFields
- type ConsumerMobileTransferFields
- type ConsumerPANFromMobileFields
- type ConsumerPurchaseFields
- type ConsumerQRCompleteFields
- type ConsumerQRPaymentFields
- type ConsumerQRRefundFields
- type ConsumerQRRegistration
- type ConsumerQRStatus
- type ConsumerRegistrationFields
- type ConsumerSpecificFields
- type ConsumerStatusFields
- type ConsumerTransactionStatusFields
- type ConsumerWorkingKeyFields
- type ConsumersBillersFields
- type ConsumrAccountTransferFields
- type CreateErrFn
- type DefaultValidator
- type DisputeFields
- type DynamicFeesFields
- type EBSMapFields
- type EBSParserFields
- type EBSResponse
- type EntityFields
- type ErrDetails
- type ErrorCode
- type ErrorDetails
- type ErrorResponse
- type FirebaseError
- type GenerateVoucherFields
- type HTTPClient
- type HTTPEntity
- type HTTPOption
- type IPINResponse
- type ImportantEBSFields
- type IsAliveFields
- type ItemID
- type KYC
- type KYCPassport
- type Merchant
- type MerchantRegistrationFields
- type MiniStatementFields
- type MinistatementDB
- type MobileRedis
- type MockClock
- type NoebsConfig
- type NoebsDatabase
- type Passport
- type PayeesListFields
- type PaymentDetails
- type PurchaseFields
- type PurchaseWithCashBackFields
- type QRMerchant
- type QRMerchantFields
- type QRPurchase
- type QrData
- type QuickPaymentFields
- type RefundFields
- type Request
- type Response
- type RetryCondition
- type RetryConfig
- type ReverseFields
- type SuccessFn
- type Token
- func Decode(data string) (Token, error)
- func GetAllTokens(db *gorm.DB) ([]Token, error)
- func GetAllTokensByUserID(userID uint, db *gorm.DB) ([]Token, error)
- func GetAllTokensByUserIDAndCartID(userID uint, cartID string, db *gorm.DB) ([]Token, error)
- func GetTokenByUUID(uuid string, db *gorm.DB) (Token, error)
- func GetTokenWithResult(uuid string, db *gorm.DB) (Token, error)
- func GetTokenWithTransaction(uuid string, db *gorm.DB) (Token, error)
- func GetUserTokens(mobile string, db *gorm.DB) ([]Token, error)
- func NewPaymentToken(mobile string, db *gorm.DB) (*Token, error)
- func NewToken(db *gorm.DB) *Token
- type TokenCard
- type User
- func GetCardsOrFail(mobile string, db *gorm.DB) (*User, error)
- func GetUser(mobile string, db *gorm.DB) (*User, error)
- func GetUserByCard(pan string, db *gorm.DB) (User, error)
- func GetUserByMobile(mobile string, db *gorm.DB) (User, error)
- func GetUserWithKYCAndPassport(db *gorm.DB, mobile string) (*User, error)
- func NewUser(db *gorm.DB) *User
- func NewUserWithBeneficiaries(mobile string, db *gorm.DB) (*User, error)
- func NewUserWithCards(mobile string, db *gorm.DB) (*User, error)
- func (u User) DeleteCards(cards []Card) error
- func (u User) EncodePublickey() string
- func (u User) EncodePublickey32() string
- func (u User) GenerateOtp() (string, error)
- func (u *User) GetAllTokens() ([]Token, error)
- func (u *User) HashPassword() error
- func (u *User) NewPaymentToken(amount int, note string, cartID string) (*Token, error)
- func (u *User) SanitizeName()
- func (u *User) SavePaymentToken(pt *Token) error
- func (u User) UpsertBeneficiary(beneficiary []Beneficiary) error
- func (u User) UpsertCards(cards []Card) error
- func (u User) VerifyOtp(code string) bool
- type UserProfile
- type ValidationError
- type VoucherCashInFields
- type VoucherCashOutFields
- type WorkingKeyFields
Constants ¶
const ( BadRequest = "BadRequest" ParsingError = "ParsingError" InternalServerError = "InternalServerError" EBSError = "EBSError" )
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" )
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" )
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 ¶
var ( INVALIDPIN = 53 SUCCESS = 0 INVALIDCARD = 52 ROUTINGERROR = 72 )
var ( ContentTypeErr = customError{/* contains filtered or unexported fields */} EbsGatewayConnectivityErr = customError{/* contains filtered or unexported fields */} )
var EBSRes = make(chan CacheCards)
var EbsFailedTransaction customError
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 EbsDate ¶ added in v0.3.0
func EbsDate() string
EbsDate generates an ebs compliant date format ("ddMMYYhhmmss")
func ExpandCard ¶ added in v0.3.0
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
GetDeviceIDsByPan retrieves device_ids associated to a card number
func HasPlatformErrorCode ¶
HasPlatformErrorCode checks if the given error contains a specific error code.
func HasSuccessStatus ¶
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 ¶
UpdateCard only changes a card pan number
func UpdateUserWithKYC ¶ added in v1.1.2
func UpdateUserWithKYC(db *gorm.DB, kycRequest *KYCPassport) error
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 CacheBillers ¶ added in v0.3.0
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)
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 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 ConsumerAmountFields ¶
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 ¶
type ConsumerBillPaymentFields struct { ConsumerCommonFields ConsumerCardHolderFields AmountFields ConsumersBillersFields }
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 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 ConsumerMobileTransferFields ¶ added in v1.1.2
type ConsumerMobileTransferFields struct { ConsumerCommonFields ConsumerCardHolderFields AmountFields ToCard string `json:"toCard"` DynamicFees float32 `json:"dynamicFees,omitempty"` Mobile string `json:"mobile" binding:"required"` }
func (*ConsumerMobileTransferFields) MustMarshal ¶ added in v1.1.2
func (p2p *ConsumerMobileTransferFields) MustMarshal() []byte
MustMarshal panics if not able to marshal repsonse
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 ¶
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 ¶
func (d *DisputeFields) New(f EBSParserFields) *DisputeFields
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"` SenderPAN string `json:"-"` ReceiverPAN string `json:"-"` // BillType is the type of bill (TopUp, Electricity, Educations, ...etc) BillType string `json:"bill_type,omitempty"` // BillTo is the number associated with the bill type (TopUp: phone number, Electricity: meter number, ...etc) BillTo string `json:"bill_to,omitempty"` // BillInfo2 contains the electricicity token BillInfo2 string `json:"bill_info2,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 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 ErrorCode = "UNAVAILABLE" // DeadlineExceeded is a OnePlatform error code. DeadlineExceeded ErrorCode = "DEADLINE_EXCEEDED" )
type ErrorDetails ¶
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 ¶
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 ¶
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 ¶
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 KYC ¶ added in v1.1.2
type KYCPassport ¶ added in v1.1.2
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) MarshalBinary ¶
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
type MobileRedis ¶
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
NoebsDatabase is an interface that can be used throughout the codebase to make the process of many sql operations more seamless
type Passport ¶ added in v1.1.2
type Passport struct { gorm.Model Mobile string `gorm:"primaryKey;not null;unique" json:"mobile,omitempty"` BirthDate time.Time `json:"birth_date,omitempty"` IssueDate time.Time `json:"issue_date,omitempty"` ExpirationDate time.Time `json:"expiration_date,omitempty"` NationalNumber string `json:"national_number,omitempty"` PassportNumber string `json:"passport_number,omitempty"` Gender string `json:"gender,omitempty"` Nationality string `json:"nationality,omitempty"` HolderName string `json:"holder_name,omitempty"` }
type PayeesListFields ¶
type PayeesListFields struct {
CommonFields
}
type PaymentDetails ¶
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 QRMerchant ¶ added in v1.1.2
type QRMerchant struct {
Mobile string
}
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"` // ebs uses mobile number for kyc AND also otp future reuse 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 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 ¶
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 ¶
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 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:
- UUID a unique UUID v4 per each operation, this is requested from ebs via [POST]/payment_token
- 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.
- Amount the amount to be transferred. Amount is required. A zero amount denotes a free payment.
- UserID the user ID of the user who is making the payment. UserID is required.
- Mobile: the receipient of the payment mobile. This is an optional field
- Note: an optional text note to be sent to the recipient.
func GetAllTokens ¶
GetAllTokens associated to a user.
func GetAllTokensByUserID ¶
GetAllTokens associated to a user.
func GetAllTokensByUserIDAndCartID ¶
GetAllTokens associated to a user.
func GetTokenByUUID ¶
GetTokenByUUID gets a preloaded token with the user's ID and their cards
func GetTokenWithResult ¶
GetTokenByUUID gets a preloaded token with the user's ID and their cards
func GetTokenWithTransaction ¶
GetTokenWithTransaction preloads a token with its transaction
func GetUserTokens ¶
NewUserByMobile Retrieves a user from the database by mobile (username)
func NewPaymentToken ¶
NewPaymentToken creates a new payment token and assign it to a user
type TokenCard ¶
type TokenCard struct { CardInfoFields Fingerprint string `json:"fingerprint" binding:"required"` }
type User ¶
type User struct { gorm.Model Created int64 `gorm:"autoCreateTime"` Password string `binding:"required,min=8,max=20" json:"password"` Fullname string `json:"fullname"` Username string `json:"username"` Gender string `json:"gender"` Birthday string `json:"birthday"` 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"` MainCard string `json:"main_card" gorm:"column:main_card"` ExpDate string `json:"exp_date" gorm:"column:main_expdate"` Language string `json:"language"` IsVerified bool `json:"is_verified"` Mobile string `json:"mobile" gorm:"primaryKey;not null;unique;uniqueIndex"` KYC *KYC `gorm:"foreignKey:UserMobile;references:Mobile"` // 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
GetCardsOrFail returns a user model and fails if user doesn't exist. It loads 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 GetUserByCard ¶ added in v0.3.0
GetUserByCard retrieves a noebs user by their PAN
func GetUserByMobile ¶ added in v0.3.0
GetUserByMobile Retrieves a user from the database by mobile (username)
func GetUserWithKYCAndPassport ¶ added in v1.1.2
GetUserWithKYCAndPassport retrieves a User model from the database by mobile number, along with its associated KYC and Passport models. It uses the GORM Preload method to load the related KYC and Passport data in a single database query (eager loading). This helps reduce the number of queries to the database and can improve performance.
Parameters: - db: An open database connection from GORM. This connection is used to execute the database queries. - mobile: The mobile number of the user to retrieve. This is used to search the User model in the database.
Returns: - A pointer to the User model if the user is found, or nil if an error occurs or the user is not found. - An error if there is an issue during the retrieval process (such as a database error), or nil if no errors occur.
The returned User model includes its associated KYC and Passport models (if they exist). If the user does not have associated KYC or Passport data, the corresponding fields in the User model are nil. If the user does not exist in the database, the function returns an error.
Example usage: user, err := GetUserWithKYCAndPassport(db, "0111493885")
if err != nil { log.Fatalf("Error retrieving user: %v", err) }
fmt.Printf("User: %+v", user)
This will output the User model with its associated KYC and Passport models (if they exist).
func NewUserWithBeneficiaries ¶ added in v0.3.0
func NewUserWithCards ¶ added in v0.3.0
func (User) DeleteCards ¶
DeleteCards soft-deletes a card of list of cards associated to a user
func (User) EncodePublickey ¶
EncodePublickey a helper function to encode publickey since it has ---BEGIN and new lines
func (User) EncodePublickey32 ¶ added in v0.3.0
EncodePublickey a helper function to encode publickey since it has ---BEGIN and new lines
func (User) GenerateOtp ¶ added in v0.3.0
GenerateOtp for a noebs user
func (*User) GetAllTokens ¶
GetAllTokens associated to a user. This requires a populated model (u.Mobile != "")
func (*User) HashPassword ¶
func (*User) NewPaymentToken ¶
NewPaymentToken creates a new payment token and assign it to a user
func (*User) SanitizeName ¶
func (u *User) SanitizeName()
func (*User) SavePaymentToken ¶
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 ¶
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
type UserProfile ¶ added in v1.1.2
type UserProfile struct { Fullname string `json:"fullname" binding:"required,min=1"` Username string `json:"username" binding:"min=1"` Email string `json:"email" binding:"email"` Birthday string `json:"birthday"` Gender string `json:"gender"` }
UserProfile is a subset of the User struct, it contains information that appear in the user profile and which user can change.
type ValidationError ¶
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