-
Notifications
You must be signed in to change notification settings - Fork 2
/
mercadopago.js
22 lines (21 loc) · 1009 Bytes
/
mercadopago.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
MercadoPago = undefined;
var _MP = Npm.require('mercadopago');
var settings = Meteor.settings && Meteor.settings.mercadopago;
var simpleCheckout = settings && settings.clientId && settings.clientSecret;
var customCheckout = settings && settings.accessToken;
if (simpleCheckout || customCheckout) {
// Intanciate MP
var instance = simpleCheckout ? new _MP(settings.clientId, settings.clientSecret) : new _MP(settings.accessToken);
instance.sandboxMode(settings.sandbox);
var methods = ['getAccessToken', 'getPreference', 'createPreference', 'updatePreference', 'searchPayment', 'getPayment', 'cancelPayment', 'refundPayment', 'post', 'get', 'put', 'delete'];
MercadoPago = {
_MP: _MP,
mp: instance,
};
methods.forEach(function(method) {
MercadoPago[method] = Async.wrap(instance, method);
MercadoPago['_' + method] = instance.method;
});
} else {
console.error('Mercadopago credentials not found on settings file. Be sure to start Meteor with --settings [filename.json]');
}