Documentation
¶
Index ¶
- Constants
- func IsStringEmpty(s string) bool
- type Authorization
- type BVN
- type BVNMatchOptions
- type BVNMatchResponse
- type BVNResponse
- type Bank
- type BankListOptions
- type BankService
- type Client
- func (c *Client) Bank() *BankService
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) NewRequest(method string, url string, v interface{}) (*http.Request, error)
- func (c *Client) Transaction() *TransactionService
- func (c *Client) Transfer() *TransactionService
- func (c *Client) Verification() *VerificationService
- type CreateTransferRecipientOptions
- type CreateTransferRecipientResponse
- type InitializeTransactionRequest
- type InitializeTransactionResponse
- type MetaData
- type Nuban
- type NubanOptions
- type NubanResponse
- type Option
- type Transaction
- type TransactionService
- func (t TransactionService) CreateRecipient(ctx context.Context, opts *CreateTransferRecipientOptions) (CreateTransferRecipientResponse, error)
- func (t *TransactionService) Initialize(ctx context.Context, opts *InitializeTransactionRequest) (InitializeTransactionResponse, error)
- func (t *TransactionService) Verify(ctx context.Context, reference string) (Transaction, error)
- type TransferService
- type VerificationService
- func (v *VerificationService) MatchBVN(ctx context.Context, b *BVNMatchOptions) (BVNMatchResponse, error)
- func (v *VerificationService) ResolveBVN(ctx context.Context, b string) (BVNResponse, error)
- func (v *VerificationService) ResolveNuban(ctx context.Context, opts *NubanOptions) (NubanResponse, error)
Constants ¶
const (
BVNLen = 11
)
Variables ¶
This section is empty.
Functions ¶
func IsStringEmpty ¶
IsStringEmpty checks if the given string (s) is empty or not. It strips out spaces while performing the check
Types ¶
type Authorization ¶
type Authorization struct {
AuthorizationCode string `json:"authorization_code"`
Bin string `json:"bin"`
Last4 string `json:"last4"`
ExpMonth string `json:"exp_month"`
ExpYear string `json:"exp_year"`
Channel string `json:"channel"`
CardType string `json:"card_type"`
Bank string `json:"bank"`
CountryCode string `json:"country_code"`
Brand string `json:"brand"`
Reusable bool `json:"reusable"`
Signature string `json:"signature"`
AccountName string `json:"account_name"`
}
Authorization represents a payment method The Reusable field should be taken note of as it determines if this authorization code can be used again
type BVN ¶
type BVN struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
DOB string `json:"dob"`
FormattedDOB string `json:"formatted_dob"`
Mobile string `json:"mobile"`
Value string `json:"bvn"`
}
BVN represents a user's BVN
type BVNMatchOptions ¶
type BVNMatchOptions struct {
AccountNumber string `json:"account_number"`
BankCode string `json:"bank_code"`
BVN string `json:"bvn"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
MiddleName string `json:"middle_name"`
}
BVNMatchOptions defines the data for matching a BVN
func (*BVNMatchOptions) Validate ¶
func (b *BVNMatchOptions) Validate() error
Validate makes sure to check for the request is properly formatted. Makes sure the required fields are present
type BVNMatchResponse ¶
type BVNMatchResponse struct {
Meta struct {
CallsThisMonth int `json:"calls_this_month,omitempty"`
FreeCallsLeft int `json:"free_calls_left,omitempty"`
} `json:"meta,omitempty"`
Data struct {
AccountNumber bool `json:"account_number"`
FirstName bool `json:"first_name"`
LastName bool `json:"last_name"`
IsBlacklisted bool `json:"is_blacklisted"`
BVN string `json:"bvn"`
} `json:"data"`
}
BVNMatchResponse is a response type that gives an actual representation of the provided data by the user.
type BVNResponse ¶
type BVNResponse struct {
Meta struct {
CallsThisMonth int `json:"calls_this_month,omitempty"`
FreeCallsLeft int `json:"free_calls_left,omitempty"`
} `json:"meta,omitempty"`
Data struct {
BVN
} `json:"data,omitempty"`
}
func (BVNResponse) IsZero ¶
func (b BVNResponse) IsZero() bool
IsZero checks if the BVN in the response is empty or an unusable state
type Bank ¶
type Bank struct {
Name string `json:"name"`
Slug string `json:"slug"`
Code string `json:"code"`
LangCode string `json:"lang_code"`
Gateway string `json:"gateway"`
Active bool `json:"active"`
ID int64 `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Bank represents a known bank
type BankListOptions ¶
type BankListOptions struct {
PerPage int `url:"perPage"`
Page int `url:"page"`
Type string `url:"type"`
Currency string `url:"currency"`
Country string `url:"country"`
}
BankListOptions is used to filter results of the banks api
type BankService ¶
type BankService service
BankService is a service for communicating with the bank related API of Paystack's API
func (BankService) ListBanks ¶
func (b BankService) ListBanks(ctx context.Context, params *BankListOptions) ([]Bank, error)
ListBanks returns a list of known banks Docs: https://developers.paystack.co/reference#list-banks
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the root object of cerberus. Used to interact with Paystack's API
func (*Client) Bank ¶
func (c *Client) Bank() *BankService
func (*Client) NewRequest ¶
NewRequest creates a new http.Request for the current operation
func (*Client) Transaction ¶
func (c *Client) Transaction() *TransactionService
func (*Client) Transfer ¶
func (c *Client) Transfer() *TransactionService
func (*Client) Verification ¶
func (c *Client) Verification() *VerificationService
type CreateTransferRecipientOptions ¶
type CreateTransferRecipientOptions struct {
Type string `json:"type"`
Name string `json:"name"`
MetaData MetaData `json:"meta_data"`
AccountNumber Nuban `json:"account_number"`
BankCode string `json:"bank_code"`
Currency string `json:"currency"`
Description string `json:"description"`
AuthorizationCode string `json:"authorization_code"`
}
CreateTransferRecipientOptions is the request body for creating a transfer recipient
func (*CreateTransferRecipientOptions) Validate ¶
func (c *CreateTransferRecipientOptions) Validate() error
Validate makes sure required value are provided
type CreateTransferRecipientResponse ¶
type CreateTransferRecipientResponse struct {
Type string `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Metadata struct {
Job string `json:"job"`
} `json:"metadata"`
Domain string `json:"domain"`
Details struct {
AccountNumber Nuban `json:"account_number"`
AccountName string `json:"account_name"`
BankCode string `json:"bank_code"`
BankName string `json:"bank_name"`
} `json:"details"`
Currency string `json:"currency"`
RecipientCode string `json:"recipient_code"`
Active bool `json:"active"`
ID int `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
CreateTransferRecipientResponse is a model that represents a successful recipient creation
type InitializeTransactionRequest ¶
type InitializeTransactionRequest struct {
CallbackURL string `json:"callback_url"`
Reference string `json:"reference"`
Amount string `json:"amount"`
Email string `json:"email"`
Plan string `json:"plan"`
InvoiceLimit int `json:"invoice_limit"`
MetaData MetaData `json:"meta_data"`
SubAccount string `json:"sub_account"`
TransactionCharge int `json:"transaction_charge"`
Bearer string `json:"bearer"`
Channels []string `json:"channels"`
}
InitializeTransactionRequest represents a model for creating/initializing a Paystack payment
func (*InitializeTransactionRequest) Validate ¶
func (i *InitializeTransactionRequest) Validate() error
Validate makes sure required data is provided for initializing the transaction
type InitializeTransactionResponse ¶
type InitializeTransactionResponse struct {
AccessCode string `json:"access_code"`
Reference string `json:"reference"`
AuthorizationURL string `json:"authorization_url"`
}
InitializeTransactionResponse is
type Nuban ¶
type Nuban string
Nuban is a custom type that represents a Nigerian account number
type NubanOptions ¶
type NubanOptions struct {
AccountNumber Nuban `json:"account_number" url:"account_number"`
BankCode string `json:"bank_code" url:"bank_code"`
}
NubanOptions represents query parameters for fetching data of a Nuban
func (*NubanOptions) Validate ¶
func (n *NubanOptions) Validate() error
Validate checks that required data is provided
type NubanResponse ¶
type NubanResponse struct {
AccountName string `json:"account_name"`
AccountNumber string `json:"account_number"`
}
NubanResponse represents an account number an it's corresponding name
type Option ¶
type Option func(*Client)
Option is a configuration type
func HTTPClient ¶
HTTPClient is an Option type that allows you provide your own HTTP client
type Transaction ¶
type Transaction struct {
ID int `json:"id"`
Domain string `json:"domain"`
Status string `json:"status"`
Reference string `json:"reference"`
Amount int `json:"amount"`
Message string `json:"message"`
GatewayResponse string `json:"gateway_response"`
PaidAt time.Time `json:"paid_at"`
CreatedAt time.Time `json:"created_at"`
Channel string `json:"channel"`
Currency string `json:"currency"`
IPAddress string `json:"ip_address"`
// Metadata is actually a string :)
Metadata string `json:"metadata"`
Log struct {
StartTime int `json:"start_time"`
TimeSpent int `json:"time_spent"`
Attempts int `json:"attempts"`
Errors int `json:"errors"`
Success bool `json:"success"`
Mobile bool `json:"mobile"`
Input []interface{} `json:"input"`
History []struct {
Type string `json:"type"`
Message string `json:"message"`
Time int `json:"time"`
} `json:"history"`
} `json:"log"`
Fees int `json:"fees"`
FeesSplit string `json:"fees_split"`
Authorization Authorization `json:"authorization"`
Customer struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
CustomerCode string `json:"customer_code"`
Phone string `json:"phone"`
Metadata MetaData `json:"metadata"`
RiskAction string `json:"risk_action"`
} `json:"customer"`
Plan interface{} `json:"plan"`
Split struct {
} `json:"split"`
OrderID interface{} `json:"order_id"`
RequestedAmount int `json:"requested_amount"`
TransactionDate time.Time `json:"transaction_date"`
}
Transaction represents the response from Paystack's API
type TransactionService ¶
type TransactionService service
TransactionService interacts with the transaction section of Paystack's API
func (TransactionService) CreateRecipient ¶
func (t TransactionService) CreateRecipient(ctx context.Context, opts *CreateTransferRecipientOptions) (CreateTransferRecipientResponse, error)
CreateRecipient creates a transfer recipient https://developers.paystack.co/reference#create-transfer-recipient
func (*TransactionService) Initialize ¶
func (t *TransactionService) Initialize(ctx context.Context, opts *InitializeTransactionRequest) (InitializeTransactionResponse, error)
Initialize initializes a Paystack transaction. https://developers.paystack.co/reference#initialize-a-transaction
func (*TransactionService) Verify ¶
func (t *TransactionService) Verify(ctx context.Context, reference string) (Transaction, error)
Verify fetches the status of a transaction by it's reference https://developers.paystack.co/reference#verify-transaction
type TransferService ¶
type TransferService service
type VerificationService ¶
type VerificationService service
VerificationService is used to communicate with the verification section of Paystack's API
func (*VerificationService) MatchBVN ¶
func (v *VerificationService) MatchBVN(ctx context.Context, b *BVNMatchOptions) (BVNMatchResponse, error)
MatchBVN compares the provided data to what is available in the BVN database Docs: https://developers.paystack.co/reference#match-bvn
func (*VerificationService) ResolveBVN ¶
func (v *VerificationService) ResolveBVN(ctx context.Context, b string) (BVNResponse, error)
ResolveBVN fetches the data of the provided bvn Docs: https://developers.paystack.co/reference#resolve-bvn
func (*VerificationService) ResolveNuban ¶
func (v *VerificationService) ResolveNuban(ctx context.Context, opts *NubanOptions) (NubanResponse, error)
ResolveNuban retrieves data of the provided Nuban Docs: https://developers.paystack.co/reference#resolve-account-number