简体   繁体   English

Braintree dropin UI:在表单提交之前验证帐单地址自定义字段

[英]Braintree dropin UI : validate billing address custom fields before form submit

I have set up a drop-in UI in my checkout page but I want to validate customers' billing and shipping addresses as well drop-in UI card details before submitting the checkout form. 我在结帐页面设置了一个插入式用户界面,但我想在提交结帐表单之前验证客户的结算和送货地址以及插入的UI卡详细信息。

It automatically creates nonce from server and appends it into our form, but how can I validate the drop-in and address fields at the same time? 它会自动从服务器创建nonce并将其附加到我们的表单中,但是如何同时验证drop-in和address字段?

I work at Braintree on the JS SDK team. 我在JS SDK团队的Braintree工作。

Currently the Drop-In does not allow for fields beyond Credit Card, Expiration, CVV and Postal Code. 目前,Drop-In不允许超出信用卡,到期日,CVV和邮政编码的字段。 However, it is designed to work within the context of your checkout form. 但是,它旨在在结帐表单的上下文中工作。 If you would like to prevent Drop-In from auto-submitting the form so that you can run your own validation once a nonce has been generated, you can define a callback in your configuration and then manually re-submit the form when you are satisfied with your results. 如果您希望阻止Drop-In自动提交表单,以便您可以在生成随机数后运行自己的验证,则可以在配置中定义回调,然后在满意时手动重新提交表单与你的结果。

You will however have to remember to include the nonce in an input field with a name that your server is expecting. 但是,您必须记住将nonce包含在输入字段中,其中包含服务器所期望的名称。 The default is payment_method_nonce . 默认为payment_method_nonce

For example: 例如:

braintree.setup('CLIENT_TOKEN', 'dropin', {
  paymentMethodNonceReceived: function (event, nonce) {
    // Simulate your validation
    setTimeout(function () {
      var form = document.getElementsByTagName('form')[0];
      var input = document.createElement('input');

      input.name = 'payment_method_nonce';
      input.value = nonce;

      form.appendChild(input);

      form.submit();
    }, 500);

  }
});

More information around this can be found here: https://developers.braintreepayments.com/javascript+node/sdk/client/drop-in 有关这方面的更多信息,请访问: https//developers.braintreepayments.com/javascript+node/sdk/client/drop-in

I hope this helps. 我希望这有帮助。

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

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