providusbank

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

README

providusbank-api-client-go

Go Reference Go Report Card Maintainability Test Coverage

Providus Bank API Client for Go

Installation

go get github.com/brokeyourbike/providusbank-api-client-go

Usage

Account
accountClient := providusbank.NewAccountClient("providusbank.com", "client_id", "client_secret")
accountClient.CreateDynamicAccount(context.TODO(), "John Doe")
Transfer
transferClient := providusbank.NewTransferClient("providusbank.com", "username", "password")
transferClient.GetNIPBanks(context.TODO())

Authors

License

BSD-3-Clause License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccountClient

func NewAccountClient(baseURL, token, secret string, options ...ClientOption) *accountClient

func NewRequest

func NewRequest(r *http.Request) *request

func NewTransferClient

func NewTransferClient(baseURL, username, password string, options ...ClientOption) *transferClient

Types

type AccountClient

type AccountClient interface {
	CreateDynamicAccount(ctx context.Context, accountName string) (data CreateDynamicAccountResponse, err error)
	CreateReservedAccount(ctx context.Context, accountName, bvn string) (data CreateReservedAccountResponse, err error)
	UpdateAccountName(ctx context.Context, accountNumber, accountName string) (data AccountOperationResponse, err error)
	BlacklistAccount(ctx context.Context, accountNumber string) (data AccountOperationResponse, err error)
	VerifyTransaction(ctx context.Context, sessionID string) (data VerifyTransactionResponse, err error)
	VerifyTransactionWithSettlementID(ctx context.Context, settlementID string) (data VerifyTransactionResponse, err error)
	RepushTransaction(ctx context.Context, sessionID, settlementID string) (data RepushTransactionResponse, err error)
}

type AccountOperationResponse

