Documentation
¶
Index ¶
- Constants
- Variables
- func InitConfig()
- func RandomString(length int) string
- type API
- type AppExamplePaymentService
- func (s *AppExamplePaymentService) Checkout(ctx context.Context, CustomerID int64, form CheckoutForm) (*Transaction, error)
- func (s *AppExamplePaymentService) CustomerByID(_ context.Context, CustomerID int64) (Customer, error)
- func (s *AppExamplePaymentService) ListTransactions(_ context.Context) (TransactionList, error)
- func (s *AppExamplePaymentService) SaveTransaction(_ context.Context, transaction Transaction) error
- type Bank
- type BankTransfer
- type BankTransferResponse
- type BanksResponse
- type BulkData
- type BulkTransferRequest
- type BulkTransferResponse
- type BulkTransferResponseData
- type CheckoutForm
- type Currency
- type Customer
- type ExamplePaymentService
- type Pagination
- type PaymentRequest
- type PaymentResponse
- type Transaction
- type TransactionList
- type TransactionStatus
- type TransactionsResponse
- type VerifyResponse
Constants ¶
View Source
const ( FailedTransactionStatus TransactionStatus = "failed" PendingTransactionStatus TransactionStatus = "pending" SuccessTransactionStatus TransactionStatus = "success" ETB Currency = "ETB" USD Currency = "USD" )
Variables ¶
View Source
var (
Customers = []Customer{
{
ID: 1002,
FirstName: firstName1,
LastName: lastName1,
Email: email1,
},
{
ID: 1032,
FirstName: firstName2,
LastName: lastName2,
Email: email2,
},
}
)
Placeholder data
Functions ¶
func InitConfig ¶
func InitConfig()
func RandomString ¶
Types ¶
type API ¶
type API interface { PaymentRequest(request *PaymentRequest) (*PaymentResponse, error) Verify(txnRef string) (*VerifyResponse, error) TransferToBank(request *BankTransfer) (*BankTransferResponse, error) GetTransactions() (*TransactionsResponse, error) GetBanks() (*BanksResponse, error) BulkTransfer(*BulkTransferRequest) (*BulkTransferResponse, error) }
type AppExamplePaymentService ¶
type AppExamplePaymentService struct {
// contains filtered or unexported fields
}
func NewExamplePaymentService ¶
func NewExamplePaymentService( paymentGatewayProvider API, ) *AppExamplePaymentService
func (*AppExamplePaymentService) Checkout ¶
func (s *AppExamplePaymentService) Checkout(ctx context.Context, CustomerID int64, form CheckoutForm) (*Transaction, error)
func (*AppExamplePaymentService) CustomerByID ¶
func (s *AppExamplePaymentService) CustomerByID(_ context.Context, CustomerID int64) (Customer, error)
CustomerByID you'd fetch Customer from the db
func (*AppExamplePaymentService) ListTransactions ¶
func (s *AppExamplePaymentService) ListTransactions(_ context.Context) (TransactionList, error)
func (*AppExamplePaymentService) SaveTransaction ¶
func (s *AppExamplePaymentService) SaveTransaction(_ context.Context, transaction Transaction) error
type Bank ¶
type Bank struct { ID int64 `json:"id"` Swift string `json:"swift"` Name string `json:"name"` AcctLength int64 `json:"acct_length"` CountryID int64 `json:"country_id"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` IsRTGS int64 `json:"is_rtgs"` IsMobileMoney int64 `json:"is_mobilemoney"` Currency Currency `json:"currency"` }
type BankTransfer ¶
type BankTransfer struct { // AccountName is the recipient Account Name matches on their bank account. AccountName string `json:"account_name"` // AccountNumber is the recipient Account Number. AccountNumber string `json:"account_number"` // Amount is the amount to be transferred to the recipient. Amount float64 `json:"amount"` // Currency is the currency for the Transfer. Expected value is ETB. Currency string `json:"currency"` // Reference is merchant’s uniques reference for the transfer, // it can be used to query for the status of the transfer. Reference string `json:"reference"` // BankCode is the recipient bank code. // You can see a list of all the available banks and their codes from the get banks endpoint. BankCode string `json:"bank_code"` }
BankTransfer is an object used in bank transfer.
func (BankTransfer) Validate ¶
func (t BankTransfer) Validate() error
type BankTransferResponse ¶
type BanksResponse ¶
type BulkTransferRequest ¶
type BulkTransferRequest struct { Title string `json:"title"` Currency string `json:"currency"` BulkData []BulkData `json:"bulk_data"` }
func (BulkTransferRequest) Validate ¶
func (t BulkTransferRequest) Validate() error
type BulkTransferResponse ¶
type BulkTransferResponse struct { Message string `json:"message"` Status string `json:"status"` Data BulkTransferResponseData `json:"data"` }
type CheckoutForm ¶
type ExamplePaymentService ¶
type ExamplePaymentService interface { Checkout(ctx context.Context, CustomerID int64, form *CheckoutForm) (*PaymentResponse, error) ListTransactions(ctx context.Context) (*TransactionList, error) }
type Pagination ¶
type PaymentRequest ¶
type PaymentRequest struct { Amount decimal.Decimal `json:"amount"` Currency string `json:"currency"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Phone string `json:"phone"` CallbackURL string `json:"callback_url"` TransactionRef string `json:"tx_ref"` Customization map[string]interface{} `json:"customization"` }
func (PaymentRequest) Validate ¶
func (p PaymentRequest) Validate() error
type PaymentResponse ¶
type Transaction ¶
type Transaction struct { Status TransactionStatus `json:"status"` RefID string `json:"ref_id"` Type string `json:"type"` CreatedAt string `json:"created_at"` Currency string `json:"currency"` Amount decimal.Decimal `json:"amount"` Charge string `json:"charge"` TransID string `json:"trans_id"` PaymentMethod string `json:"payment_method"` Customer Customer `json:"customer"` }
type TransactionList ¶
type TransactionList struct { Transactions []Transaction `json:"transactions"` Pagination Pagination `json:"pagination"` }
type TransactionStatus ¶
type TransactionStatus string
type TransactionsResponse ¶
type TransactionsResponse struct { Message string `json:"message"` Status string `json:"status"` Data TransactionList `json:"data"` }
type VerifyResponse ¶
Click to show internal directories.
Click to hide internal directories.