This library is a wrap of nodejs mercadopago sdk for meteor.
$ meteor add ha:mercadopago
Get your clientID/ClientSecret
or accessToken
whether you use basic or custom checkout (See more in basic checkout and customized checkout). Add your credentials to your meteor config.
{
"mercadopago": {
"clientID": "yourClientID",
"clientSecret": "yourClientSecret"
}
}
Start meteor with the config file.
meteor --settings [settings.json]
If everything went fine you should have (server side) access to the variable MercadPago
.
All methods of MercadoPago
can be called in a synchronous or asynchronous way. All methods have a regular version (sync) and one starting with a lowdash (async). For example you have three ways of using the method createPreference
.
MercadoPago.createPreference(p)
MercadoPago._createPreference(p).then(
function (preference) {
console.log(preference);
},
function (error) {
console.log (error);
});
MercadoPago._createPreference(p, function (err, preference){
if (err) {
console.log (err);
} else {
console.log (preference);
}
});
You have access to the underlying node module and the current mercadopago instance in the following vars
MercadoPago._MP // Node module
Mercadopago.mp // Mercadopago node instance
You can checkout how to use the module in the official repo.
- Get your CLIENT_ID and CLIENT_SECRET in the following address:
- Argentina: https://www.mercadopago.com/mla/herramientas/aplicaciones
- Brazil: https://www.mercadopago.com/mlb/ferramentas/aplicacoes
- México: https://www.mercadopago.com/mlm/herramientas/aplicaciones
- Venezuela: https://www.mercadopago.com/mlv/herramientas/aplicaciones
- Colombia: https://www.mercadopago.com/mco/herramientas/aplicaciones
- Chile: https://www.mercadopago.com/mlc/herramientas/aplicaciones
- Add the credentials to your meteor config.
{
"mercadopago": {
"clientID": "yourClientID",
"clientSecret": "yourClientSecret"
}
}
MercadoPago.getPreference(preferenceID);
var preference = {
"items": [
{
"title": "Test",
"quantity": 1,
"currency_id": "USD",
"unit_price": 10.5
}
]
};
MercadoPago.createPreference(preference);
var preference = {
"items": [
{
"title": "Test Modified",
"quantity": 1,
"currency_id": "USD",
"unit_price": 20.4
}
]
};
MercadoPago.updatePreference(preferenceID, preference);
var filters = {
"id": null,
"site_id": null,
"external_reference": null
};
data = MercadoPago.searchPayment(filters);
console.log (JSON.stringify (data, null, 4);
data = MercadoPago.getPayment(paymentId);
console.log(JSON.stringify(data, null, 4));
MercadoPago.cancelPayment(paymentID);
MercadoPago.refundPayment(paymentID);
- Get your ACCESS_TOKEN in the following address:
- Argentina: https://www.mercadopago.com/mla/account/credentials
- Brazil: https://www.mercadopago.com/mlb/account/credentials
- Mexico: https://www.mercadopago.com/mlm/account/credentials
- Venezuela: https://www.mercadopago.com/mlv/account/credentials
- Colombia: https://www.mercadopago.com/mco/account/credentials
- Add the credentials to your meteor config.
{
"mercadopago": {
"accessToken": "yourAccessToken"
}
}
MercadoPago.post("/v1/payments", payment_data);
MercadoPago.post("/v1/customers", {"email": "[email protected]"});
MercadoPago.get("/v1/customers/CUSTOMER_ID");
- View more Custom checkout related APIs in Developers Site
- Argentina: https://www.mercadopago.com.ar/developers
- Brazil: https://www.mercadopago.com.br/developers
- Mexico: https://www.mercadopago.com.mx/developers
- Venezuela: https://www.mercadopago.com.ve/developers
- Colombia: https://www.mercadopago.com.co/developers
You can access any other resource from the MercadoPago API using the generic methods:
// Get a resource, with optional URL params. Also you can disable authentication for public APIs
MercadoPago.get("/resource/uri", [params], [authenticate=true]);
// Create a resource with "data" and optional URL params.
MercadoPago.post("/resource/uri", data, [params]);
// Update a resource with "data" and optional URL params.
MercadoPago.put("/resource/uri", data, [params]);
// Delete a resource with optional URL params.
MercadoPago.delete("/resource/uri", [params]);
For example, if you want to get the Sites list (no params and no authentication):
sites = MercadoPago.get("/sites", null, false);
console.log(sites);