type AccountOperationResponse struct {
	Success         bool   `json:"requestSuccessful"`
	ResponseCode    string `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
}

type AccountResponse

type AccountResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
}

type BVNDetailsResponse

type BVNDetailsResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	FirstName       string `json:"firstName"`
	MiddleName      string `json:"middleName"`
	LastName        string `json:"surname"`
	DOB             Time   `json:"dateOfBirth"`
}

type ClientOption

type ClientOption func(*client)

ClientOption is a function that configures a Client.

func WithHTTPClient

func WithHTTPClient(c HttpClient) ClientOption

WithHTTPClient sets the HTTP client for the paystack API client.

func WithLogger

func WithLogger(l *logrus.Logger) ClientOption

WithLogger sets the *logrus.Logger for the paystack API client.

type Code added in v0.2.0

type Code string
const (
	CodeCompleted                        Code = "00"
	CodeDormantAccount                   Code = "06"
	CodeTransactionNotExists             Code = "01"
	CodeInvalidSender                    Code = "03"
	CodeDoNotHonor                       Code = "05"
	CodeInvalidAccount                   Code = "07"
	CodeAccountNameMismatch              Code = "08"
	CodeInProgress                       Code = "09"
	CodeReversalNotSuccessful            Code = "11"
	CodeInvalidTransaction               Code = "12"
	CodeInvalidAmount                    Code = "13"
	CodeInvalidBatchNumber               Code = "14"
	CodeInvalidSession                   Code = "15"
	CodeUnknownBankCode                  Code = "16"
	CodeInvalidChannel                   Code = "17"
	CodeInvalidMethodCall                Code = "18"
	CodeNoActionTaken                    Code = "21"
	CodeUnableToLocateRecord             Code = "25"
	CodeReversalCompleted                Code = "25"
	CodeDuplicateRecord                  Code = "26"
	CodeFormatError                      Code = "30"
	CodeTransferNotSuccessful            Code = "32"
	CodeSuspectedFraud                   Code = "34"
	CodeContactSendingBank               Code = "35"
	CodeTransferCompleted                Code = "36"
	CodeInsufficientFunds                Code = "51"
	CodeTransactionNotPermittedToSender  Code = "57"
	CodeTransactionNotPermittedToChannel Code = "58"
	CodeServiceUnavailable               Code = "505"
	CodeTransferLimitExceeded            Code = "61"
	CodeSecurityViolation                Code = "63"
	CodeWithdrawalFrequencyExceeded      Code = "65"
	CodeResponseReceivedTooLate          Code = "68"
	CodeCustomerDetailsNotValidated      Code = "69"
	CodeNotificationNotReceived          Code = "70"
	CodeDebitAccountInvalid              Code = "7701"
	CodeCreditAccountInvalid             Code = "7702"
	CodeCreditAccountDormant             Code = "7703"
	CodeInsufficientBalance              Code = "7704"
	CodeInvalidAmount2                   Code = "7706"
	CodeCurrencyMismatch                 Code = "7708"
	CodeDuplicateReference               Code = "7709"
	CodeCustomerNotValidated             Code = "7710"
	CodeCustomerNotActive                Code = "7711"
	CodeCustomerAlreadyEnrolled          Code = "7712"
	CodeOtpFailInvalidAccountNumber      Code = "7713"
	CodeCustomerNotEnrolled              Code = "7714"
	CodeOtpMismatch                      Code = "7715"
	CodeCustomerAlreadyValidated         Code = "7716"
	CodeCbaSystemError                   Code = "7799"
	CodeAuthFailed                       Code = "8004"
	CodeMethodNotAllowed                 Code = "8005"
	CodeNoConenction                     Code = "8803"
	CodeCreditAccountNotPermitted        Code = "8888"
	CodeRecipientBankNotAvailable        Code = "91"
	CodeRoutingError                     Code = "92"
	CodeDuplicateTransaction             Code = "94"
	CodeSustemMalfunction                Code = "96"
	CodeDestinationResponseTimeout       Code = "97"
	CodeUnknownNfpResponse               Code = "909"
	CodeNullNfpResponse                  Code = "919"
	CodeLocalTimeout                     Code = "999"
	CodeAuthFailed2                      Code = "9999"
)

func (Code) IsFailed added in v0.4.0

func (c Code) IsFailed() bool

func (Code) IsSuccesful added in v0.4.0

func (c Code) IsSuccesful() bool

type CreateDynamicAccountResponse

type CreateDynamicAccountResponse struct {
	Success         bool   `json:"requestSuccessful"`
	ResponseCode    string `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	AccountName     string `json:"account_name"`
	AccountNumber   string `json:"account_number"`
	Reference       string `json:"initiationTranRef"`
}

type CreateReservedAccountResponse

