Documentation
¶
Overview ¶
Models provides predefined structures to facilitate interaction with PixelPay entities.
We strongly recommend that you use the special methods to create objects from the structure of each model. These methods provide a correctly initialized structure.
Note that you can use chaining with these methods.
Index ¶
- type Billing
- type Card
- type Item
- type Order
- type Settings
- func (model *Settings) SetupCredentials(key, hash string) *Settings
- func (model *Settings) SetupEndpoint(endpoint string) *Settings
- func (model *Settings) SetupEnvironment(env string) *Settings
- func (model *Settings) SetupLanguage(lang string) *Settings
- func (model *Settings) SetupPlatformUser(hash string) *Settings
- func (model *Settings) SetupSandbox() *Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Billing ¶
type Billing struct {
// Customer billing address
Address string `json:"address,omitempty"`
// Customer billing country alpha-2 code (ISO 3166-1)
Country string `json:"country,omitempty"`
// Customer billing state alpha code (ISO 3166-2)
State string `json:"state,omitempty"`
// Customer billing city
City string `json:"city,omitempty"`
// Customer billing postal code
Zip string `json:"zip,omitempty"`
// Customer billing phone
Phone string `json:"phone,omitempty"`
}
Billing represents the billing information for a request.
func NewBilling ¶
func NewBilling() *Billing
NewBilling initializes and returns a new instance of the Billing model.
type Card ¶
type Card struct {
// Card number or PAN
Number string `json:"number,omitempty"`
// Card security code
Cvv2 string `json:"cvv2,omitempty"`
// Card expire month date (MM)
ExpireMonth int `json:"expire_month,omitempty"`
// Card expire year date (YYYY)
ExpireYear int `json:"expire_year,omitempty"`
// Cardholder name
Cardholder string `json:"cardholder,omitempty"`
}
Card represents the card information for a request.
func NewCard ¶
func NewCard() *Card
NewCard initializes and returns a new instance of the Card model.
func (Card) GetExpireFormat ¶
GetExpireFormat returns the expiration date of a credit card in the YYMM ISO format.
type Item ¶
type Item struct {
// Item identifier code or UPC/EAN
Code string `json:"code,omitempty"`
// Item product title
Title string `json:"title,omitempty"`
// Item per unit price
Price float64 `json:"price,omitempty"`
// Item quantity
Qty int `json:"qty,omitempty"`
// Item tax amount per unit
Tax float64 `json:"tax,omitempty"`
// Item total value
Total float64 `json:"total,omitempty"`
}
Item represents the item information for a request.
type Order ¶
type Order struct {
// Order ID
Id string `json:"id,omitempty"`
// Order currency code alpha-3
Currency string `json:"currency,omitempty"`
// Order total amount
Amount float64 `json:"amount,omitempty"`
// Order total tax amount
TaxAmount float64 `json:"tax_amount,omitempty"`
// Order total shipping amount
ShippingAmount float64 `json:"shipping_amount,omitempty"`
// Order summary of items or products
Content []Item `json:"content,omitempty"`
// Order extra properties
Extras map[string]string `json:"extras,omitempty"`
// Order note or aditional instructions
Note string `json:"note,omitempty"`
// Order calback webhook URL
CallbackUrl string `json:"callback_url,omitempty"`
// Order customer name
CustomerName string `json:"customer_name,omitempty"`
// Order customer email
CustomerEmail string `json:"customer_email,omitempty"`
}
Order represents the order information for a request.
func NewOrder ¶
func NewOrder() *Order
NewOrder initializes and returns a new instance of the Order model.
func (*Order) AddExtra ¶
AddExtra adds extra properties related to the order.
The `key` parameter represents the id of the extra. The `value` parameter represents the content of the extra.
This function updates the Extra property of the Order model.
func (*Order) AddItem ¶
AddItem appends an item to the content list of the order.
The `item` parameter represents the item to be added to the order.
This function updates the order amount by calling Totalize().
func (*Order) Totalize ¶
Totalize calculates the tax and amount of the order by calling the Totalize() function for each Item. To calculate the amount, it adds up the total of all items. To calculate the tax, it multiplies the tax of each item by its quantity. This function updates the TaxAmount, the Amount and every Item of the Order model.
type Settings ¶
type Settings struct {
// Merchant API auth key
AuthKey string `json:"auth_key,omitempty"`
// Merchant API auth hash (MD5 of secret key)
AuthHash string `json:"auth_hash,omitempty"`
// Merchant API platform auth user (SHA-512 of user email)
AuthUser string `json:"auth_user,omitempty"`
// Merchant API endpoint URL
Endpoint string `json:"endpoint,omitempty"`
// Merchant API environment
Environment string `json:"environment,omitempty"`
// Settings response messages language
Lang string `json:"lang,omitempty"`
// SDK identifier
Sdk string `json:"sdk,omitempty"`
}
Settings represents the settings information for a request.
func NewSettings ¶
func NewSettings() *Settings
NewSettings initializes and returns a new instance of the Settings model.
func (*Settings) SetupCredentials ¶
Sets up the API credentials.
The `key` parameter represents the merchant'model key ID. The `hash` parameter represents the merchant'model secret key.
This function updates the Settings model.
func (*Settings) SetupEndpoint ¶
Sets up the API endpoint URL.
The `endpoint` parameter represents the URL to connect to the API.
This function updates the Settings model.
func (*Settings) SetupEnvironment ¶
Sets up the API environment.
The `env` parameter represents the enenvironment (e.g. "live", "sandbox").
This function updates the Settings model.
func (*Settings) SetupLanguage ¶
Sets up the response messages language.
The `lang` parameter represents the language to be used.
This function updates the Settings model.
func (*Settings) SetupPlatformUser ¶
Sets up the API platform user.
The `hash` parameter represents the merchant user's email.
This function updates the Settings model.
func (*Settings) SetupSandbox ¶
Sets up defaults to Sandbox credentials.
This function updates the Settings model.