此命令meteor add patrickml:braintree
在Meteor app目录中运行。
在client.main.js中:
波浪线在变量braintree
下,IDE表示“未解析的变量或类型”。
Template.payment.onRendered(function () {
Meteor.call('getClientToken', function (error, clientToken) {
if (error) {
console.log(error); //<---- always prints out
} else {
//vvvvvvvvv
braintree.setup(clientToken, "dropin", {
container: "payment-form", // Injecting into <div id="payment-form"></div>
onPaymentMethodReceived: function (response) {
var nonce = response.nonce;
console.log(nonce);
}
});
}
});
});
在下面的服务器代码中,clientId始终未定义。
//server/main.js
'getClientToken': function (clientId) {
console.log(clientId); //<--------- undefined
let generateToken = Meteor.wrapAsync(gateway.clientToken.generate, gateway.clientToken);
let options = {};
if (clientId) {
options.clientId = clientId;
}
let response = generateToken(options);
return response.clientToken;
}
服务器控制台打印出来:
调用方法'getClientToken'时出现异常authenticationError:身份验证错误
知道什么是错的以及如何解决它? THX
答案 0 :(得分:0)
完全披露:我在Braintree工作。如果您有任何其他问题,请随时联系support。
配置网关对象时,请确保使用API credentials documented in your Sandbox Control Panel。以下是您可以找到它们的方法:
如果有,请使用它们配置网关对象。例如:
@if($instrument->reservations ->where('reserved_from','<=', $scheduler_start_time) ->where('reserved_to','>=', $scheduler_start_time)->first() != null