-
Notifications
You must be signed in to change notification settings - Fork 8
/
braintree.js
27 lines (23 loc) · 974 Bytes
/
braintree.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Braintree = Npm.require('braintree');
BrainTreeConnect = function (key) {
var BraintreeObj;
var resources = {
address : ['create', 'delete', 'find', 'update'],
clientToken : ['generate'],
customer : ['create', 'delete', 'find', 'search', 'update'],
merchantAccount : ['create', 'find', 'update'],
paymentMethod : ['create', 'delete', 'find', 'update'],
paymentMethodNonce : ['create', 'find'],
plan : ['all'],
subscription : ['cancel', 'create', 'find', 'search', 'update'],
transaction : ['cancelRelease', 'cloneTransaction', 'find', 'holdInEscrow', 'refund', 'releaseFromEscrow', 'sale', 'search', 'submitForSettlement', 'void']
};
BraintreeObj = Braintree.connect(key);
_.each(resources, function (resource, key){
_.each(resource, function (funcName){
var func = BraintreeObj[key][funcName];
BraintreeObj[key][funcName] = Meteor.wrapAsync(func, BraintreeObj[key]);
});
});
return BraintreeObj;
};