[英]Using Braintree Dropin UI "braintree is not defined"
I am attempting to follow the basics of Braintree integration and I am running into stumbling block after stumbling block seeing the flow in action.我正在尝试遵循 Braintree 集成的基础知识,并且在看到流程中的流程之后遇到了绊脚石。
Right now I am trying to take a look at the dropin UI for Braintree and using their code, copy and pasted I am running into现在我正在尝试查看 Braintree 的 dropin UI 并使用他们的代码,复制和粘贴我遇到了
"braintree is not defined"
“脑树没有定义”
when the braintree.dropin.create is executed.当 Braintree.dropin.create 被执行时。
<div id="dropin-container"></div>
<button id="submit-button">Purchase</button>
<script src="https://js.braintreegateway.com/web/dropin/1.14.1/js/dropin.min.js"></script>
<script>
var submitButton = document.querySelector('#submit-button');
braintree.dropin.create({
authorization: 'CLIENT_AUTHORIZATION',
container: '#dropin-container'
}, function (err, dropinInstance) {
if (err) {
// Handle any errors that might've occurred when creating Drop-in
console.error(err);
return;
}
submitButton.addEventListener('click', function () {
dropinInstance.requestPaymentMethod(function (err, payload) {
if (err) {
// Handle errors in requesting payment method
}
// Send payload.nonce to your server
});
});
});
</script>
Does anyone have any recommendations on how to get this dropin working?有没有人对如何让这个 dropin 工作有任何建议?
Edit: As far as development stack is concerned I am creating this in a Django environment and testing with both the JavaScript library and the Python library.编辑:就开发堆栈而言,我正在 Django 环境中创建它并使用 JavaScript 库和 Python 库进行测试。 This particular implementation I am attempting to use the javascript library.
这个特定的实现我正在尝试使用 javascript 库。
I solved my own issue by starting over and using this code:我通过重新开始并使用以下代码解决了我自己的问题:
https://developers.braintreepayments.com/start/hello-client/javascript/v3 https://developers.braintreepayments.com/start/hello-client/javascript/v3
<head>
<meta charset="utf-8">
<script src="https://js.braintreegateway.com/web/dropin/1.14.1/js/dropin.min.js"></script>
</head>
<body>
<div id="dropin-container"></div>
<button id="submit-button">Request payment method</button>
<script>
var button = document.querySelector('#submit-button');
braintree.dropin.create({
authorization: 'CLIENT_TOKEN_FROM_SERVER',
container: '#dropin-container'
}, function (createErr, instance) {
button.addEventListener('click', function () {
instance.requestPaymentMethod(function (err, payload) {
// Submit payload.nonce to your server
});
});
});
</script>
</body>
I then provided the CLIENT_TOKEN_FROM_SERVER via the Python Library.然后我通过 Python 库提供了 CLIENT_TOKEN_FROM_SERVER。 Works.
作品。
我有一个类似的问题,并移动了 dropin.create 的代码,以便在页面加载并且问题消失后发生
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.