e5

package
v0.0.0-...-0ca455c Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package e5 contains the client used to interact with E5

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToReadBody is a generic error when failing to parse a response body
	ErrFailedToReadBody = errors.New("failed reading the body of the response")
	// ErrE5BadRequest is a 400
	ErrE5BadRequest = errors.New("failed request to E5")
	// ErrE5InternalServer is anything in the 5xx
	ErrE5InternalServer = errors.New("got an internal server error from E5")
	// ErrE5NotFound is a 404
	ErrE5NotFound = errors.New("not found")
	// ErrUnexpectedServerError represents anything other than a 400, 404 or 500 - which would be something not
	// documented in their API
	ErrUnexpectedServerError = errors.New("unexpected server error")
)

Functions

This section is empty.

Types

type Action

type Action string

Action is the type that describes a payment call to E5

const (
	// CreateAction signifies payment creation. This locks the customer account.
	CreateAction Action = "create"
	// AuthoriseAction signifies the payment has been authorised - but money not confirmed
	AuthoriseAction Action = "authorise"
	// ConfirmAction signifies money has been received. The customer account will not be unlocked
	ConfirmAction Action = "confirm"
	// TimeoutAction can be used to unlock the account following authorisation
	TimeoutAction Action = "timeout"
	// RejectAction will reject the payment altogether
	RejectAction Action = "reject"
)

type AuthorisePaymentInput

type AuthorisePaymentInput struct {
	CompanyCode         string `json:"companyCode" validate:"required"`
	PaymentID           string `json:"paymentId" validate:"required"`
	CardReference       string `json:"paymentCardReference"`
	AuthorisationNumber string `json:"authorisationNumber"`
	CardType            string `json:"cardType"`
	Email               string `json:"emailAddress" validate:"required,email"`
}

AuthorisePaymentInput is the struct to authorise payment

type Client

type Client struct {
	E5Username string
	E5BaseURL  string
}

Client interacts with the Client finance system

func NewClient

func NewClient(username, baseURL string) *Client

NewClient will construct a new E5 client service struct that can be used to interact with the Client finance system

func (*Client) AuthorisePayment

func (c *Client) AuthorisePayment(input *AuthorisePaymentInput) error

AuthorisePayment will mark the payment as been authorised by the payment provider, but the money has not yet reached use yet. The customer account will remain locked.

func (*Client) ConfirmPayment

func (c *Client) ConfirmPayment(input *PaymentActionInput) error

ConfirmPayment allocates the money in Client and unlocks the customer account

func (*Client) CreatePayment

func (c *Client) CreatePayment(input *CreatePaymentInput) error

CreatePayment will create a new payment session in Client. This will lock the account in Client so no other modifications can happen until the it is released by a confirm call or manually released in the Client portal.

func (*Client) GetTransactions

func (c *Client) GetTransactions(input *GetTransactionsInput) (*GetTransactionsResponse, error)

GetTransactions will return a list of transactions for a company

func (*Client) RejectPayment

func (c *Client) RejectPayment(input *PaymentActionInput) error

RejectPayment will mark a payment as rejected and unlock the account.

func (*Client) TimeoutPayment

func (c *Client) TimeoutPayment(input *PaymentActionInput) error

TimeoutPayment will unlock the customer account

type CreatePaymentInput

type CreatePaymentInput struct {
	CompanyCode   string                      `json:"companyCode" validate:"required"`
	CompanyNumber string                      `json:"customerCode" validate:"required"`
	PaymentID     string                      `json:"paymentId" validate:"required"`
	TotalValue    float64                     `json:"paymentValue" validate:"required"`
	Transactions  []*CreatePaymentTransaction `json:"transactions" validate:"required"`
}

CreatePaymentInput is the struct needed to send a create payment request to the Client API

type CreatePaymentTransaction

type CreatePaymentTransaction struct {
	Reference string  `json:"transactionReference" validate:"required"`
	Value     float64 `json:"allocationValue" validate:"required"`
}

CreatePaymentTransaction is the struct to define the transactions you want to pay for

type GetTransactionsInput

type GetTransactionsInput struct {
	CompanyCode   string `validate:"required"`
	CompanyNumber string `validate:"required"`
	PageNumber    int
}

GetTransactionsInput is the struct used to query transactions by company number

type GetTransactionsResponse

type GetTransactionsResponse struct {
	Page         Page          `json:"page"`
	Transactions []Transaction `json:"data"`
}

GetTransactionsResponse returns the output of a get request for company transactions

type Page

type Page struct {
	Size          int `json:"size"`
	TotalElements int `json:"totalElements"`
	TotalPages    int `json:"totalPages"`
	Number        int `json:"number"`
}

Page is a representation of a Page data block in part of e5 GET request

type PaymentActionInput

type PaymentActionInput struct {
	CompanyCode string `json:"companyCode" validate:"required"`
	PaymentID   string `json:"paymentId" validate:"required"`
}

PaymentActionInput input is the struct used for the confirm, reject and timeout actions

type PaymentActionResponse

type PaymentActionResponse struct {
	Success      bool
	ErrorMessage string
}

PaymentActionResponse is the return value of a successful request to create a payment

type Transaction

type Transaction struct {
	CompanyCode          string  `json:"companyCode"`
	LedgerCode           string  `json:"ledgerCode"`
	CustomerCode         string  `json:"customerCode"`
	TransactionReference string  `json:"transactionReference"`
	TransactionDate      string  `json:"transactionDate"`
	MadeUpDate           string  `json:"madeUpDate"`
	Amount               float64 `json:"amount"`
	OutstandingAmount    float64 `json:"outstandingAmount"`
	IsPaid               bool    `json:"isPaid"`
	TransactionType      string  `json:"transactionType"`
	TransactionSubType   string  `json:"transactionSubType"`
	TypeDescription      string  `json:"typeDescription"`
	DueDate              string  `json:"dueDate"`
	AccountStatus        string  `json:"accountStatus"`
}

Transaction is a representation of a transaction item in E5

Jump to

Keyboard shortcuts

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