Closed kylealwyn closed 6 years ago
Looks like the problem is that we're not actually verifying the keys being passed into create
before making the request: https://github.com/braintree/braintree_node/blob/90ebc69922a15a9d0c7d7fb94695a0a9ebcf6714/lib/braintree/customer_gateway.js#L17
We do this in the other sdks and should make the change here to use invalid key error. Thanks for reporting it.
This is fixed (finally) in version 2.11.0 https://github.com/braintree/braintree_node/blob/master/CHANGELOG.md#2110
Not a bug, just a small suggestion after integrating.
I had this code after some copy-pasta while moving over from Stripe:
It's misleading to throw an
AuthorizationError
when sending invalid fields in a gateway call. Something along the lines ofMalformedPayload
orBadRequest
seems like it would be more helpful. It would then mimic more closely http statuses 401 Unauthorized and 400 Bad Request or 422 UnprocessableEntity. The misnamed (or extra in my case) fields seem to have nothing to do with Authorization, which led me down the rabbit hole of thinking my keys were wrong.I understand now it's in the documentation but still believe to be a misnomer. Thanks!