Skip to content

danteay/mercadopago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MercadoPago GO

Basic library for mercadopago

Install

go get https://github.com/danteay/mercadopago

Usage

Importing

import mp "github.com/danteay/mercadopago"

Configuring

ClientId and ClientSecret

clientId := "12345678987"
clientSecret := "iugbkjSfFewASndfvñjn1234"

client := new(mp.MpClient)
client.Init(clientId, clientSecret)

AccessToken

accessToken := "APP_PP_iugbkjSfFewASndfvñjn1234nlkefa__T_TT__adfhbrjnkfkl"

client := new(mp.MpClient)
client.Init(accessToken)

Create order

paymentData := mp.RequestData{
  "payer": mp.RequestData{
    "type":       "customer",
    "email":      "[email protected]",
    "first_name": "Dante Aligeri",
    "last_name":  "",
  },
  "transaction_amount": 20,
  "description":        "Service expres - Service regular",
  "payment_method_id":  "oxxo",
}

response, err := client.CreatePayment(paymentData)

fmt.Println(err)
fmt.Println(string(response))