Whenever the user gets the payment declined, no matter what the reason, I need to refresh the authorization token in order to request again to Braintree, otherwise I receive the error:
Cannot use a payment_method_nonce more than once
var token = 'MY_INITIAL_TOKEN';
braintree.dropin.create(
{
authorization: token,
container: '#braintree-container',
paypal:
{
flow: 'vault',
}
}, function(err, instance)
{
instance.requestPaymentMethod(function(err, payload)
{
// Executes HTTP Request
});
});
After the http request is being done and the payment has been declined I need to refresh the token.
The DropIn documentation has a function called updateConfiguration https://braintree.github.io/braintree-web-drop-in/docs/current/Dropin.html#updateConfiguration but I can't seem to get it to work, I have tried without success:
braintree.updateConfiguration('dropin', 'authorization', myNewToken);
braintree.dropin.updateConfiguration('authorization', myNewToken);
dropin.updateConfiguration('authorization', myNewToken);
braintree.dropin.authorization = myNewToken;