paysimple

package module
v0.0.0-...-10525c6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: MIT Imports: 14 Imported by: 0

README

paysimple-go GoDoc

PaySimple Go Library

Quickstart

Set the environmental variables PAYSIMPLE_USER and PAYSIMPLE_SECRET

Create either a live or sandboxed API:

api := API()
// Or
api := Sandbox()

Create customers, accounts, and payments as needed:

customer := Customer{
    FirstName:             "Test",
    LastName:              "Customer",
    ShippingSameAsBilling: true,
}
created, err := api.Customers.Create(customer)
if err != nil {
    log.Panic(err)
}

For more information, see the PaySimple API documentation: http://developer.paysimple.com/documentation/

  • aodin, 2015

Documentation

Index

Constants

View Source
const (
	Visa       Issuer = "12"
	MasterCard        = "13"
	Amex              = "14"
	Discover          = "15"
)

Variables

This section is empty.

Functions

func API

func API() *api

func CreateAuthorization

func CreateAuthorization(username, apiKey string) string

func Sandbox

func Sandbox() *api

Types

type Accounts

type Accounts struct {
	// contains filtered or unexported fields
}

Accounts handles requests to the Account API endpoint

func (*Accounts) CreateCreditCard

func (c *Accounts) CreateCreditCard(create CreditCard) (CreditCard, error)

CreateCreditCard creates a new credit card account

type Address

type Address struct {
	StreetAddress1 string
	StreetAddress2 string
	City           string
	StateCode      string
	ZipCode        string
	Country        string
}

type Config

type Config struct {
	Username, SecretKey string
}

func Env

func Env() (config Config)

func (Config) IsValid

func (config Config) IsValid() bool

type CreditCard

type CreditCard struct {
	CreditCardNumber string
	ExpirationDate   string
	Issuer           Issuer
	BillingZipCode   string
	CustomerID       int64 `json:"CustomerId"`
	IsDefault        bool
	ID               int64 `json:"Id"`
	LastModified     time.Time
	CreatedOn        time.Time
}

type CreditCardResponse

type CreditCardResponse struct {
	Meta     Meta
	Response CreditCard
}

CreditCardResponse is returned by Accounts.CreateCreditCard

type Customer

type Customer struct {
	ID                    int64 `json:"Id,omitempty"`
	FirstName             string
	MiddleName            string `json:",omitempty"`
	LastName              string
	BillingAddress        *Address `json:",omitempty"`
	ShippingSameAsBilling bool
	ShippingAddress       *Address   `json:",omitempty"`
	Company               string     `json:",omitempty"`
	CustomerAccount       string     `json:",omitempty"`
	Phone                 string     `json:",omitempty"`
	AltPhone              string     `json:",omitempty"`
	MobilePhone           string     `json:",omitempty"`
	Fax                   string     `json:",omitempty"`
	Email                 string     `json:",omitempty"`
	AltEmail              string     `json:",omitempty"`
	Website               string     `json:",omitempty"`
	Notes                 string     `json:",omitempty"`
	LastModified          *time.Time `json:",omitempty"`
	CreatedOn             *time.Time `json:",omitempty"`
}

type CustomerResponse

type CustomerResponse struct {
	Meta     Meta
	Response Customer
}

CustomerResponse is returned by Customers.Create

type Customers

type Customers struct {
	// contains filtered or unexported fields
}

Customers handles requests to the Customer API endpoint

func (*Customers) Create

func (c *Customers) Create(create Customer) (created Customer, err error)

Create creates and returns a single customer

func (*Customers) Get

func (c *Customers) Get(id int64) (customer Customer, err error)

Get returns a single customer

func (*Customers) List

func (c *Customers) List() ([]Customer, error)

List returns a list of customers TODO filters

type CustomersResponse

type CustomersResponse struct {
	Meta     Meta
	Response []Customer
}

CustomersResponse is returned by Customers.List

type Date

type Date struct {
	time.Time
}

Date discards time of day information

func NewDate

func NewDate(year, month, day int) Date

NewDate creates a new Date

func (Date) String

func (date Date) String() string

type Empty

type Empty struct {
	Meta Meta
}

Empty responses are returned when detail operations fail

type ErrorCode

type ErrorCode string
const (
	InvalidInput       ErrorCode = "InvalidInput"
	InvalidPermissions ErrorCode = "InvalidPermissions"
	NotFound           ErrorCode = "NotFound"
	UnexpectedError    ErrorCode = "UnexpectedError"
)

type ErrorMessage

type ErrorMessage struct {
	Field   string
	Message string
}

func (ErrorMessage) String

func (msg ErrorMessage) String() string

type Errors

type Errors struct {
	ErrorCode     ErrorCode
	ErrorMessages []ErrorMessage
	TraceCode     string
	StatusCode    int // Not part of the API - added so error has code
}

func (Errors) Error

func (err Errors) Error() string

Error implements the built-in interface for Errors

type Failure

type Failure struct {
	Code               string
	Description        string
	MerchantActionText string
	IsDecline          bool
}

type Filters

type Filters interface {
	Values() url.Values
}

type Issuer

type Issuer string

type Meta

type Meta struct {
	Errors         *Errors
	HttpStatus     string
	HttpStatusCode int
	PagingDetails  struct {
		TotalItems   int64
		Page         int64
		ItemsPerPage int64
	}
}

type PaginationFilters

type PaginationFilters struct {
	Page, PageSize int
}

func (PaginationFilters) Values

func (f PaginationFilters) Values() url.Values

Values generates GET parameters from the given filters

type Payment

type Payment struct {
	ID                  int64 `json:"Id"`
	CustomerID          int64 `json:"CustomerId"`
	CustomerFirstName   string
	CustomerLastName    string
	CustomerCompany     string
	ReferenceID         int64 `json:"ReferenceId"`
	Status              string
	RecurringScheduleID int64 `json:"RecurringScheduleId"`
	PaymentType         string
	PaymentSubType      string
	ProviderAuthCode    string
	TraceNumber         string
	PaymentDate         time.Time
	ReturnDate          *time.Time
	EstimatedSettleDate time.Time
	ActualSettledDate   *time.Time
	CanVoidUntil        time.Time
	Amount              float64
	FailureData         Failure
	AccountID           int64 `json:"AccountId"`
	InvoiceID           int64 `json:"InvoiceId"`
	IsDebit             bool
	InvoiceNumber       string // TODO or int64?
	PurchaseOrderNumber string // TODO or int64?
	OrderID             int64  `json:"OrderId"`
	Description         string
	Latitude            *float64
	Longitude           *float64
	LastModified        time.Time
	CreateOn            time.Time
}

type PaymentFilters

type PaymentFilters struct {
	PaginationFilters
	StartDate, EndDate Date
	Lite               bool
}

PaymentFilters create GET parameters for the payments endpoint

func (PaymentFilters) Values

func (f PaymentFilters) Values() url.Values

Values returns GET parameters for payments

type Payments

type Payments struct {
	// contains filtered or unexported fields
}

Payments handles requests to the Payment API endpoint

func (*Payments) List

func (c *Payments) List() ([]Payment, error)

List returns multiple payments TODO pass filters

type PaymentsResponse

type PaymentsResponse struct {
	Meta     Meta
	Response []Payment
}

PaymentsResponse is the response returned from the payments endpoint

type Status

type Status int64
const (
	Pending Status = iota
	Posted
	Settled
	Failed

	Voided
	Reversed

	ReversePosted
	Chargeback

	Authorized

	Returned

	ReverseNSF

	RefundSettled
)

Jump to

Keyboard shortcuts

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