Search code examples
javascriptpaypalbraintree

Braintree PayPal checkout component throwing "e.client.getVersion is not a function"


I'm struggling to understand what I'm doing wrong here:

 braintree.client.create({
     authorization: res.clientToken // this is the token, I know it is correct
 }, (err, client) => {
    if (err) { ... }
    braintree.paypalCheckout.create({ client }, (err, paypalInstance) => {
        if (...) { ... }
    })
 });

When calling braintree.paypalCheckout.create, an error is called synchronously:

Uncaught TypeError: e.client.getVersion is not a function

Indeed, the client object doesn't have such a method. I followed the code from this page and this page (pretty much the same thing).

How to fix the problem? The PayPal Checkout component is loaded and appended to the braintree object.


Solution

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

    getVersion is a method of the client class as of version 3.16.0 of braintree-web. Update the version of braintree-web you're using to 3.16.0+.