multisafego

package module
v0.0.0-...-a94291b Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2016 License: MIT Imports: 11 Imported by: 0

README

GoDoc

Go binding for MultiSafePay

Bindings for the MultiSafePay payment provider in go

Installation
go get github.com/SLASH2NL/multisafego
Documentation

See godoc http://godoc.org/github.com/SLASH2NL/multisafego

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TESTURL is the url to use in test mode
	TESTURL *url.URL
	// PRODURL is the url to use in production mode
	PRODURL *url.URL
)

Functions

func Path

func Path(path string) string

Path is a shortcut for prepending /v1/json to the path

Types

type APIError

type APIError struct {
	Code    int         `json:"error_code"`
	Message string      `json:"error_info"`
	Data    interface{} `json:"data"`
}

A APIError occurs when the response has a non 200 status code default error values like a timeout will be wrapped in an APIError with code -1

func (APIError) String

func (a APIError) String() string

type Gateway

type Gateway struct {
	ID          string `json:"id"`
	Description string `json:"description"`
}

Gateway represents a gateway in multisafepay(IDEAL, Paypal)

type Issuer

type Issuer struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

Issuer represents an issuer for an Gateway

type MultiSafePay

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

MultiSafePay is the wrapper for calls to the Api. Use the New function to construct a basic variant

func New

func New(apiKey string, baseURL *url.URL, debug bool) *MultiSafePay

New returns a basic multisafepay object that can be set in debug mode to dump requests/responses

func (*MultiSafePay) Call

func (m *MultiSafePay) Call(url *url.URL, method string, payload io.Reader) (*http.Response, error)

Call can be used to get the raw unparsed http.Response. Remember to close the response body when using this function.

func (*MultiSafePay) Execute

func (m *MultiSafePay) Execute(url *url.URL, method string, payload interface{}, returnVal interface{}) *APIError

Execute will do a json call to multisafepay payload represents the request body that will be encoded as json the returnVal will be transformed the same way json.Unmarshal does. If an error occurs an APIError will be returned

func (*MultiSafePay) Gateways

func (m *MultiSafePay) Gateways(locale, currency string, amount int, country string) ([]Gateway, *APIError)

Gateways will return the gateways for the api Use default values if no filters apply: Gateways("", "", 0) locale should be in ISO 639-1 currency should be in ISO 4217 amount should be in cents

func (*MultiSafePay) GetOrder

func (m *MultiSafePay) GetOrder(id int) (*OrderInfo, *APIError)

GetOrder returns info about an order placed

func (*MultiSafePay) GetTransaction

func (m *MultiSafePay) GetTransaction(transactionID int) (*Transaction, *APIError)

GetTransaction returns infomation about the payment

func (*MultiSafePay) Issuers

func (m *MultiSafePay) Issuers(id string) ([]Issuer, *APIError)

Issuers will return the issuers for the supplied gateway id

func (*MultiSafePay) PlaceOrder

func (m *MultiSafePay) PlaceOrder(o Order) (*Payment, *APIError)

PlaceOrder will post an order and return the response urls

type Order

type Order map[string]interface{}

Order is the container for holding all the order parametersa that should be posted

func NewOrder

func NewOrder() Order

NewOrder is a shortcut method for creating the order map

func (Order) SetIssuer

func (o Order) SetIssuer(gateway string, issuer string)

SetIssuer for the order to enable direct payments

func (Order) SetPaymentOptions

func (o Order) SetPaymentOptions(notifyURL, redirectURL, cancelURL string, closeWindow bool)

SetPaymentOptions sets the urls for the payment

type OrderInfo

type OrderInfo struct {
	Amount         int
	AmountRefunded int
	//Created        time.Time `json:"created"`
	Currency string `json:"currency"`
	Customer struct {
		Email  string `json:"email"`
		Locale string `json:"locale"`
	} `json:"customer"`
	Description string `json:"description"`
	//Modified       time.Time `json:"modified"`
	OrderID        int
	PaymentDetails struct {
		AccountHolderName     interface{} `json:"account_holder_name"`
		AccountID             interface{} `json:"account_id"`
		ExternalTransactionID interface{} `json:"external_transaction_id"`
		RecurringID           interface{} `json:"recurring_id"`
		Type                  string      `json:"type"`
	} `json:"payment_details"`
	Status        string `json:"status"`
	TransactionID int

	TransactionIDJSON  interface{} `json:"transaction_id"`
	OrderIDJSON        interface{} `json:"order_id"`
	AmountJSON         interface{} `json:"amount"`
	AmountRefundedJSON interface{} `json:"amount_refunded"`
}

OrderInfo is returned from the GetOrder function and contains the TransactionId which can be used to grab the payment status

type Payment

type Payment struct {
	URL         string `json:"payment_url"`
	OrderID     int
	OrderIDJSON interface{} `json:"order_id"`
}

Payment is the response from PlaceOrder

type Transaction

type Transaction struct {
	Amount   int
	Created  string `json:"created"`
	Currency string `json:"currency"`
	Customer struct {
		Email string `json:"email"`
	} `json:"customer"`
	Description    string `json:"description"`
	OrderID        int
	OrderStatus    string `json:"order_status"`
	PaymentDetails struct {
		AccountHolderName     interface{} `json:"account_holder_name"`
		AccountID             interface{} `json:"account_id"`
		ExternalTransactionID string      `json:"external_transaction_id"`
		RecurringID           interface{} `json:"recurring_id"`
		Type                  string      `json:"type"`
	} `json:"payment_details"`
	Status        string      `json:"status"`
	TransactionID interface{} `json:"transaction_id"`
	Type          string      `json:"type"`

	AmountJSON  interface{} `json:"amount"`
	OrderIDJSON interface{} `json:"order_id"`
}

Transaction contains a transaction for an order

func (*Transaction) IsCompleted

func (t *Transaction) IsCompleted() bool

IsCompleted returns true if a payment is succesfull

Jump to

Keyboard shortcuts

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