Skip to content

Instantly share code, notes, and snippets.

@michaltakac
Created October 16, 2015 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaltakac/4d38299d71311d1500a3 to your computer and use it in GitHub Desktop.
Save michaltakac/4d38299d71311d1500a3 to your computer and use it in GitHub Desktop.
Braintree demo - billing.js (v1)
// 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