Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabianmendez/mercadopago
Idiomatic go client for MercadoPago
https://github.com/fabianmendez/mercadopago
go golang mercadolibre mercadopago
Last synced: about 4 hours ago
JSON representation
Idiomatic go client for MercadoPago
- Host: GitHub
- URL: https://github.com/fabianmendez/mercadopago
- Owner: fabianMendez
- License: mit
- Created: 2021-01-01T23:39:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-01-04T17:22:54.000Z (over 3 years ago)
- Last Synced: 2024-06-21T11:17:28.290Z (3 months ago)
- Topics: go, golang, mercadolibre, mercadopago
- Language: Go
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mercadopago
Idiomatic go client for MercadoPago## :eyes: Example
Create a new payment using a test user
```golang
package mainimport (
"fmt"
"github.com/fabianMendez/mercadopago"
)func main() {
client := mercadopago.NewClient("https://api.mercadopago.com/v1", "TEST-PUBLIC-KEY", "TEST-ACCESS-TOKEN")buyer, err := client.NewTestUser(mercadopago.TestUserParams{SiteID: "MCO"})
if err != nil {
panic(err)
}identification := mercadopago.Identification{Type: "CC", Number: "19119119100"}
cardToken, err := client.NewCardToken(mercadopago.CardTokenParams{
ExpirationMonth: 11,
ExpirationYear: 2025,
Cardholder: mercadopago.Cardholder{Name: "APRO", Identification: identification},
SecurityCode: "123",
CardNumber: "4013540682746260",
})
if err != nil {
panic(err)
}payment, err := client.NewPayment(mercadopago.PaymentParams{
PaymentMethodID: "visa",
TransactionAmount: 1234.5,
Payer: mercadopago.Payer{
Email: buyer.Email,
Identification: identification,
},
Token: cardToken.ID,
Description: "Test Payment",
Installments: 1,
})
if err != nil {
panic(err)
}fmt.Println(payment.Status)
}```