Braintree PayPal 结帐组件抛出 "e.client.getVersion is not a function"
Braintree PayPal checkout component throwing "e.client.getVersion is not a function"
我很难理解我在这里做错了什么:
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 (...) { ... }
})
});
调用braintree.paypalCheckout.create
时,同步调用出错:
Uncaught TypeError: e.client.getVersion
is not a function
的确,client
对象没有这样的方法。我遵循了 this page and this page 中的代码(几乎相同)。
如何解决这个问题? PayPal Checkout 组件已加载并附加到 braintree
对象。
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.
getVersion
is a method of the client
class as of version 3.16.0 of braintree-web
. Update the version of braintree-web
您正在使用 3.16.0+。
我在尝试将 vaultManager
与 dropIn
结合使用时 运行 加入了此内容。
现在我 实际上 不打算继续这样做 - 我只是在玩。看起来我将不得不完全自定义 - 因此我想开始玩 vaultManager
.
反正我有这个:
braintree.dropin.create({....}, (err, instance) => {
braintree.vaultManager.create({ client: instance }, (e, vmInstance) =>
{
vmInstance.fetchPaymentMethods((err, paymentMethods) => {
alert(JSON.stringify(paymentMethods));
});
});
});
原来 instance
不是 Client
对象。它是一个 Dropin
对象 ;-) 它创建自己的客户端存储在 _client
private 属性.
我需要做 braintree.client.create(...)
来获得真正的 Client
对象。
我实际上作弊并这样做了 - 只是暂时:
braintree.vaultManager.create({ client: instance._client },
正如我所说,我不建议同时使用 DropIn 和 Vault,这有点违背了两者的意义。
我很难理解我在这里做错了什么:
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 (...) { ... }
})
});
调用braintree.paypalCheckout.create
时,同步调用出错:
Uncaught TypeError:
e.client.getVersion
is not a function
的确,client
对象没有这样的方法。我遵循了 this page and this page 中的代码(几乎相同)。
如何解决这个问题? PayPal Checkout 组件已加载并附加到 braintree
对象。
完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.
getVersion
is a method of the client
class as of version 3.16.0 of braintree-web
. Update the version of braintree-web
您正在使用 3.16.0+。
我在尝试将 vaultManager
与 dropIn
结合使用时 运行 加入了此内容。
现在我 实际上 不打算继续这样做 - 我只是在玩。看起来我将不得不完全自定义 - 因此我想开始玩 vaultManager
.
反正我有这个:
braintree.dropin.create({....}, (err, instance) => {
braintree.vaultManager.create({ client: instance }, (e, vmInstance) =>
{
vmInstance.fetchPaymentMethods((err, paymentMethods) => {
alert(JSON.stringify(paymentMethods));
});
});
});
原来 instance
不是 Client
对象。它是一个 Dropin
对象 ;-) 它创建自己的客户端存储在 _client
private 属性.
我需要做 braintree.client.create(...)
来获得真正的 Client
对象。
我实际上作弊并这样做了 - 只是暂时:
braintree.vaultManager.create({ client: instance._client },
正如我所说,我不建议同时使用 DropIn 和 Vault,这有点违背了两者的意义。