Reputation: 113455
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.
Upvotes: 2
Views: 1095
Reputation: 146170
I ran into this when trying to use vaultManager
in conjunction with dropIn
.
Now I'm not actually planning on continuing with that - I'm just playing. Looks like I'm going to have to go fully custom - hence why I wanted to start playing with vaultManager
.
Anyway I had this :
braintree.dropin.create({....}, (err, instance) => {
braintree.vaultManager.create({ client: instance }, (e, vmInstance) =>
{
vmInstance.fetchPaymentMethods((err, paymentMethods) => {
alert(JSON.stringify(paymentMethods));
});
});
});
Turns out instance
is NOT a Client
object. It is a Dropin
object ;-) It creates its own client stored on _client
private property.
I needed instead to do braintree.client.create(...)
to get a true Client
object.
I actually cheated and did this - just for the time being:
braintree.vaultManager.create({ client: instance._client },
Like I said I don't recommend using both DropIn and Vault together, it kind of defeats the point of both.
Upvotes: 2
Reputation: 896
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+.
Upvotes: 3