Documentation ¶
Index ¶
- Constants
- type ID
- type Item
- type MP
- func (mp *MP) CreatePayment(payment *Payment) (*Payment, error)
- func (mp *MP) CreatePreference(preference *Preference) (*Preference, error)
- func (mp *MP) GetAccessToken() (string, error)
- func (mp *MP) GetPayment(id string) (*Payment, error)
- func (mp *MP) GetPaymentsByRef(externalReference string) (*PaymentSearch, error)
- func (mp *MP) GetPreference(id string) (*Preference, error)
- func (mp *MP) PaymentsSearch(filters *url.Values) (*PaymentSearch, error)
- type MPError
- type Payment
- type PaymentSearch
- type Preference
- type TokenResponse
Constants ¶
const ( MPVersion string = "0.1" MPUserAgent string = "MercadoPago Go SDK v" + MPVersion APIBaseURL string = "https://api.mercadopago.com" MIMEJSON string = "application/json" MIMEForm string = "application/x-www-form-urlencoded" )
General API configuration values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { ID string `json:"id,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` PictureURL string `json:"picture_url,omitempty"` CategoryID string `json:"category_id,omitempty"` Quantity int `json:"quantity,omitempty"` CurrencyID string `json:"currency_id,omitempty"` UnitPrice float32 `json:"unit_price,omitempty"` }
Item information
type MP ¶
type MP struct { CustomAccessToken string BasicAccessToken string ClientID string Sandbox bool Debug bool // contains filtered or unexported fields }
MP is the implementation to consume Mercado Pago API services
func NewMP ¶
func NewMP(clientID string, clientSecret string, customAccessToken string, sandbox bool, debug bool) MP
NewMP returns a new instance of the MP service library
func (*MP) CreatePreference ¶
func (mp *MP) CreatePreference(preference *Preference) (*Preference, error)
CreatePreference Creates a checkout preference
@param preference @return json
func (*MP) GetAccessToken ¶
GetAccessToken returns an Access Token obtained from MP API
func (*MP) GetPaymentsByRef ¶
func (mp *MP) GetPaymentsByRef(externalReference string) (*PaymentSearch, error)
GetPaymentsByRef Get a payment by External Reference
@param id @return json
func (*MP) GetPreference ¶
func (mp *MP) GetPreference(id string) (*Preference, error)
GetPreference Get a checkout preference
@param id @return json
func (*MP) PaymentsSearch ¶
func (mp *MP) PaymentsSearch(filters *url.Values) (*PaymentSearch, error)
PaymentsSearch Search for payments using a filter set
@param filters in url.Values object @return json
type MPError ¶
type MPError struct { Name string `json:"name"` Message string `json:"message"` Stack string `json:"stack"` Status int `json:"status"` }
MPError is the type returned by the lib in case of errors
type Payment ¶
type Payment struct { ID int `json:"id,omitempty"` DateCreated string `json:"date_created,omitempty"` DateApproved string `json:"date_approved,omitempty"` DateLastUpdated string `json:"date_last_updated,omitempty"` MoneyReleaseDate string `json:"money_release_date,omitempty"` CollectorID int `json:"collector_id,omitempty"` OperationType string `json:"operation_type,omitempty"` Payer struct { EntityType string `json:"entity_type,omitempty"` Type string `json:"type,omitempty"` // ID string `json:"id,omitempty"` // Issue on MP API - sometimes this is string, other is int :( Email string `json:"email,omitempty"` Identification struct { Type string `json:"type,omitempty"` Number string `json:"number,omitempty"` } `json:"identification,omitempty"` Phone struct { AreaCode string `json:"area_code,omitempty"` Number string `json:"number,omitempty"` Extension string `json:"extension,omitempty"` } `json:"phone,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` } `json:"payer,omitempty"` BinaryMode bool `json:"binary_mode,omitempty"` LiveMode bool `json:"live_mode,omitempty"` Order struct { Type string `json:"type,omitempty"` } `json:"order,omitempty"` ExternalReference string `json:"external_reference,omitempty"` Description string `json:"description,omitempty"` CurrencyID string `json:"currency_id,omitempty"` TransactionAmount float32 `json:"transaction_amount,omitempty"` TransactionAmountRefunded float32 `json:"transaction_amount_refunded,omitempty"` CouponAmount float32 `json:"coupon_amount,omitempty"` CampaignID int `json:"campaign_id,omitempty"` CouponCode string `json:"coupon_code,omitempty"` TransactionDetails struct { FinancialInstitution string `json:"financial_institution,omitempty"` NetReceivedAmount float32 `json:"net_received_amount,omitempty"` TotalPaidAmount float32 `json:"total_paid_amount,omitempty"` InstallmentAmount float32 `json:"installment_amount,omitempty"` OverpaidAmount float32 `json:"overpaid_amount,omitempty"` PaymentMethodReference string `json:"payment_method_reference,omitempty"` } `json:"transaction_details,omitempty"` FeeDetails []struct { Type string `json:"type,omitempty"` FeePayer string `json:"fee_payer,omitempty"` Amount float32 `json:"amount,omitempty"` } `json:"fee_details,omitempty"` DifferentialPricingID int `json:"differential_pricing_id,omitempty"` ApplicationFee float32 `json:"application_fee,omitempty"` Status string `json:"status,omitempty"` StatusDetail string `json:"status_detail,omitempty"` Capture bool `json:"capture,omitempty"` Captured bool `json:"captured,omitempty"` CallForAuthorizeID string `json:"call_for_authorize_id,omitempty"` PaymentMethodID string `json:"payment_method_id,omitempty"` // IssuerID string `json:"issuer_id,omitempty"` // Issue on MP API - sometimes this is string, other is int :( PaymentTypeID string `json:"payment_type_id,omitempty"` Token string `json:"token,omitempty"` Card struct { ID int `json:"id,omitempty"` LastFourDigits string `json:"last_four_digits,omitempty"` FirstSixDigits string `json:"first_six_digits,omitempty"` ExpirationYear int `json:"expiration_year,omitempty"` ExpirationMonth int `json:"expiration_month,omitempty"` DateCreated string `json:"date_created,omitempty"` DateLastUpdated string `json:"date_last_updated,omitempty"` Cardholder struct { Name string `json:"name,omitempty"` Identification struct { Type string `json:"type,omitempty"` Number string `json:"number,omitempty"` } `json:"identification,omitempty"` } `json:"cardholder,omitempty"` } `json:"card,omitempty"` StatementDescriptor string `json:"statement_descriptor,omitempty"` Installments int `json:"installments,omitempty"` NotificationURL string `json:"notification_url,omitempty"` CallbackURL string `json:"callback_url,omitempty"` Refunds []struct { ID int `json:"id,omitempty"` PaymentID int `json:"payment_id,omitempty"` Amount float32 `json:"amount,omitempty"` Source struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` } `json:"source,omitempty"` } `json:"refunds,omitempty"` AdditionalInfo struct { IPAddress string `json:"ip_address,omitempty"` Items []Item `json:"items,omitempty"` Payer struct { FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Phone struct { AreaCode string `json:"area_code,omitempty"` Number string `json:"number,omitempty"` } `json:"phone,omitempty"` Address struct { ZipCode string `json:"zip_code,omitempty"` StreetName string `json:"street_name,omitempty"` StreetNumber int `json:"street_number,omitempty"` } `json:"address,omitempty"` RegistrationDate string `json:"registration_date,omitempty"` } `json:"payer,omitempty"` Shipments struct { ReceiverAddress struct { ZipCode string `json:"zip_code,omitempty"` StreetName string `json:"street_name,omitempty"` StreetNumber int `json:"street_number,omitempty"` Floor string `json:"floor,omitempty"` Apartment string `json:"apartment,omitempty"` } `json:"receiver_address,omitempty"` } `json:"shipments,omitempty"` Barcode struct { Type string `json:"type,omitempty"` Content string `json:"content,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` } `json:"barcode,omitempty"` } `json:"additional_info,omitempty"` }
Payment is the data struct for payment MP API
type PaymentSearch ¶
type PaymentSearch struct { Paging struct { Total int `json:"total,omitempty"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` } `json:"paging,omitempty"` Results []Payment `json:"results,omitempty"` }
PaymentSearch is the data struct for payment MP API
type Preference ¶
type Preference struct { Items []Item `json:"items,omitempty"` Payer struct { Name string `json:"name,omitempty"` Surname string `json:"surname,omitempty"` Email string `json:"email,omitempty"` Phone struct { AreaCode string `json:"area_code,omitempty"` Number string `json:"number,omitempty"` } `json:"phone,omitempty"` Identification struct { Type string `json:"type,omitempty"` Number string `json:"number,omitempty"` } `json:"identification,omitempty"` Address struct { ZipCode string `json:"zip_code,omitempty"` Street string `json:"street,omitempty"` Number int `json:"number,omitempty"` } `json:"address,omitempty"` DateCreated string `json:"date_created,omitempty"` } `json:"payer,omitempty"` PaymentMethods struct { ExcludedPaymentMethods []ID `json:"excluded_payment_methods,omitempty"` ExcludedPaymentTypes []ID `json:"excluded_payment_types,omitempty"` DefaultPaymentMethodID string `json:"default_payment_method_id,omitempty"` Installments int `json:"installments,omitempty"` DefaultInstallments int `json:"default_installments,omitempty"` } `json:"payment_methods,omitempty"` Shipments struct { Mode string `json:"mode,omitempty"` LocalPickup bool `json:"local_pickup,omitempty"` Dimensions string `json:"dimensions,omitempty"` DefaultShippingMethod int `json:"default_shipping_method,omitempty"` FreeMethods []ID `json:"free_methods,omitempty"` Cost float32 `json:"cost,omitempty"` FreeShipping bool `json:"free_shipping,omitempty"` ReceiverAddress struct { ZipCode string `json:"zip_code,omitempty"` StreetName string `json:"street_name,omitempty"` StreetNumber int `json:"street_number,omitempty"` Floor string `json:"floor,omitempty"` Apartment string `json:"apartment,omitempty"` } `json:"receiver_address,omitempty"` } `json:"shipments,omitempty"` BackUrls struct { Success string `json:"success,omitempty"` Pending string `json:"pending,omitempty"` Failure string `json:"failure,omitempty"` } `json:"back_urls,omitempty"` NotificationURL string `json:"notification_url,omitempty"` ID string `json:"id,omitempty"` InitPoint string `json:"init_point,omitempty"` SandboxInitPoint string `json:"sandbox_init_point,omitempty"` DateCreated string `json:"date_created,omitempty"` OperationType string `json:"operation_type,omitempty"` AdditionalInfo string `json:"additional_info,omitempty"` AutoReturn string `json:"auto_return,omitempty"` ExternalReference string `json:"external_reference,omitempty"` Expires bool `json:"expires,omitempty"` ExpirationDateFrom string `json:"expiration_date_from,omitempty"` ExpirationDateTo string `json:"expiration_date_to,omitempty"` CollectorID int `json:"collector_id,omitempty"` ClientID string `json:"client_id,omitempty"` }
Preference is the data struct for payment checkouts
type TokenResponse ¶
type TokenResponse struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` LiveMode bool `json:"live_mode"` UserID int32 `json:"user_id"` TokenType string `json:"token_type"` ExpiresIn int32 `json:"expires_in"` Scope string `json:"scope"` }
TokenResponse is the structure of data obtained from the MP Auth Token service