Documentation ¶
Index ¶
- Variables
- type AirtimeTransferParams
- type AirtimeTransferResponse
- type CallbackRequest
- type Client
- func (client *Client) Collect(ctx context.Context, params *CollectParams) (*CollectResponse, *Response, error)
- func (client *Client) Token(ctx context.Context) (*Token, *Response, error)
- func (client *Client) ValidateCallback(signature string, webhookKey []byte) error
- func (client *Client) Withdraw(ctx context.Context, params *WithdrawParams) (*WithdrawResponse, *Response, error)
- func (client *Client) WithdrawSync(ctx context.Context, params *WithdrawParams) (*Transaction, *Response, error)
- type ClientOption
- type CollectParams
- type CollectResponse
- type Environment
- type Response
- type Token
- type Transaction
- type UtilitiesTransaction
- type WithdrawParams
- type WithdrawResponse
Constants ¶
This section is empty.
Variables ¶
var ( // DevEnvironment is the development Environment DevEnvironment = Environment("https://demo.campay.net") // ProdEnvironment is the production Environment ProdEnvironment = Environment("https://www.campay.net") )
Functions ¶
This section is empty.
Types ¶
type AirtimeTransferParams ¶ added in v0.0.6
type AirtimeTransferParams struct { Amount string `json:"amount"` To string `json:"to"` ExternalReference string `json:"external_reference"` }
AirtimeTransferParams are parameters for transferring airtime
type AirtimeTransferResponse ¶ added in v0.0.6
type AirtimeTransferResponse struct { Reference string `json:"reference"` Status string `json:"status"` }
AirtimeTransferResponse is gotten after transferring airtime
type CallbackRequest ¶
type CallbackRequest struct { Status string `json:"status" query:"status"` Reference string `json:"reference" query:"reference"` Amount string `json:"amount" query:"amount"` Currency string `json:"currency" query:"currency"` Operator string `json:"operator" query:"operator"` Code string `json:"code" query:"code"` OperatorReference string `json:"operator_reference" query:"operator_reference"` Signature string `json:"signature" query:"signature"` ExternalReference string `json:"external_reference" query:"external_reference"` }
CallbackRequest is the notification request that is sent when a payment is made
type Client ¶
type Client struct { Transaction *transactionService Utilities *utilitiesService // contains filtered or unexported fields }
Client is the campay API client. Do not instantiate this client with Client{}. Use the New method instead.
func New ¶
func New(options ...ClientOption) *Client
New creates and returns a new campay.Client from a slice of campay.ClientOption.
func (*Client) Collect ¶
func (client *Client) Collect(ctx context.Context, params *CollectParams) (*CollectResponse, *Response, error)
Collect Requests a Payment POST /collect/ API Doc: https://documenter.getpostman.com/view/2391374/T1LV8PVA#31757962-2e07-486b-a6f4-a7cc7a06d032
func (*Client) Token ¶
Token Gets the access token POST /token/ API Doc: https://documenter.getpostman.com/view/2391374/T1LV8PVA#8803168b-d451-4d65-b8cc-85e385bc3050
func (*Client) ValidateCallback ¶
ValidateCallback checks if the signature was encrypted with the webhook key
func (*Client) Withdraw ¶ added in v0.0.4
func (client *Client) Withdraw(ctx context.Context, params *WithdrawParams) (*WithdrawResponse, *Response, error)
Withdraw funds to a mobile money account POST /withdraw/ API Doc: https://documenter.getpostman.com/view/2391374/T1LV8PVA#885dbde0-b0dd-4514-a0f9-f84fc83df12d
func (*Client) WithdrawSync ¶ added in v0.0.7
func (client *Client) WithdrawSync(ctx context.Context, params *WithdrawParams) (*Transaction, *Response, error)
WithdrawSync transfers money to a mobile number and waits for the transaction to be completed. POST /withdraw/ API Doc: https://documenter.getpostman.com/view/2391374/T1LV8PVA#885dbde0-b0dd-4514-a0f9-f84fc83df12d
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption are options for constructing a client
func WithAPIPassword ¶
func WithAPIPassword(apiPassword string) ClientOption
WithAPIPassword sets the campay API password
func WithAPIUsername ¶
func WithAPIUsername(apiUsername string) ClientOption
WithAPIUsername sets the campay API username
func WithEnvironment ¶
func WithEnvironment(environment Environment) ClientOption
WithEnvironment sets the campay endpoint for API requests By default, ProdEnvironment is used.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets the underlying HTTP client used for requests. By default, http.DefaultClient is used.
type CollectParams ¶ added in v0.0.4
type CollectParams struct { Amount uint `json:"amount"` Currency string `json:"currency"` From string `json:"from"` Description string `json:"description"` ExternalReference string `json:"external_reference"` }
CollectParams is the details needed to initialize a payment
type CollectResponse ¶
type CollectResponse struct { Reference string `json:"reference"` UssdCode string `json:"ussd_code"` Operator string `json:"operator"` }
CollectResponse is the response after calling the collect endpoint
type Environment ¶
type Environment string
Environment is the URL of the campay environment
func (Environment) String ¶
func (e Environment) String() string
type Transaction ¶ added in v0.0.2
type Transaction struct { Reference string `json:"reference"` Status string `json:"status"` Amount float64 `json:"amount"` Currency string `json:"currency"` Operator string `json:"operator"` Code string `json:"code"` OperatorReference string `json:"operator_reference"` }
Transaction contains details of an initiated transaction
func (*Transaction) IsPending ¶ added in v0.0.7
func (transaction *Transaction) IsPending() bool
IsPending checks if a transaction is pending
func (*Transaction) IsSuccessfull ¶ added in v0.0.7
func (transaction *Transaction) IsSuccessfull() bool
IsSuccessfull checks if a transaction is successfull
type UtilitiesTransaction ¶ added in v0.0.6
type UtilitiesTransaction struct { Reference string `json:"reference"` ExternalReference string `json:"external_reference"` Status string `json:"status"` Amount float64 `json:"amount"` Currency string `json:"currency"` Operator string `json:"operator"` Code string `json:"code"` Type string `json:"type"` Reason string `json:"reason"` }
UtilitiesTransaction represent a utility transaction
func (*UtilitiesTransaction) IsPending ¶ added in v0.0.6
func (transaction *UtilitiesTransaction) IsPending() bool
IsPending checks if a transaction is pending
func (*UtilitiesTransaction) IsSuccessfull ¶ added in v0.0.6
func (transaction *UtilitiesTransaction) IsSuccessfull() bool
IsSuccessfull checks if a transaction is successfull
type WithdrawParams ¶ added in v0.0.4
type WithdrawParams struct { Amount uint `json:"amount"` To string `json:"to"` Description string `json:"description"` ExternalReference *string `json:"external_reference,omitempty"` }
WithdrawParams are the details needed to perform a withdrawal
type WithdrawResponse ¶ added in v0.0.4
WithdrawResponse is the response after doing a withdrawal request