payment

package
v0.0.0-...-430864d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidJson = errors.New("Invalid json")
View Source
var ErrInvalidPaymentAmount = errors.New("Invalid payment amount")

Functions

func MakeAuthoriseEndpoint

func MakeAuthoriseEndpoint(s Service) endpoint.Endpoint

MakeListEndpoint returns an endpoint via the given service.

func MakeHTTPHandler

func MakeHTTPHandler(ctx context.Context, e Endpoints, logger log.Logger) http.Handler

MakeHTTPHandler mounts the endpoints into a REST-y HTTP handler.

func MakeHealthEndpoint

func MakeHealthEndpoint(s Service) endpoint.Endpoint

MakeHealthEndpoint returns current health of the given service.

func WireUp

func WireUp(ctx context.Context, declineAmount float32) (http.Handler, log.Logger)

Types

type Authorisation

type Authorisation struct {
	Authorised bool `json:"authorised"`
}

type AuthoriseRequest

type AuthoriseRequest struct {
	Amount float32 `json:"amount"`
}

AuthoriseRequest represents a request for payment authorisation. The Amount is the total amount of the transaction

type AuthoriseResponse

type AuthoriseResponse struct {
	Authorisation Authorisation
	Err           error
}

AuthoriseResponse returns a response of type Authorisation and an error, Err.

type Endpoints

type Endpoints struct {
	AuthoriseEndpoint endpoint.Endpoint
	HealthEndpoint    endpoint.Endpoint
}

Endpoints collects the endpoints that comprise the Service.

func MakeEndpoints

func MakeEndpoints(s Service) Endpoints

MakeEndpoints returns an Endpoints structure, where each endpoint is backed by the given service.

type Middleware

type Middleware func(Service) Service

Middleware decorates a service.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

LoggingMiddleware logs method calls, parameters, results, and elapsed time.

type Service

type Service interface {
	Authorise(total float32) (Authorisation, error) // GET /paymentAuth
}

func NewAuthorisationService

func NewAuthorisationService(declineOverAmount float32) Service

NewFixedService returns a simple implementation of the Service interface, fixed over a predefined set of socks and tags. In a real service you'd probably construct this with a database handle to your socks DB, etc.

type UnmarshalKeyError

type UnmarshalKeyError struct {
	Key  string
	JSON string
}

func (*UnmarshalKeyError) Error

func (e *UnmarshalKeyError) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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