consumer

package
v0.0.0-...-1985c56 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package consumer provides services for EBS consumer APIs, and custom apis we have developed as well. It offers a seamless and unified api to be used for both merchant pos and mobile payment

EBS Services

- Get Balance

- Working Key

- Is Alive

- Card transfer

- Billers

Special Payment

Special Payment is a secure way to tokenize payments for external service providers through a custom url link. The URL is only valid once and it cannot be reused.

Workflow

Here's how the system works.

- Generate a payment token (/consumer/generate_token)

Parameters: - amount

- biller id

It will return a new response with a UUID that to be used by the client's users for payment.

- Special payment (/consumer/special_payment/:UUID)

Parameters:

- tranAmount (the same as before!)

- billerId

- ConsumerServices payload

It will return 400 ONLY if the amount OR the biller id didn't match the specified UUID in the system

Examples

cURL:

1. Generate Token curl -X POST https://api.soluspay.net/api/v1/payment_token -d '{"amount": 10}'

> {"result":{"amount":10,"uuid":"6eb3ae20-ecbc-4603-b079-ed98549cf9f2"},"uuid":"6eb3ae20-ecbc-4603-b079-ed98549cf9f2"}

2. Inquire token via UUID curl -X GET https://api.soluspay.net/api/v1/payment/6eb3ae20-ecbc-4603-b079-ed98549cf9f2 -d '{"amount": 10}'

3. Complete Payment curl -X POST https://api.soluspay.net/api/v1/payment/6eb3ae20-ecbc-4603-b079-ed98549cf9f2 -d '{"amount": 10}'

NOTE that in payment inquiry we use GET method, while we use POST for payment

* Note authentication might be added to this API

PIN Block

Please advice with ebs documentations about iPIN block encryption. You can cite these locations for iPIN implementation:

- https://github.com/adonese/donates (JS) - https://github.com/jadenfreude/noebs-wasm (GO) - https://github.com/adonese/cashq (Java)

Index

Constants

View Source
const (
	SPECIAL_BILLERS = "noebs:billers"
)

Variables

BillChan it is used to asyncronysly parses ebs response to get and assign values to the billers such as assigning the name to utility personal payment info

View Source
var (
	ErrCreateDbRow = errors.New("unable to create a new db row/column")
)

Functions

func BillerHooks

func BillerHooks()

BillerHooks submits results to external endpoint

func GetRandomName

func GetRandomName(retry int) string

GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective_surname". For example 'focused_turing'. If retry is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`

func GetServiceID

func GetServiceID(c *gin.Context)

FIXME issue #61

func NewCashout

func NewCashout(r *redis.Client) paymentTokens

NewCashout experimental interface to make cashout publicaly availabe.

func NewPayment

func NewPayment(r *redis.Client) *paymentTokens

NewPayment generate a new payment token to be used by consumers

func Routes

func Routes(groupName string, route *gin.Engine, db *gorm.DB, redisClient *redis.Client)

Routes get all consumer routes to be used in main noebs program

Types

type Auther

type Auther interface {
	VerifyJWT(token string) (*gateway.TokenClaims, error)
	GenerateJWT(token string) (string, error)
}

type Service

type Service struct {
	utils.Service
}

Service consumer for utils.Service struct

func (*Service) AccountTransfer

func (s *Service) AccountTransfer(c *gin.Context)

AccountTransfer performs p2p transactions

func (*Service) AddCards

func (s *Service) AddCards(c *gin.Context)

AddCards Allow users to add card to their profile if main_card was set to true, then it will be their main card AND it will remove the previously selected one FIXME

func (*Service) AddMobile

func (s *Service) AddMobile(c *gin.Context)

AddMobile adds a mobile number to the current authorized user

func (*Service) Balance

func (s *Service) Balance(c *gin.Context)

Balance gets performs get balance transaction for the provided card info

func (*Service) BillInquiry

func (s *Service) BillInquiry(c *gin.Context)

BillInquiry for telecos, utility and government (billers inquiries)

func (*Service) BillPayment

func (s *Service) BillPayment(c *gin.Context)

BillPayment is responsible for utility, telecos, e-government and other payment services

func (*Service) BillerTrans

func (s *Service) BillerTrans(c *gin.Context)

BillerTrans to get all transaction to specific biller_id

func (*Service) CancelBiller

func (s *Service) CancelBiller(c *gin.Context)

CancelBiller using its issued uuid

func (*Service) CardFromNumber

func (s *Service) CardFromNumber(c *gin.Context)

CardFromNumber gets the gussesed associated mobile number to this pan

func (*Service) CardTransfer

func (s *Service) CardTransfer(c *gin.Context)

CardTransfer performs p2p transactions

func (*Service) CashoutClaims

func (s *Service) CashoutClaims(c *gin.Context)

CashoutClaims used by merchants to make a cashout

func (*Service) CompleteIpin

func (s *Service) CompleteIpin(c *gin.Context)

CompleteIpin performs an otp check from ebs to complete ipin change transaction

func (*Service) CompleteRegistration

func (s *Service) CompleteRegistration(c *gin.Context)

CompleteRegistration step 2 in card issuance process

func (*Service) CreateMerchant

func (s *Service) CreateMerchant(c *gin.Context)

CreateMerchant creates new noebs merchant

func (*Service) EbsGetCardInfo

func (s *Service) EbsGetCardInfo(c *gin.Context)

EbsGetCardInfo get card holder name from pan. Currently is limited to telecos only

func (*Service) EditCard

func (s *Service) EditCard(c *gin.Context)

EditCard allow authorized users to edit their cards (e.g., edit pan / expdate)

