简体   繁体   English

将自定义字段用于Braintree的托管字段和插件

[英]Using custom fields for braintree's hosted fields & drop-in

I wanted to know if it is possible to use a custom form for braintree payment integration. 我想知道是否可以使用自定义表格进行Braintree付款集成。 By custom i mean something like this: 按照习惯,我的意思是这样的:

<form id="payment-form" method="post" action="/checkout.php">
  <div id="customField>{$customField;}</div>
  <div id="customField2>{$customField2;}</div>
  <input type="submit" value="PAY">
</form>

<script src="https://js.braintreegateway.com/js/braintree-2.31.0.min.js"></script>
<script>
var clientToken = "";
braintree.setup("clientToken", "dropin", {
  container: "payment-form"
});
</script>

I want to post my custom fields to checkout.php but it seems the form only returns payment method nonce. 我想将我的自定义字段发布到checkout.php,但该表单似乎仅返回付款方式现时。 I don't want to store any of these custom values in braintree's vault either. 我也不想在Braintree的库中存储任何这些自定义值。 Checkout.php just adds all values together (including received payment method nonce) from previous forms in an array and passes these values to .NET server. Checkout.php只是将数组中以前形式的所有值(包括收到的付款方式现时)相加在一起,然后将这些值传递给.NET服务器。 So is there a way to pass these values to checkout.php? 那么有没有办法将这些值传递给checkout.php?

It looks like this is certainly possible using Braintree's Custom Fields 看来使用Braintree的自定义字段确实可以实现

It looks like, though, you are not properly formatting your form to populate the Drop-In, per your Braintree.setup. 但是,看来您没有按照Braintree.setup正确格式化表格的格式来填充Drop-In。 The container you are specifying in the braintree.setup will correlate to a div element that will in turn be the drop in, not the ID of the complete payment form. 您指定的braintree.setup的容器将关联到一个div元素,这将又是在下降,而不是完整的付款形式的ID。

So, if you have a form that looks like; 因此,如果您的表单看起来像这样;

<form> <div id="dropin-container"></div> </form>

, you'd want your braintree.setup to look like; ,您希望您的braintree.setup看起来像;

braintree.setup('CLIENT-TOKEN-FROM-SERVER', 'dropin', {container: 'dropin-container'});

in order to convert the DIV "dropin-container" into the Drop In. 为了将DIV“ dropin-container”转换为Drop In。

Custom Fields, though, can be included in the form, but you'll want to make them simply HTML Input elements, as opposed to div elements, that will be returned to your server alongside the nonce. 尽管“自定义字段”可以包含在表单中,但是您希望将它们简化为HTML Input元素,而不是div元素,这些元素将随现时一起返回到服务器。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM