Documentation
¶
Index ¶
- type Actions
- type CheckoutInvoice
- type CheckoutInvoiceRequest
- type CheckoutInvoiceResponse
- type CheckoutInvoiceStatus
- type DirectMobile
- type DirectMobileRequest
- type DirectMobileResponse
- type DirectMobileStatusResponse
- type DirectPay
- type DirectPayRequest
- type DirectPayResponse
- type Invoice
- func (i *Invoice) AddItem(name string, quantity int, unitPrice float32, totalPrice float32, desc string) error
- func (i *Invoice) AddTax(name string, amount float32) error
- func (i *Invoice) Clear()
- func (i *Invoice) ClearAllItems()
- func (i *Invoice) ClearAllTaxes()
- func (i *Invoice) PrepareForRequest()
- func (i *Invoice) RemoveItem(name string)
- func (i *Invoice) RemoveTax(name string)
- func (i *Invoice) SetCustomData(key string, val interface{})
- func (i *Invoice) SetDescription(desc string)
- func (i *Invoice) SetTotalAmount(amt float32)
- func (i *Invoice) SetURLS(cancelURL, returnURL string)
- type MPower
- type OnsiteInvoice
- type OnsiteInvoiceRequest
- type OnsiteInvoiceResponse
- type OnsitePaymentRequestCharge
- type OnsitePaymentRequestChargeResponse
- type OnsitePaymentRequestData
- type Response
- type Setup
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actions ¶
type Actions struct {
CancelURL string `json:"cancel_url,omitempty"`
ReturnURL string `json:"return_url,omitempty"`
}
Actions represent the action urls of the invoice
type CheckoutInvoice ¶
type CheckoutInvoice struct {
Invoice
// contains filtered or unexported fields
}
CheckoutInvoice holds all the data related to checkout invoice Invoice is an embedded struct, so all methods of Invoice can be called on it
func NewCheckoutInvoice ¶
func NewCheckoutInvoice(mp *MPower) *CheckoutInvoice
NewCheckoutInvoice - create a new checkout instance
Example.
checkout := mpower.NewCheckoutInvoice(mpower)
func (*CheckoutInvoice) Confirm ¶
func (c *CheckoutInvoice) Confirm(token string) (*CheckoutInvoiceStatus, *napping.Response, error)
Confirm - This confirms the token status
func (*CheckoutInvoice) Create ¶
func (c *CheckoutInvoice) Create() (*CheckoutInvoiceResponse, *napping.Response, error)
Create - creates a new invoice on mpower
type CheckoutInvoiceRequest ¶
type CheckoutInvoiceRequest struct {
Invoice
}
type CheckoutInvoiceResponse ¶
CheckoutInvoiceResponse is the response data as specified by the mpower It retrieves the response json data and stores it on the checkout invoice object
type CheckoutInvoiceStatus ¶
CheckoutInvoiceStatus holds all the data related to status of an invoice created on mpower
type DirectMobile ¶
type DirectMobile struct {
// contains filtered or unexported fields
}
DirectMobile is used to handle api requests to mpower direct mobile payments
func NewDirectMobile ¶
func NewDirectMobile(mp *MPower) *DirectMobile
NewDirectMobile creates a new DirectMobile instance
func (*DirectMobile) Charge ¶
func (d *DirectMobile) Charge(name, email, phone, merchant, wallet, amount string) (*DirectMobileResponse, *napping.Response, error)
Charge charges customers' mobile money money wallets directly on your site or application
Example.
resp, err := directMobileInstance.Charge("Eugene", "ngene84@gmail.com", "0272271893", "Awesome Shopping", "MTN", "20")
func (*DirectMobile) Status ¶
func (d *DirectMobile) Status(token string) (*DirectMobileStatusResponse, *napping.Response, error)
Status checks the status of a direct mobile transaction
type DirectMobileRequest ¶
type DirectMobileRequest struct {
CustomerName string `json:"customer_name"`
CustomerEmail string `json:"customer_email"`
CustomerPhone string `json:"customer_phone"`
MerchantName string `json:"merchant_name"`
WalletProvider string `json:"wallet_provider"`
Amount string `json:"amount"`
}
DirectMobileRequest The request json to be sent over during a `charge` api request
type DirectMobileResponse ¶
type DirectMobileResponse struct {
Response
Token string `json:"token"`
TransactionID string `json:"transaction_id"`
MobileInvoiceNumber string `json:"mobile_invoice_no"`
}
DirectMobileResponse is the response from a direct mobile charge request
type DirectMobileStatusResponse ¶
type DirectMobileStatusResponse struct {
Response
TXStatus string `json:"tx_status"`
TransactionID string `json:"transaction_id"`
MobileInvoiceNumber string `json:"mobile_invoice_no"`
CancelReason string `json:"cancel_reason"`
}
DirectMobileStatusResponse is the status of a direct mobile transaction
type DirectPay ¶
type DirectPay struct {
// contains filtered or unexported fields
}
DirectPay - the direct pay object as defined by mpower
func NewDirectPay ¶
NewDirectPay - creates a DirectPay instance
func (*DirectPay) CreditAccount ¶
func (d *DirectPay) CreditAccount(account string, amount int) (*DirectPayResponse, *napping.Response, error)
CreditAccount - credits the account of an mpower customer
type DirectPayRequest ¶
type DirectPayRequest struct {
Alias string `json:"account_alias,omitempty"`
Amount int `json:"amount,omitempty"`
}
DirectPayRequest - `struct` to send the data as json to mpower
type DirectPayResponse ¶
DirectPayResponse - the response from mpower is serialiazed into this form
type Invoice ¶
type Invoice struct {
sync.RWMutex
Setup *Setup `json:"-"`
Store Store `json:"store"`
InvoiceData invoice `json:"invoice"`
CustomData map[string]interface{} `json:"custom_data,omitempty"`
Actions Actions `json:"actions,omitempty"`
}
Invoice definition It specifies the required field keys and values we will be sending over to mpower This is supposed to be an embedded struct in the Onsite Invoice and Checkout Invoice
func (*Invoice) AddItem ¶
func (i *Invoice) AddItem(name string, quantity int, unitPrice float32, totalPrice float32, desc string) error
AddItem add an `item - struct` to the items in the invoice
Example.
checkout := mpower.NewCheckoutInvoice(newSetup, newStore)
checkout.AddItem("Yam Phone", 1, 50.00, 50.00, "Hello World")
func (*Invoice) AddTax ¶
AddTax add an `tax - struct` to the taxes in the invoice
Example.
checkout := mpower.NewCheckoutInvoice(newSetup, newStore)
checkout.AddTax("VAT", 30.00)
func (*Invoice) Clear ¶
func (i *Invoice) Clear()
Clear clears all the items in the invoice
Example.
checkout.Clear()
func (*Invoice) ClearAllItems ¶
func (i *Invoice) ClearAllItems()
ClearAllItems clears all the items in the invoice
Example.
checkout.ClearAllItems()
func (*Invoice) ClearAllTaxes ¶
func (i *Invoice) ClearAllTaxes()
ClearAllTaxes clears all the taxes in the invoice
Example.
checkout.ClearAllTaxes()
func (*Invoice) PrepareForRequest ¶
func (i *Invoice) PrepareForRequest()
PrepareForRequest prepares the invoice for request This is called before the request to mpower invoice is made to set the items and taxes into a json format
func (*Invoice) RemoveItem ¶
RemoveItem removes the item with name of `name`
Example.
checkout.RemoveItem()
func (*Invoice) RemoveTax ¶
RemoveTax removes the tax with name of `name`
Example.
checkout.RemoveTax()
func (*Invoice) SetCustomData ¶
SetCustomData the total amount on the invoice
Example.
checkout := mpower.NewCheckoutInvoice(newSetup, newStore)
checkout.SetCustomData("bonus", yeah)
func (*Invoice) SetDescription ¶
SetDescription the description for the invoice
Example.
checkout := mpower.NewCheckoutInvoice(newSetup, newStore)
checkout.SetDescription("Hello World")
func (*Invoice) SetTotalAmount ¶
SetTotalAmount the total amount on the invoice
Example.
checkout := mpower.NewCheckoutInvoice(newSetup, newStore) checkout.SetTotalAmount(80.00)
type MPower ¶
MPower holds the setup and store data It includes all instances of the MPower API
type OnsiteInvoice ¶
type OnsiteInvoice struct {
Invoice
// contains filtered or unexported fields
}
OnsiteInvoice allows you to create an onsite invoice as per mpower docs
func NewOnsiteInvoice ¶
func NewOnsiteInvoice(mp *MPower) *OnsiteInvoice
NewOnsiteInvoice create a new onsite invoice object It require a setup and store object
Example.
onsite := mpower.NewOnsiteInvoice(newSetup, newStore)
func (*OnsiteInvoice) Charge ¶
func (on *OnsiteInvoice) Charge(onsitePaymentRequestToken, customerConfirmToken string) (*OnsitePaymentRequestChargeResponse, *napping.Response, error)
Charge - it charges the customer on mpower and returns a response json object which contains the receipt url with other information The `confirmToken` is from the customer
func (*OnsiteInvoice) Create ¶
func (on *OnsiteInvoice) Create(name string) (*OnsiteInvoiceResponse, *napping.Response, error)
Create - creates a new invoice on mpowers server
type OnsiteInvoiceRequest ¶
type OnsiteInvoiceRequest struct {
Invoice `json:"invoice_data"`
OPRData OnsitePaymentRequestData `json:"opr_data"`
}
OnsiteInvoiceRequest This struct holds all the data with respect to onsite request
type OnsiteInvoiceResponse ¶
type OnsiteInvoiceResponse struct {
Response
Token string `json:"token"`
InvoiceToken string `json:"invoice_token"`
}
OnsiteInvoiceResponse is the response you get back from creating an onsite invoice
type OnsitePaymentRequestCharge ¶
type OnsitePaymentRequestCharge struct {
Token string `json:"token"`
ConfirmToken string `json:"confirm_token"`
}
OnsitePaymentRequestCharge charges a customer
type OnsitePaymentRequestChargeResponse ¶
type OnsitePaymentRequestChargeResponse struct {
InvoiceData struct {
ReceiptURL string `json:"receipt_url"`
Status string `json:"status"`
Invoice struct {
TotalAmount float32 `json:"total_amount"`
Description string `json:"description"`
}
Customer struct {
Name string `json:"name"`
Phone string `json:"phone"`
Email string `json:"email"`
} `json:"customer"`
} `json:"invoice_data"`
}
OnsitePaymentRequestChargeResponse is the response from an onsite charge request
type OnsitePaymentRequestData ¶
type OnsitePaymentRequestData struct {
Alias string `json:"account_alias"`
}
type Response ¶
type Response struct {
ResponseText string `json:"response_text,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
Description string `json:"description,omitempty"`
}
Response - almost all mpower JSON responses contain all these fields This struct is embeded in other structs
type Setup ¶
type Setup struct {
MasterKey string
PrivateKey string
PublicKey string
Token string
Headers map[string]string
BaseURL string
}
Setup as defined by mpower docs with the exception of the BaseURL
func NewSetupFromEnv ¶
func NewSetupFromEnv() *Setup
NewSetupFromEnv creates a setup from your environment keys
type Store ¶
type Store struct {
Name string `json:"name,omitempty"`
Tagline string `json:"tagline,omitempty"`
PhoneNumber string `json:"phone,omitempty"`
PostalAddress string `json:"postal_address,omitempty"`
LogoURL string `json:"logo_url,omitempty"`
}
The Store holds the store information and ised to define the store data for mpower transaction
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Godeps
|
|
|
_workspace/src/github.com/jmcvetta/napping
Package napping is a client library for interacting with RESTful APIs.
|
Package napping is a client library for interacting with RESTful APIs. |
|
_workspace/src/github.com/jmcvetta/napping/examples/github_auth_token
command
Example demonstrating use of package napping, with HTTP Basic authentictation over HTTPS, to retrieve a Github auth token.
|
Example demonstrating use of package napping, with HTTP Basic authentictation over HTTPS, to retrieve a Github auth token. |
|
_workspace/src/github.com/stretchr/testify/assert
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
|
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. |
|
_workspace/src/github.com/stretchr/testify/require
Alternative testing tools which stop test execution if test failed.
|
Alternative testing tools which stop test execution if test failed. |
|
_workspace/src/github.com/stretchr/testify/suite
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests.
|
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests. |
