[英]Braintree payment with nodejs not working
我有以下html:
<form id="payment-form" method="post" submit="/checkout">
<input type="submit" value="Pay $10">
<input type="hidden" name="payment_method_nonce" value="0fgg1679-75e2-43e0-bc1f-94faee177877">
<iframe src="https://assets.braintreegateway.com/dropin/2.28.0/inline-frame.html#3a713953-3106-4fd5-8714-b0ada1723284" frameborder="0" allowtransparency="true" scrolling="no" name="braintree-dropin-frame" width="100%" height="68" id="braintree-dropin-frame" style="transition: height 210ms cubic-bezier(0.39, 0.575, 0.565, 1); border: 0px; z-index: 9999; height: 70px;"></iframe>
</form>
html最初只是input type=submit
和payment-form
但我的javascript具有以下代码,可将元素转换为上面所示的内容:
braintree.setup(BT_CLIENT_TOKEN, "dropin", {
container: "payment-form"
});
BT_CLIENT_TOKEN已在服务器端成功实例化到客户端。 当我打开网站时,我可以登录到沙箱并看到以下内容:
但是,当我单击“ pay”时,该表单不是通过nodejs服务器端的app.post("/checkout")
提交的,而是通过默认路由app.post("/")
。 另外,请求的主体始终为空req.body: {}
(而且据我所知,至少应该与nounce一起出现)。
有谁知道发生了什么吗? 非常感谢你。
全面披露:我在Braintree工作。 如果您还有其他疑问,请随时与支持小组联系。
我有几点建议。 首先,请确保在<form>
定义一个action
属性。
<form id="payment-form" method="post" action="/checkout">
其次,Braintree Drop-in 需要一个容器元素嵌套在 <form>
。 应该在braintree.setup()
定位此容器元素。
的HTML
<form id="payment-form" method="post" action="/checkout">
<div id="dropin-container"></div>
</form>
的JavaScript
braintree.setup('BT_CLIENT_TOKEN', 'dropin', {
container: 'dropin-container'
});
关于req.body: {}
,如果不更全面地查看您的代码很难深入研究,而我更希望避免在没有上下文的情况下进行猜测。 如果以上建议不能解决问题,则也许您可以编辑问题并提供更多代码段,以帮助社区更加仔细地研究此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.