func (*Service) GenerateCashoutClaim

func (s *Service) GenerateCashoutClaim(c *gin.Context)

GenerateCashoutClaim generates a new cashout claim. Used by merchant to issue a new claim

func (*Service) GenerateIpin

func (s *Service) GenerateIpin(c *gin.Context)

GenerateIpin generates a new ipin for card holder

func (*Service) GeneratePaymentToken

func (s *Service) GeneratePaymentToken(c *gin.Context)

GeneratePaymentToken generates a token BUG(adonese) we have to make it mandatory for biller id as well BUG(adonese) still not fixed -- but we really should fix it TODO(adonese) #94 API key should be mandatory

func (*Service) GenerateVoucher

func (s *Service) GenerateVoucher(c *gin.Context)

QRPayment performs QR payment transaction

func (*Service) GetCards

func (s *Service) GetCards(c *gin.Context)

GetCards Get all cards for the currently authorized user

func (*Service) GetMSISDNFromCard

func (s *Service) GetMSISDNFromCard(c *gin.Context)

GetMSISDNFromCard for ussd to get pan info from sim card

func (*Service) GetMobile

func (s *Service) GetMobile(c *gin.Context)

GetMobile gets list of mobile numbers to this user

func (*Service) GetPaymentToken

func (s *Service) GetPaymentToken(c *gin.Context)

GetPaymentToken retrieves a generated payment token by ID (UUID)

func (*Service) IPinChange

func (s *Service) IPinChange(c *gin.Context)

IPinChange changes the ipin for the card holder provided card

func (*Service) IsAlive

func (s *Service) IsAlive(c *gin.Context)

IsAlive performs isAlive request to inquire for ebs server availability

func (*Service) NecToName

func (s *Service) NecToName(c *gin.Context)

NecToName gets an nec number from the context and maps it to its meter number

func (*Service) NewBiller

func (s *Service) NewBiller(c *gin.Context)

NewBiller creates a new biller for system

func (*Service) Purchase

func (s *Service) Purchase(c *gin.Context)

Purchase performs special payment api from ebs consumer services It requires: card info (src), amount fields, specialPaymentId (destination) in order to complete the transaction

func (*Service) QRGeneration

func (s *Service) QRGeneration(c *gin.Context)

QRGeneration generates a qr token for the registered merchant

func (*Service) QRPayment

func (s *Service) QRPayment(c *gin.Context)

QRPayment performs QR payment transaction

func (*Service) QRRefund

func (s *Service) QRRefund(c *gin.Context)

QRRefund performs qr refund transaction

func (*Service) RegisterCard

func (s *Service) RegisterCard(c *gin.Context)

QRPayment performs QR payment transaction

func (*Service) RegisterCashout

func (s *Service) RegisterCashout(c *gin.Context)

RegisterCashout to register a new cashout biller in noebs

func (*Service) RemoveCard

func (s *Service) RemoveCard(c *gin.Context)

RemoveCard allow authorized users to remove their card when the send the card id (from its list in app view)

func (*Service) ResetPassword

func (s *Service) ResetPassword(c *gin.Context)

ResetPassword reset user password after passing some check

func (*Service) SpecialPayment

func (s *Service) SpecialPayment(c *gin.Context)

SpecialPayment is a new api to allow for site users to securely request payment it is really just a payment request with: - tran amount - payee id later we can add more features such as expiration for the token and more.

func (*Service) Status

func (s *Service) Status(c *gin.Context)

Status get transactions status from ebs

func (*Service) Transactions

func (s *Service) Transactions(c *gin.Context)

Transactions get transactions stored in our redis data store

func (*Service) UpdateCashout

func (s *Service) UpdateCashout(c *gin.Context)

UpdateCashout to register a new cashout biller in noebs

func (*Service) WorkingKey

func (s *Service) WorkingKey(c *gin.Context)

WorkingKey get ebs working key for encrypting ipin for consumer transactions

type State

type State struct {
	Db        *gorm.DB
	Redis     *redis.Client
	Auth      Auther
	UserModel gateway.UserModel
	UserLogin gateway.UserLogin
}

func (*State) APIAuth

func (s *State) APIAuth() gin.HandlerFunc

APIAuth API-Key middleware. Currently is used by consumer services FIXME issue #61

func (*State) ApiKeyMiddleware

func (s *State) ApiKeyMiddleware(c *gin.Context)

ApiKeyMiddleware used to authenticate clients using X-Email and X-API-Key headers FIXME issue #58 #61

func (*State) CreateUser

func (s *State) CreateUser(c *gin.Context)

FIXME issue #61

func (*State) GenerateAPIKey

func (s *State) GenerateAPIKey(c *gin.Context)

GenerateAPIKey An Admin-only endpoint that is used to generate api key for our clients the user must submit their email to generate a unique token per email. FIXME #59 #58 #61 api generation should be decoupled from apigateway package

func (*State) IpFilterMiddleware

func (s *State) IpFilterMiddleware(c *gin.Context)

FIXME issue #58 #61

func (*State) LogOut

func (s *State) LogOut(c *gin.Context)

FIXME issue #61

func (*State) LoginHandler

func (s *State) LoginHandler(c *gin.Context)

FIXME #60 make LoginHandler in consumer apis #61

func (*State) RefreshHandler

func (s *State) RefreshHandler(c *gin.Context)

FIXME #61 refactor some of these apis for consumer services only

Notes

Bugs

  • we have to make it mandatory for biller id as well

  • still not fixed -- but we really should fix it

  • safe but unclean; should be fixed. As reliable as the holding handler is

  • find a way to get hooks and to from here.

Jump to

Keyboard shortcuts

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