There seem to be something like this but in the opposite. This is closest but I'm not storing anything.
I am only using stripe for a charge in my other post/answer:
Client:
I am grabbing the value, with jQuery, from an input field:
<input type="text" id="amount" name="amount"/>
var amount = $("#amount").val() *100; // the js client
Server:
To charge the card, you would have something like:
amount: 7000, // I want to remove the static value
I need something like this:
amount: amount
I am still learning js and I thought jquery would work but I guess not. I've tried passing amount
into the isServer
function but that does not work. Any alternatives?
I have also tried to use var amount = document.getElementById('#amount');
But document
is not defined.
Edit:
if (Meteor.isServer) {
Meteor.methods({
'chargeCard': function(stripeToken, amount) {
check(stripeToken, Object);
var stripe = Meteor.npmRequire('stripe')('sk_test_rand');
stripe.customers.create({
email: 'a@aol.com'
}).then(function() {
return stripe.charges.create({
amount: amount,
currency: 'gbp',
source: stripeToken.id
});
}).then(function(err, charge) {
// New charge created on a new customer
console.log(err, charge);
}, function(err) {
// Deal with an error
console.log('Card not charge')
});
}
});
}