【发布时间】:2015-03-02 09:36:36
【问题描述】:
我在我的应用程序中使用条带付款,我想在成功交易后在我自己的数据库中创建一个收据文档
我的代码:
Meteor.methods({
makePurchase: function(tabId, token) {
check(tabId, String);
tab = Tabs.findOne(tabId);
Stripe.charges.create({
amount: tab.price,
currency: "USD",
card: token.id
}, function (error, result) {
console.log(result);
if (error) {
console.log('makePurchaseError: ' + error);
return error;
}
Purchases.insert({
sellerId: tab.userId,
tabId: tab._id,
price: tab.price
}, function(error, result) {
if (error) {
console.log('InsertionError: ' + error);
return error;
}
});
});
}
});
但是这段代码返回错误:
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
我不熟悉 Fibers,知道为什么会这样吗?
【问题讨论】:
标签: meteor