[英]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: 调用
braintree.paypalCheckout.create
,将同步调用一个错误:
Uncaught TypeError:
e.client.getVersion
is not a function未捕获的TypeError:
e.client.getVersion
不是一个函数
Indeed, the client
object doesn't have such a method. 的确,
client
对象没有这种方法。 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. PayPal Checkout组件已加载并附加到
braintree
对象。
Full disclosure: I work at Braintree. 全面披露:我在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
. getVersion
是从braintree-web
的braintree-web
版本开始的client
类的方法。 Update the version of braintree-web
you're using to 3.16.0+. 将您正在使用的
braintree-web
的版本更新为3.16.0+。
I ran into this when trying to use vaultManager
in conjunction with dropIn
. 当尝试将
vaultManager
与dropIn
结合使用时,我遇到了这个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
. 看来我将必须完全自定义-因此为什么要开始使用
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. 原来
instance
不是Client
对象。 It is a Dropin
object ;-) It creates its own client stored on _client
private property. 它是一个
Dropin
对象;-)它创建自己的客户端,该客户端存储在_client
私有属性中。
I needed instead to do braintree.client.create(...)
to get a true Client
object. 我需要做
braintree.client.create(...)
来获得真正的Client
对象。
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. 就像我说过的,我不建议同时使用DropIn和Vault,这有点违反了两者的观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.