Created
October 17, 2015 00:09
-
-
Save michaltakac/51ad92d44f27320f7c9a to your computer and use it in GitHub Desktop.
Braintree demo - dashboard.js (v3)
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
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