type CreateReservedAccountResponse struct {
	Success         bool   `json:"requestSuccessful"`
	ResponseCode    string `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	AccountName     string `json:"account_name"`
	AccountNumber   string `json:"account_number"`
	BVN             string `json:"bvn"`
}

type ErrResponse

type ErrResponse struct {
	Status    int    `json:"status"`
	Err       string `json:"error"`
	Message   string `json:"message"`
	Path      string `json:"path"`
	Timestamp Time   `json:"timestamp"`
}

func (ErrResponse) Error

func (e ErrResponse) Error() string

type FundTransferPayload

type FundTransferPayload struct {
	CreditAccount string  `json:"creditAccount"`
	DebitAccount  string  `json:"debitAccount"`
	Currency      string  `json:"currencyCode"`
	Amount        float64 `json:"transactionAmount"`
	Reference     string  `json:"transactionReference"`
	Narration     string  `json:"narration"`
}

type FundTransferResponse

type FundTransferResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	Currency        string `json:"currency"`
	Amount          string `json:"amount"`
	Reference       string `json:"transactionReference"`
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type NIPAccountResponse

type NIPAccountResponse struct {
	ResponseCode         Code   `json:"responseCode"`
	ResponseMessage      string `json:"responseMessage"`
	AccountNumber        string `json:"accountNumber"`
	AccountName          string `json:"accountName"`
	BankCode             string `json:"bankCode"`
	BVN                  string `json:"bvn"`
	TransactionReference string `json:"transactionReference"`
}

type NIPBanksResponse

type NIPBanksResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	Banks           []struct {
		Code string `json:"bankCode"`
		Name string `json:"bankName"`
	} `json:"banks"`
}

type NIPFundTransferPayload

type NIPFundTransferPayload struct {
	SourceAccountName        string  `json:"sourceAccountName"`
	BeneficiaryAccountName   string  `json:"beneficiaryAccountName"`
	BeneficiaryAccountNumber string  `json:"beneficiaryAccountNumber"`
	BeneficiaryBank          string  `json:"beneficiaryBank"`
	Currency                 string  `json:"currencyCode"`
	Amount                   float64 `json:"transactionAmount"`
	Reference                string  `json:"transactionReference"`
	Narration                string  `json:"narration"`
}

type NIPFundTransferResponse

type NIPFundTransferResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	Reference       string `json:"transactionReference"`
	SessionID       string `json:"sessionId"`
}

type NIPTransactionStatusResponse

type NIPTransactionStatusResponse struct {
	ResponseCode           Code   `json:"responseCode"`
	ResponseMessage        string `json:"responseMessage"`
	Currency               string `json:"currency"`
	Amount                 string `json:"amount"`
	RecipientBankCode      string `json:"recipientBankCode"`
	RecipientAccountNumber string `json:"recipientAccountNumber"`
	Reference              string `json:"transactionReference"`
	Date                   Time   `json:"transactionDateTime"`
}

type RepushTransactionResponse

type RepushTransactionResponse struct {
	Success             bool   `json:"requestSuccessful"`
	ResponseCode        string `json:"responseCode"`
	ResponseMessage     string `json:"responseMessage"`
	AccountNumber       string `json:"account_number"`
	AccountName         string `json:"account_name"`
	InitiationReference string `json:"initiationTranRef"`
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TransactionStatusResponse

type TransactionStatusResponse struct {
	ResponseCode    Code   `json:"responseCode"`
	ResponseMessage string `json:"responseMessage"`
	Currency        string `json:"currency"`
	Amount          string `json:"amount"`
	CreditAccount   string `json:"creditAccount"`
	DebitAccount    string `json:"debitAccount"`
	Reference       string `json:"transactionReference"`
	Date            Time   `json:"transactionDateTime"`
}

type TransferClient

type TransferClient interface {
	GetNIPBanks(ctx context.Context) (data NIPBanksResponse, err error)
	GetBVNDetails(ctx context.Context, bvn string) (data BVNDetailsResponse, err error)
	GetTransactionStatus(ctx context.Context, reference string) (data TransactionStatusResponse, err error)
	GetNIPTransactionStatus(ctx context.Context, reference string) (data NIPTransactionStatusResponse, err error)
	GetAccount(ctx context.Context, accountNumber string) (data AccountResponse, err error)
	GetNIPAccount(ctx context.Context, bankCode, accountNumber string) (data NIPAccountResponse, err error)
	FundTransfer(ctx context.Context, payload FundTransferPayload) (data FundTransferResponse, err error)
	NIPFundTransfer(ctx context.Context, payload NIPFundTransferPayload) (data NIPFundTransferResponse, err error)
}

type VerifyTransactionResponse

type VerifyTransactionResponse struct {
	SessionID           string  `json:"sessionId"`
	SettlementID        string  `json:"settlementId"`
	ChannelID           string  `json:"channelId"`
	AccountNumber       string  `json:"accountNumber"`
	SourceAccountNumber string  `json:"sourceAccountNumber"`
	SourceAccountName   string  `json:"sourceAccountName"`
	SourceBankName      string  `json:"sourceBankName"`
	Currency            string  `json:"currency"`
	Amount              float64 `json:"transactionAmount"`
	SettledAmount       float64 `json:"settledAmount"`
	FeeAmount           float64 `json:"feeAmount"`
	VATAmount           float64 `json:"vatAmount"`
	InitiationReference string  `json:"initiationTranRef"`
	Remarks             string  `json:"tranRemarks"`
	Date                Time    `json:"tranDateTime"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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