Socket
Socket
Sign inDemoInstall

mercadopago-ideame

Package Overview
Dependencies
1
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mercadopago-ideame

Mercadopago SDK module for Payments integration


Version published
Weekly downloads
2
decreased by-60%
Maintainers
2
Install size
3.71 MB
Created
Weekly downloads
 

Readme

Source

MercadoPago SDK module for Payments integration

  • Usage
  • Using MercadoPago Checkout
  • Using MercadoPago Payment collection

Usage:

$ npm install mercadopago
var MP = require ("mercadopago");

var mp = new MP ("CLIENT_ID", "CLIENT_SECRET");

Get your Access Token:

mp.getAccessToken(function (err, accessToken){
    console.log (accessToken);
});

Using MercadoPago Checkout

Create a Checkout preference:

var preference = {
        "items": [
            {
                "title": "Test",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 10.5
            }
        ]
    };

mp.createPreference (preference, function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

Others items to use

Get an existent Checkout preference:

mp.getPreference ("PREFERENCE_ID", function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

Update an existent Checkout preference:

var preference = {
        "items": [
            {
                "title": "Test Modified",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 20.4
            }
        ]
    };

mp.updatePreference ("PREFERENCE_ID", preference, function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

Using MercadoPago Payment

Searching:

var filters = {
        "id": null,
        "site_id": null,
        "external_reference": null
    };

mp.searchPayment (filters, function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

More search examples

Receiving IPN notification:

var MP = require ("mercadopago"),
	http = require("http"),
	url = require('url');

var mp = new MP ("CLIENT_ID", "CLIENT_SECRET");

function onRequest(request, response) {
	var qs = url.parse (request.url, true).query;

	mp.getPaymentInfo (qs["id"], function (err, data){
        if (err) {
            console.log (err);
            response.writeHead(200, {
                'Content-Type' : 'application/json; charset=utf-8'
            });
            response.write (err);
            response.end();
        } else {
            console.log (JSON.stringify (data, null, 4));
            response.writeHead(200, {
                'Content-Type' : 'application/json; charset=utf-8'
            });
            response.write (JSON.stringify (data));
            response.end();
        }
    });
}

http.createServer(onRequest).listen(8888);

Cancel (only for pending payments):

mp.cancelPayment ("ID", function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

Refund (only for accredited payments):

mp.refundPayment ("ID", function (err, data){
        if (err) {
            console.log (err);
        } else {
            console.log (JSON.stringify (data, null, 4));
        }
    });

<a href=http://developers.mercadopago.com/documentacion/devolucion-y-cancelacion> About Cancel & Refund

Keywords

FAQs

Last updated on 03 Jun 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc