Skip to content Skip to sidebar Skip to footer

Meteor.call Not Returning A Response

I'm trying to get Stripe working with the new promises support. Using checkout, I get the token and send it to the server: Meteor.call('submit_charge', res.id, fee, name, reg, func

Solution 1:

You have to use synchronous javascript:

submit_charge: function(tok, amt, name, reg) {
    varStripe = StripeAPI('privatekey');
    console.log('Submitting charge for ' + name);

    var createCharge = Meteor._wrapAsync(Stripe.charges.create.bind(Stripe.charges));

    try {
        var result = createCharge({
            amount: amt,
            currency: "usd",
            card: tok,
            description: "Payment - " + name,
            metadata: {
            'reg': reg
        });

        return result;
    }
    catch(e) {
        //Errorconsole.log(e);
    }
}

Basically you're trying to return data from within a callback. You need to return data to your meteor method and not the function in the then.

Using Meteor._wrapAsync uses Fibers to wait until the transaction is complete then returns the value or throws an error (hence the try/catch) to get the error.

Post a Comment for "Meteor.call Not Returning A Response"