transaction

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	AuthorizationCode string `json:"authorization_code,omitempty"`
	Bin               string `json:"bin,omitempty"`
	Last4             string `json:"last4,omitempty"`
	ExpMonth          string `json:"exp_month,omitempty"`
	ExpYear           string `json:"exp_year,omitempty"`
	Channel           string `json:"channel,omitempty"`
	CardType          string `json:"card_type,omitempty"`
	Bank              string `json:"bank,omitempty"`
	CountryCode       string `json:"country_code,omitempty"`
	Brand             string `json:"brand,omitempty"`
	Resusable         bool   `json:"reusable,omitempty"`
	Signature         string `json:"signature,omitempty"`
	Source            Source `json:"source,omitempty"`
}

Authorization represents Paystack authorization object

type AuthorizationRequest

type AuthorizationRequest struct {
	Reference         string          `json:"reference,omitempty"`
	AuthorizationCode string          `json:"authorization_code,omitempty"`
	Amount            int             `json:"amount,omitempty"`
	Currency          string          `json:"currency,omitempty"`
	Email             string          `json:"email,omitempty"`
	Metadata          client.Metadata `json:"metadata,omitempty"`
}

AuthorizationRequest represents a request to enable/revoke an authorization

type Customer added in v0.2.0

type Customer struct {
	Id                       int               `json:"id"`
	FirstName                string            `json:"first_name,omitempty"`
	LastName                 string            `json:"last_name,omitempty"`
	Email                    string            `json:"email,omitempty"`
	CustomerCode             string            `json:"customer_code,omitempty"`
	Phone                    string            `json:"phone,omitempty"`
	Metadata                 map[string]string `json:"metadata,omitempty"`
	RiskAction               string            `json:"risk_action,omitempty"`
	InternationalFormatPhone string            `json:"international_format_phone,omitempty"`
}

type DefaultTransactionService

type DefaultTransactionService struct {
	*client.Client
}

DefaultTransactionService handles operations related to transactions For more details see https://developers.paystack.co/v1.0/reference#create-transaction

func (*DefaultTransactionService) ChargeAuthorization

func (s *DefaultTransactionService) ChargeAuthorization(ctx context.Context, req *Request) (*Transaction, error)

ChargeAuthorization is for charging all authorizations marked as reusable whenever you need to recieve payments. For more details see https://developers.paystack.co/v1.0/reference#charge-authorization

func (*DefaultTransactionService) CheckAuthorization

CheckAuthorization checks authorization For more details see https://developers.paystack.co/v1.0/reference#check-authorization

func (*DefaultTransactionService) Export

Export exports transactions to a downloadable file and returns a link to the file For more details see https://developers.paystack.co/v1.0/reference#export-transactions

func (*DefaultTransactionService) Get

Get returns the details of a transaction. For more details see https://developers.paystack.co/v1.0/reference#fetch-transaction

func (*DefaultTransactionService) Initialize

Initialize initiates a transaction process For more details see https://developers.paystack.co/v1.0/reference#initialize-a-transaction

func (*DefaultTransactionService) List

List returns a list of transactions. For more details see https://paystack.com/docs/api/#transaction-list

func (*DefaultTransactionService) ListForCustomer added in v0.2.0

func (s *DefaultTransactionService) ListForCustomer(ctx context.Context, customerId string) (*List, error)

func (*DefaultTransactionService) ListN

func (s *DefaultTransactionService) ListN(ctx context.Context, count, offset int) (*List, error)

ListN returns a list of transactions For more details see https://developers.paystack.co/v1.0/reference#list-transactions

func (*DefaultTransactionService) ReAuthorize

ReAuthorize requests reauthorization For more details see https://developers.paystack.co/v1.0/reference#request-reauthorization

func (*DefaultTransactionService) Timeline

func (s *DefaultTransactionService) Timeline(ctx context.Context, reference string) (*Timeline, error)

Timeline fetches the transaction timeline. Reference can be ID or transaction reference For more details see https://developers.paystack.co/v1.0/reference#view-transaction-timeline

func (*DefaultTransactionService) Totals

Totals returns total amount received on your account For more details see https://developers.paystack.co/v1.0/reference#transaction-totals

func (*DefaultTransactionService) Verify

func (s *DefaultTransactionService) Verify(ctx context.Context, reference string) (*Transaction, error)

Verify checks that transaction with the given reference exists For more details see https://api.paystack.co/transaction/verify/reference

type History added in v0.2.0

type History struct {
	Type    string `json:"type,omitempty"`
	Message string `json:"message,omitempty"`
	Time    int    `json:"time,omitempty"`
}

type List

type List struct {
	Meta   response.ListMeta
	Values []Transaction `json:"data"`
}

