问题
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