3 回答

TA貢獻1851條經(jīng)驗 獲得超5個贊
對于這種情況,Meteor現(xiàn)在具有Meteor.wrapAsync()。
這是通過Stripe收費并傳遞回調(diào)函數(shù)的最簡單方法:
var stripe = StripeAPI("key");
Meteor.methods({
yourMethod: function(callArg) {
var charge = Meteor.wrapAsync(stripe.charges.create, stripe.charges);
charge({
amount: amount,
currency: "usd",
//I passed the stripe token in callArg
card: callArg.stripeToken,
}, function(err, charge) {
if (err && err.type === 'StripeCardError') {
// The card has been declined
throw new Meteor.Error("stripe-charge-error", err.message);
}
//Insert your 'on success' code here
});
}
});
添加回答
舉報