Skip to content

MercadoPago Connect

Ariel Rey edited this page Jul 31, 2018 · 4 revisions

Getting the credentials

The methods available for MercadoPago Connect are the following:

  • sendAuthorizationCode - Send a request to an specific URI with an authorization_code
mercadopago.connect.sendAuthorizationCode(client_id, redirect_uri, callback);

Example:

mercadopago.connect.sendAuthorizationCode('CLIENT_ID', 'http://www.mywebsite.com/mercadopago/webhook').then(function () {
  console.log('Everything went OK');
});

Now you are going to receive a call to that redirect_uri:

http://www.URL_de_retorno.com?code=AUTHORIZATION_CODE
  • getCredentials - Get your personal credentials from MercadoPago API
mercadopago.connect.getCredentials(access_token, authorization_code, redirect_uri, callback);

Example:

mercadopago.connect.getCredentials('ACCESS_TOKEN','AUTHORIZATION_CODE', 'http://www.mywebsite.com/mercadopago/webhook').then(function (response) {
  console.log(response);
});

The output will be this:

{
    "access_token": "USER_AT",
    "public_key": "USER_PK",
    "refresh_token": "USER_RT",
    "live_mode": false,
    "user_id": 123456789,
    "token_type": "bearer",
    "expires_in": 15768000,
    "scope": "offline_access read write"
}

Using the credentials

Now that you have the merchant credentials, you can use them to generate any kind of operation in his name. When you want to use it, you just need to use the access_token configuration to override it. If you wan't to know how, click here.

Clone this wiki locally