Migrating Braintree 2 to Braintree 3

两盒软妹~` 提交于 2021-01-29 09:22:49

问题


Braintree 2 is working well. I am trying to migrate from Braintree 2 to braintree 3. And I think it's issue is I am trying to submit payment and it's going to failed payment.

    <form class="Info" method="post">
       <div id="dropin-container"></div>
        // submit payment
       <input class="form_submit" type="submit" value="BOOK">
    </form>

jQuery(document).ready(function () {  xyz.braintree.init({braintreeToken:"Token_value",container:"#dropin-container", form:jQuery("form_submit"); });

Braintree 2 code

 xyz.braintree.form = config.form;
            braintree.setup(config.braintreeToken, 'dropin', {
                container: config.container,
                onPaymentMethodReceived: function(paymentRecievedObj) {
                    nret.braintree.paymentMethodReceived(paymentRecievedObj);
                }
            });
        },
        paymentMethodReceived: function(payload) {
            //post form
  xyz.braintree.form.append('<input type="hidden" value="' + payload.nonce + '" name="Nonce">').submit();
        }

Braintree 3 code

    xyz.braintree.form = config.form;
    var form = config.form;
    var button = document.querySelector('.form_submit');

    braintree.dropin.create({
        authorization: 'sandbox_aadjajdaksjda',
        container: config.container
    }, function (createErr, instance) {
     button.addEventListener('click', function () {
        instance.requestPaymentMethod(function (err, payload) {
        if (err) {
          console.log('Error', err);
          return;
        }
        // Add the nonce to the form and submit
        document.querySelector('input[name="Nonce"]').value = payload.nonce;
        });
    });
 });

来源:https://stackoverflow.com/questions/65727493/migrating-braintree-2-to-braintree-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!