I worked with Meteor and the strip package to try and make a client. So, first I have client-side code that calls a method on the server, so when I click on it I have client.js:
Meteor.call('usersignup', function (error, result) {
console.log (result);
});
So this calls the method on server.js:
var Future = Npm.require('fibers/future');
var stripe = StripeAPI('my key');
Meteor.methods({
usersignup: function(cusEmail){
var fut = new Future();
stripe.customers.create(
{ email: cusEmail },
function(err, customer) {
if (err) {
console.log(err);
fut.ret;
}
fut.ret(customer);
}
);
return fut.wait();
},
userfail: function(cusid){
var fut = new Future();
stripe.customers.retrieve(cusid, function(err, result) {
if(err){
console.log(err);
fut.ret;
}
fut.ret(err, result);
});
return fut.wait();
}
});
Now it works and creates the client when I enter the stripe.com toolbar, but I try to get the response returned to the client, at least the client ID, and print it in the console. Here I can not make it work. It will write undefined when I do console.log (result). Any ideas?
EDIT: , , , , . :
'click #signupsubmit': function (event) {
console.log("hello");
var whatis = getVal();
var testid;
var cusid = Meteor.call('usersignup', whatis.email, function (error, result) {
if (error) {
console.log(err.message);
return;
}
console.log(result);
console.log("meteor call");
testid = result;
return (result);
});
console.log("outside call");
console.log(testid);
console.log(cusid);
},
});
, console.log, , meteor.call . Console.log testid cusid undefined, console.log "meteor call" meteor.call. , ? :
- ""
- " "
- test id undefined
- cusid undefined
- " "
- ""