Skip to content

Configure

Ariel Rey edited this page Jan 19, 2017 · 2 revisions

configure Method

To configure the SDK you must use the cofigure method. this method receives a JSON object. The valid configurations are:

  • client_id - String
  • client_secret - String
  • access_token - String
  • sandbox (defaults = false) - Boolean
  • show_promise_error (defaults = true) - Boolean

Valid credential configurations:

mercadopago.configure({
    access_token: 'ACCESS_TOKEN'
});
mercadopago.configure({
    sandbox: true,
    access_token: 'ACCESS_TOKEN'
});
mercadopago.configure({
    client_id: 'CLIENT_ID',
    client_secret: 'CLIENT_SECRET'
});

Invalid credential configurations:

mercadopago.configure({});

You must provide an Object with the configurations

mercadopago.configure({
    sandbox: true
});

You must provide a method of authentication (client_id & client_secret or access_token)

mercadopago.configure({
    client_id: 'CLIENT_ID'
});

You must provide client_id and client_secret

mercadopago.configure({
    client_secret: 'CLIENT_SECRET'
});

Cant change client_id or client_secret because is already set

Show Promise Error (defaults = true)

We support Promises. That means that all the methods are wrap into a new Promise. This means that if you don't provide a catch a warning is going to be output on the console (UnhandledPromiseRejectionWarning).

If you are going to use callbacks configure show_promise_error to false

Errors

If you provide an invalid configuration the applications is going to throw an Error (is going to block the application).