流星:异步回调问题

Meteor: Async Callback issues

目前我让用户单击提交,然后在创建令牌并调用方法时发生单击事件。我想要做的是在收费后收到一个回调,说明是否成功。如果成功它将运行 router.go 到确认页面。如果不成功,它会让用户知道该卡已被拒绝。以上所有我都可以编码出来,尽管不停地修补,但我似乎无法弄清楚如何将消息传递回事件。

这是我的服务器端方法:

  Meteor.methods({
    'chargeCard': function(token,amount,email) {
      var Stripe = StripeAPI('where the key info guys');
      // get a sync version of our API async func
      var stripeCustomersCreateSync=Meteor.wrapAsync(Stripe.customers.create,Stripe.customers);
      // call the sync version of our API func with the parameters from the method call
      var result=stripeCustomersCreateSync({
        description: 'Woot! A new customer!',
        card: token,
        email: email
      }, function(error,result) {
        if(error) {
          return error;
        }
        return 'Success';
      });
      return result;
    }
});

和我的客户端方法:

    Stripe.card.createToken({
      number: $('#cc-number').val(),
      cvc: $('#card-cvc').val(),
      exp_month: expM,
      exp_year: expY,
      name: $('#fn').val(),
      address_zip: $('#postCode').val()
    }, stripeResponseHandler);
  }
  function stripeResponseHandler(status, response) {
    var $form = $('form');

    if (response.error) {
      // Show the errors on the form
      $form.find('.validation').text(response.error.message);
      return false;
    } else {
      var token = response.id;
      var amount = 15000;
      var Payid = $('#pid').text();
      var userEmail = Leaguemembers.findOne({_id: Payid}).Email;
      Meteor.call('chargeCard', token, amount,userEmail, function (error, result) {
        console.log(error,result); alert(result); alert(error);
        }
      );
    }
  };

如有任何帮助,我们将不胜感激。

编辑:

我回到后端,我可以看到通过 console.log 生成的错误,但仍然无法将其传递回调用的位置以向用户显示这些错误或将它们传递给确认页面。我似乎得到的只是未定义的。

meteor.call 应该是这样的

Meteor.call('chargeCard',token,amount,username,function(err,result){
    if(!err){
       Router.go("theRoute") //if there is not error go to the route
     }else{
       console.log(err.reason) // show the error
    }
  })