Skip to content

Instantly share code, notes, and snippets.

@michaltakac
Created October 17, 2015 00:09
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/51ad92d44f27320f7c9a to your computer and use it in GitHub Desktop.
Save michaltakac/51ad92d44f27320f7c9a to your computer and use it in GitHub Desktop.
Braintree demo - dashboard.js (v3)
Template.dashboard.onCreated(function() {
var instance = this;
instance.autorun(function() {
instance.subscribe('items');
});
});
Template.dashboard.onRendered(function() {
Meteor.call('getClientToken', function(error, clientToken) {
if (error) {
console.log(error);
} else {
braintree.setup(clientToken, "dropin", {
container: "payment-form", // Injecting into <div id="payment-form"></div>
onPaymentMethodReceived: function (response) {
// When we submit the payment form,
// we'll receive a response that includes
// payment method nonce:
var nonce = response.nonce;
// Check the nonce printed in console after submitting the form.
console.log(nonce);
}
});
}
});
});
Template.dashboard.helpers({
items: function(){
return Items.find();
},
showForm: function() {
var userId = Meteor.userId();
return Roles.userIsInRole(userId, 'paid') ? false : true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment