Documentation ¶
Index ¶
- Variables
- func Path(path string) string
- type APIError
- type Gateway
- type Issuer
- type MultiSafePay
- func (m *MultiSafePay) Call(url *url.URL, method string, payload io.Reader) (*http.Response, error)
- func (m *MultiSafePay) Execute(url *url.URL, method string, payload interface{}, returnVal interface{}) *APIError
- func (m *MultiSafePay) Gateways(locale, currency string, amount int, country string) ([]Gateway, *APIError)
- func (m *MultiSafePay) GetOrder(id int) (*OrderInfo, *APIError)
- func (m *MultiSafePay) GetTransaction(transactionID int) (*Transaction, *APIError)
- func (m *MultiSafePay) Issuers(id string) ([]Issuer, *APIError)
- func (m *MultiSafePay) PlaceOrder(o Order) (*Payment, *APIError)
- type Order
- type OrderInfo
- type Payment
- type Transaction
Constants ¶
This section is empty.
Variables ¶
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 ¶
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
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 ¶
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 (Order) SetPaymentOptions ¶
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