List is a list object for transactions.

type Log added in v0.2.0

type Log struct {
	StartTime int           `json:"start_time,omitempty"`
	TimeSpent int           `json:"time_spent,omitempty"`
	Attempts  int           `json:"attempts,omitempty"`
	Errors    int           `json:"errors,omitempty"`
	Success   bool          `json:"success,omitempty"`
	Mobile    bool          `json:"mobile,omitempty"`
	Input     []interface{} `json:"input,omitempty"`
	History   []History     `json:"history,omitempty"`
}

type Request

type Request struct {
	CallbackURL       string          `json:"callback_url,omitempty"`
	Reference         string          `json:"reference,omitempty"`
	AuthorizationCode string          `json:"authorization_code,omitempty"`
	Currency          string          `json:"currency,omitempty"`
	Amount            float32         `json:"amount,omitempty"`
	Email             string          `json:"email,omitempty"`
	Plan              string          `json:"plan,omitempty"`
	InvoiceLimit      int             `json:"invoice_limit,omitempty"`
	Metadata          client.Metadata `json:"metadata,omitempty"`
	SubAccount        string          `json:"subaccount,omitempty"`
	TransactionCharge int             `json:"transaction_charge,omitempty"`
	Bearer            string          `json:"bearer,omitempty"`
	Channels          []string        `json:"channels,omitempty"`
}

Request represents a request to start a transaction.

type Service

type Service interface {
	Initialize(ctx context.Context, txn *Request) (response.Response, error)
	Verify(ctx context.Context, reference string) (*Transaction, error)
	List(ctx context.Context) (*List, error)
	ListForCustomer(ctx context.Context, customerId string) (*List, error)
	ListN(ctx context.Context, count, offset int) (*List, error)
	Get(ctx context.Context, id int) (*Transaction, error)
	ChargeAuthorization(ctx context.Context, req *Request) (*Transaction, error)
	Timeline(ctx context.Context, reference string) (*Timeline, error)
	Totals(ctx context.Context) (response.Response, error)
	Export(ctx context.Context, params response.RequestValues) (response.Response, error)
	ReAuthorize(ctx context.Context, req AuthorizationRequest) (response.Response, error)
	CheckAuthorization(ctx context.Context, req AuthorizationRequest) (response.Response, error)
}

type Source added in v0.2.0

type Source struct {
	Source     string      `json:"source,omitempty"`
	Type       string      `json:"type,omitempty"`
	Identifier interface{} `json:"identifier,omitempty"`
	EntryPoint string      `json:"entry_point,omitempty"`
}

type Timeline

type Timeline struct {
	TimeSpent      int                      `json:"time_spent,omitempty"`
	Attempts       int                      `json:"attempts,omitempty"`
	Authentication string                   `json:"authentication,omitempty"` // TODO: confirm type
	Errors         int                      `json:"errors,omitempty"`
	Success        bool                     `json:"success,omitempty"`
	Mobile         bool                     `json:"mobile,omitempty"`
	Input          []string                 `json:"input,omitempty"` // TODO: confirm type
	Channel        string                   `json:"channel,omitempty"`
	History        []map[string]interface{} `json:"history,omitempty"`
}

Timeline represents a timeline of events in a transaction session

type Transaction

type Transaction struct {
	ID              int                   `json:"id,omitempty"`
	CreatedAt       string                `json:"createdAt,omitempty"`
	Domain          string                `json:"domain,omitempty"`
	Metadata        interface{}           `json:"metadata,omitempty"` //TODO: why is transaction metadata a string?
	Status          string                `json:"status,omitempty"`
	Reference       string                `json:"reference,omitempty"`
	Amount          float32               `json:"amount,omitempty"`
	Message         string                `json:"message,omitempty"`
	GatewayResponse string                `json:"gateway_response,omitempty"`
	PaidAt          string                `json:"piad_at,omitempty"`
	Channel         string                `json:"channel,omitempty"`
	Currency        string                `json:"currency,omitempty"`
	IPAddress       string                `json:"ip_address,omitempty"`
	Log             Log                   `json:"log,omitempty"` // TODO: same as timeline?
	Fees            int                   `json:"int,omitempty"`
	FeesSplit       string                `json:"fees_split,omitempty"` // TODO: confirm data type
	Customer        Customer              `json:"customer,omitempty"`
	Authorization   Authorization         `json:"authorization,omitempty"`
	Plan            plan.Plan             `json:"plan,omitempty"`
	SubAccount      subaccount.SubAccount `json:"sub_account,omitempty"`
}

Transaction is the resource representing your Paystack transaction. For more details see https://developers.paystack.co/v1.0/reference#initialize-a-transaction

Jump to

Keyboard shortcuts

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