Search code examples
braintree

What is the length of a Braintree payment method nonce string?


I'd like to know the length or range of lengths of the payment method nonce that Braintree gives in order to add a payment method. I've looked at their docs but I haven't been able to find an answer. You can read more about what a nonce is here.

Just to give some more context...

I have a REST api endpoint for adding payment methods to Braintree that expects the nonce in the request body. As part of that endpoint, I want to validate the nonce before I even try to use it, so if the length of the nonce string is bad then I can return an error.


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    It is not guaranteed that the character length of the nonce string will not change at some future date, so it is not recommended to use length as a means of validating a nonce.

    The server-side methods that consume a nonce have built-in validation that you can rely on to determine whether a particular nonce value is valid or invalid. Beyond checking whether it is a correctly-formatted value, they will also confirm that the nonce belongs to a particular gateway, among other things.