0
内この流星サーバーのコードを実行する必要がありますが(ほとんどが他からコピー&ペースト)は、このエラーを与える:patrickmlと流星:ブレインツリーコードは常にファイバー
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
それはブレーントリーサンドボックスの罰金に支払いを送信しますが、Iサーバーコードの一番下が見えるようになると、サーバー上で作業を行う必要があります。どうすれば修正できますか?
私は'createTransaction: Meteor.wrapAsync(function (nonceFromTheClient, Payment) {...});)
を試しましたが、無駄です。
//client.account.js
Template.account.onRendered(function() { //6a
Meteor.call('getClientToken', function (error, clientToken) {
if (error) {
console.log(error);
} else {
braintree.setup(clientToken, "dropin", {
container: "payment-form",
onPaymentMethodReceived: function (response) {
var nonce = response.nonce;
Meteor.call('btCreateCustomer', function (error) {
if (error) {
throw new Meteor.Error('customer-creation-failed');
} else {
let e = document.getElementById("invoice");
let label = e.options[e.selectedIndex].text;
let Payment = {
amount: /\$(.*?) /g.exec(label)[1],
period: /(.*? .*?) /g.exec(label)[1]
};
Meteor.call('createTransaction', nonce, Payment, function (error) {
if (!error) {
//do stuff.
}
});
}
});
}
});
}
});
});
//server.main.js
Meteor.methods({
'getClientToken': function (clientId) {
let generateToken = Meteor.wrapAsync(gateway.clientToken.generate, gateway.clientToken);
let options = {};
if (clientId) {
options.clientId = clientId;
}
let response = generateToken(options);
return response.clientToken;
},
'btCreateCustomer': function() {
let user = Meteor.user();
let customerData = {
email: user.emails[0].address
};
gateway.customer.create(customerData, function (error, response) {
if (!error) {
Meteor.users.update(user._id, {
$set: {
customerId: response.customer.id
}
});
}
});
},
'createTransaction': function (nonceFromTheClient, Payment) {
let user = Meteor.user();
gateway.transaction.sale({
amount: Payment.amount,
paymentMethodNonce: nonceFromTheClient, // Generated nonce passed from client
customer: {
id: user.customerId
},
options: {
submitForSettlement: true, // Payment is submitted for settlement immediately
storeInVaultOnSuccess: true // Store customer in Braintree's Vault
}
}, function (err) {
if (!err) {
// ------------- next line fail due to Fiber issue ------------------
console.log('Paid ' + Payment.amount + " for period " + Payment.period);
}
});
}
});
<template name="account">
<div id="account">
<form role="form">
<div class="row">
<div class="col-md-6 col-xs-12">
<div id="payment-form"></div>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</template>
私は無駄のためにそれをやりました。それでも同じエラー。 –
あなたは 'Meteor.wrapAsync'を試してみましたが、これは同じではありません。 –
私はあなたのソリューションを試しましたが、うまくいかない、つまり同じエラーが発生しました。 –