Created
October 16, 2015 18:42
-
-
Save michaltakac/4d38299d71311d1500a3 to your computer and use it in GitHub Desktop.
Braintree demo - billing.js (v1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define gateway variable | |
var gateway; | |
Meteor.startup(function () { | |
var env; | |
// Pick Braintree environment based on environment defined in Meteor settings. | |
if (Meteor.settings.public.env === 'Production') { | |
env = Braintree.Environment.Production; | |
} else { | |
env = Braintree.Environment.Sandbox; | |
} | |
// Initialize Braintree connection: | |
gateway = BrainTreeConnect({ | |
environment: env, | |
publicKey: Meteor.settings.public.BT_PUBLIC_KEY, | |
privateKey: Meteor.settings.private.BT_PRIVATE_KEY, | |
merchantId: Meteor.settings.public.BT_MERCHANT_ID | |
}); | |
}); | |
Meteor.methods({ | |
getClientToken: function (clientId) { | |
var generateToken = Meteor.wrapAsync(gateway.clientToken.generate, gateway.clientToken); | |
var options = {}; | |
if (clientId) { | |
options.clientId = clientId; | |
} | |
var response = generateToken(options); | |
return response.clientToken; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment