Documentation
¶
Overview ¶
Package consumer contains all of apis regarding EBS Consumer Web services the package is structured in such a way that separetes between the payment apis and the [services] apis.
Payment APIs All of the payment apis are in [payment_apis.go] file, they include basically all of EBS Consumer web service docs [v3.0.0].
Helper APIs We also have help apis in [services.go]
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/adonese/noebs-wasm (GO) - https://github.com/adonese/cashq (Java)
Index ¶
- Constants
- Variables
- func GetRandomName(retry int) string
- type Auther
- type PushData
- type Service
- func (s *Service) APIAuth() gin.HandlerFunc
- func (s *Service) AccountTransfer(c *gin.Context)
- func (s *Service) AddCards(c *gin.Context)
- func (s *Service) AddFirebaseID(c *gin.Context)
- func (s *Service) ApiKeyMiddleware(c *gin.Context)
- func (s *Service) Balance(c *gin.Context)
- func (s *Service) BalanceStep(c *gin.Context)
- func (s *Service) Beneficiaries(c *gin.Context)
- func (s *Service) BillInquiry(c *gin.Context)
- func (s *Service) BillPayment(c *gin.Context)
- func (s Service) BillerHooks()
- func (s *Service) CardFromNumber(c *gin.Context)
- func (s *Service) CardTransfer(c *gin.Context)
- func (s *Service) CashIn(c *gin.Context)
- func (s *Service) CashOut(c *gin.Context)
- func (s *Service) CashoutPub()
- func (s *Service) ChangePassword(c *gin.Context)
- func (s *Service) CheckUser(c *gin.Context)
- func (s *Service) CompleteIpin(c *gin.Context)
- func (s *Service) CompleteRegistration(c *gin.Context)
- func (s *Service) CreateUser(c *gin.Context)
- func (s *Service) EbsGetCardInfo(c *gin.Context)
- func (s *Service) EditCard(c *gin.Context)
- func (s *Service) GenerateAPIKey(c *gin.Context)
- func (s *Service) GenerateIpin(c *gin.Context)
- func (s *Service) GeneratePaymentToken(c *gin.Context)
- func (s *Service) GenerateSignInCode(c *gin.Context, allowInsecure bool)
- func (s *Service) GenerateVoucher(c *gin.Context)
- func (s *Service) GetBiller(c *gin.Context)
- func (s *Service) GetBills(c *gin.Context)
- func (s *Service) GetCards(c *gin.Context)
- func (s *Service) GetIpinPubKey() error
- func (s *Service) GetMSISDNFromCard(c *gin.Context)
- func (s *Service) GetPaymentToken(c *gin.Context)
- func (s *Service) GetTransactions(c *gin.Context)
- func (s *Service) GetUser(c *gin.Context)
- func (s *Service) GetUserLanguage(c *gin.Context)
- func (s *Service) IPINKey(c *gin.Context)
- func (s *Service) IPinChange(c *gin.Context)
- func (s *Service) IpFilterMiddleware(c *gin.Context)
- func (s *Service) IsAlive(c *gin.Context)
- func (s *Service) KYC(ctx *gin.Context)
- func (s *Service) LoginHandler(c *gin.Context)
- func (s *Service) MobileTransfer(c *gin.Context)
- func (s *Service) NecToName(c *gin.Context)
- func (s *Service) NoebsQuickPayment(c *gin.Context)
- func (s *Service) Notifications(c *gin.Context)
- func (s *Service) PaymentOrder() gin.HandlerFunc
- func (s *Service) PaymentRequest(c *gin.Context)
- func (s *Service) Purchase(c *gin.Context)
- func (s *Service) Pusher()
- func (s *Service) QRComplete(c *gin.Context)
- func (s *Service) QRGeneration(c *gin.Context)
- func (s *Service) QRMerchantRegistration(c *gin.Context)
- func (s *Service) QRPayment(c *gin.Context)
- func (s *Service) QRRefund(c *gin.Context)
- func (s *Service) QRTransactions(c *gin.Context)
- func (s *Service) RefreshHandler(c *gin.Context)
- func (s *Service) RegisterCard(c *gin.Context)
- func (s *Service) RegisterWithCard(c *gin.Context)
- func (s *Service) RemoveCard(c *gin.Context)
- func (s *Service) SendPush(data PushData) error
- func (s *Service) SetMainCard(c *gin.Context)
- func (s *Service) SetUserLanguage(c *gin.Context)
- func (s *Service) SingleLoginHandler(c *gin.Context)
- func (s *Service) Status(c *gin.Context)
- func (s *Service) ToDatabasename(url string) string
- func (s *Service) TransactionStatus(c *gin.Context)
- func (s *Service) UpdateUser(c *gin.Context)
- func (s *Service) VerifyFirebase(c *gin.Context)
- func (s *Service) VerifyOTP(c *gin.Context)
- func (s *Service) WorkingKey(c *gin.Context)
Constants ¶
const ( SPECIAL_BILLERS = "noebs:billers" KEY = "publickey_" )
const ( EBS_NOTIFICATION = "ebs" NOEBS_NOTIFICATION = "noebs" MARKETING_NOTIFICATION = "marketing" OTHERS_NOTIFICATIONS = "others" CTA_CARD_TRANSFER = "card_transfer" CTA_BALANCE = "balance" CTA_BILL_PAYMENT = "bill_payment" CTA_VOUCHER = "voucher" CTA_REQUEST_FUNDS = "request_funds" CTA_OTHERS = "others" )
various consts we are using for push data and notifications
const (
SMS_GATEWAY = "https://mazinhost.com/smsv1/sms/api?action=send-sms"
)
Variables ¶
var (
ErrCreateDbRow = errors.New("unable to create a new db row/column")
)
Functions ¶
func GetRandomName ¶
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`
Types ¶
type PushData ¶ added in v0.3.0
type PushData struct { UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` Type string `json:"type"` Date int64 `json:"date" gorm:"autoCreateTime"` UUID string `gorm:"primaryKey"` // To could be a phone number a bill id a card number, you name it To string `json:"to"` Title string `json:"title"` Body string `json:"body"` EBSData ebs_fields.EBSResponse `json:"data" gorm:"foreignKey:UUID;references:UUID"` // EBS parser fields holds many unnecssary info PaymentRequest ebs_fields.QrData `json:"payment_request" gorm:"foreignKey:UUID"` CallToAction string `json:"call_to_action"` // We use phone field to store a reference to the mobile number for both the sender and the receiver // for future reference to be queried. Phone string `json:"phone"` IsRead bool `json:"is_read"` DeviceID string `json:"device_id"` // UserMobile identifies which user the notification belogs to UserMobile string `json:"user_mobile"` }
PushData is a database table we use to push notifications to their users. It has a one-to-one reference to transactions Table and a noebs Token (if needed)
type Service ¶
type Service struct { Redis *redis.Client Db *gorm.DB NoebsConfig ebs_fields.NoebsConfig Logger *logrus.Logger FirebaseApp *firebase.App Auth Auther }
Service consumer for utils.Service struct
func (*Service) APIAuth ¶
func (s *Service) APIAuth() gin.HandlerFunc
APIAuth API-Key middleware. Currently is used by consumer services
func (*Service) AccountTransfer ¶
AccountTransfer performs p2p transactions
func (*Service) AddCards ¶
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) AddFirebaseID ¶ added in v0.3.0
func (*Service) ApiKeyMiddleware ¶
ApiKeyMiddleware used to authenticate clients using X-Email and X-API-Key headers FIXME issue #58 #61
func (*Service) BalanceStep ¶ added in v0.3.0
BalanceStep part of our 2fa steps for account recovery
func (*Service) Beneficiaries ¶ added in v0.3.0
Beneficiaries manage all of beneficiaries data
func (*Service) BillInquiry ¶
BillInquiry for telecos, utility and government (billers inquiries)
func (*Service) BillPayment ¶
BillPayment is responsible for utility, telecos, e-government and other payment services
func (Service) BillerHooks ¶ added in v0.3.0
func (s Service) BillerHooks()
BillerHooks submits results to external endpoint
func (*Service) CardFromNumber ¶
CardFromNumber gets the gussesed associated mobile number to this pan
func (*Service) CardTransfer ¶
CardTransfer performs p2p transactions
func (*Service) CashoutPub ¶
func (s *Service) CashoutPub()
CashoutPub experimental support to add pubsub support we need to make this api public
func (*Service) ChangePassword ¶
ChangePassword used to change a user's password using their old one
func (*Service) CompleteIpin ¶
CompleteIpin performs an otp check from ebs to complete ipin change transaction
func (*Service) CompleteRegistration ¶
CompleteRegistration step 2 in card issuance process
func (*Service) CreateUser ¶
CreateUser to register a new user to noebs
func (*Service) EbsGetCardInfo ¶
EbsGetCardInfo get card holder name from pan. Currently is limited to telecos only
func (*Service) EditCard ¶
EditCard allow authorized users to edit their cards (e.g., edit pan / expdate) this updates any card via
func (*Service) GenerateAPIKey ¶
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 (*Service) GenerateIpin ¶
GenerateIpin generates a new ipin for card holder
func (*Service) GeneratePaymentToken ¶
GeneratePaymentToken is used by noebs user to charge their customers. the toCard field in `Token` uses a masked PAN (first 6 digits and last 4 digits and any number of * in between)
func (*Service) GenerateSignInCode ¶
GenerateSignInCode allows noebs users to access their accounts in case they forgotten their passwords
func (*Service) GenerateVoucher ¶
QRPayment performs QR payment transaction
func (*Service) GetBiller ¶ added in v0.3.0
BillerID retrieves a billerID from noebs and performs an ebs request if a phone number doesn't exist in our system
func (*Service) GetBills ¶
GetBills for any EBS supported bill just by the entityID (phone number or the invoice ID). A good abstraction over EBS services. The function also updates a local database for each result for subsequent queries.
func (*Service) GetIpinPubKey ¶ added in v0.3.0
func (*Service) GetMSISDNFromCard ¶
GetMSISDNFromCard for ussd to get pan info from sim card
func (*Service) GetPaymentToken ¶
GetPaymentToken retrieves a generated payment token by UUID This service should be accessed via an authorization header
func (*Service) GetTransactions ¶ added in v1.1.2
func (*Service) GetUser ¶ added in v1.1.2
GetUser returns the user profile object for the currently logged in user
func (*Service) GetUserLanguage ¶ added in v1.1.2
func (*Service) IPINKey ¶
CompleteIpin performs an otp check from ebs to complete ipin change transaction
func (*Service) IPinChange ¶
IPinChange changes the ipin for the card holder provided card
func (*Service) IpFilterMiddleware ¶
FIXME issue #58 #61
func (*Service) LoginHandler ¶
LoginHandler noebs signin page
func (*Service) MobileTransfer ¶ added in v1.1.2
func (*Service) NecToName ¶
NecToName gets an nec number from the context and maps it to its meter number
func (*Service) NoebsQuickPayment ¶
NoebsQuickPayment performs a QR or payment via url transaction The api should be like this, and it should work for both the mobile and the web clients The very unique thing about the full payment token is that it is self-containted, the implmenter doesn't have to do an http call to inquire about its fields but, let's walkthrough the process, should we used a uuid of the payment token instead. - a user will click on an item - the app or web will make a call to generate a payment token - and it will return a link and a payment token. the link, or noebs link is only valid in the case of noebs' vendors payments (e.g., Solus or tuti): in that, it cannot work for the case of ecommerce - there are two cases for using the endpoint: - using the full-token should render the forms to show the details of the token (toCard, amount, and any comments) - using the uuid only, should be followed by the client performing a request to get the token info request body fields should always take precendents over query params
func (*Service) Notifications ¶ added in v0.3.0
Notifications handles various crud operations (json)
func (*Service) PaymentOrder ¶
func (s *Service) PaymentOrder() gin.HandlerFunc
PaymentOrder used to perform a transaction on behalf of a noebs user. This api should be used behind an authorization middleware The goal of this api is to allow our customers to perform certain types of transactions (recurred ones) without having to worry about it. For example, if a user wants to make saving, or in case they want to they want to pay for their rent. Recurring payment scenarios are a lot. The current proposal is to use a _wallet_. Simply, a user will put a money into noebs bank account. Whenever a user want to perform a recurred payment, noebs can then use their wallet to perform the transaction.
## Problems we have so far - We are not allowed to store value, we cannot save users money in our account - We cannot store user's payment information (pan, ipin, exp date) in our system - And we don't want the user to everytime login into the app and key in their payment information
func (*Service) PaymentRequest ¶ added in v1.1.2
func (*Service) Purchase ¶
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) QRComplete ¶
QRRefund performs qr refund transaction
func (*Service) QRGeneration ¶
QRGeneration generates a qr token for the registered merchant
func (*Service) QRMerchantRegistration ¶
CashIn performs cash in transactions
func (*Service) QRPayment ¶
QRPayment performs QR payment transaction. This is EBS-based QR transaction, and to be confused with noebs one
func (*Service) QRTransactions ¶
QRRefund performs qr refund transaction
func (*Service) RefreshHandler ¶
RefreshHandler generates a new access token to the user using their signed public key. the user will sign their username with their private key, and noebs will verify the signature using the stored public key for the user
func (*Service) RegisterCard ¶
QRPayment performs QR payment transaction
func (*Service) RegisterWithCard ¶ added in v0.3.0
Register with card allow a user to register through noebs and assigning a card to them
func (*Service) RemoveCard ¶
RemoveCard allow authorized users to remove their card when the send the card id (from its list in app view)
func (*Service) SetMainCard ¶ added in v1.1.2
func (*Service) SetUserLanguage ¶ added in v1.1.2
func (*Service) SingleLoginHandler ¶
SingleLoginHandler is used for one-time authentications. It checks a signed entered otp keys against the user's credentials (user's stored public key)
NOTES This function only allows one-time authentication VIA the same device that the user originally has signed up with.
func (*Service) ToDatabasename ¶
func (*Service) TransactionStatus ¶
TransactionStatus queries EBS to get the status of the transaction
func (*Service) UpdateUser ¶ added in v1.1.2
UpdateUser allows the currently logged in user to update their profile info
func (*Service) VerifyFirebase ¶
VerifyFirebase used to confirm that the user's token is valid
func (*Service) WorkingKey ¶
WorkingKey get ebs working key for encrypting ipin for consumer transactions