0

我想让用户删除他保存的支付卡我正在使用这个包

"react-native-braintree-payments-drop-in": "^1.2.0"`

代码:

BraintreeDropIn.show({
  clientToken: this.state.clientToken,
  // I also add this but it is not showing me edit option in dropin
  vaultManager: true 
}).then(result => { ...

有什么我想念的吗?

4

1 回答 1

0

您必须创建一个“braintree 客户”,然后将 Braintree.customer.id 存储到您的用户对象中。

然后,如果您有一个 Braintree 客户 ID,您可以像我一样生成一个自定义客户令牌。在您的后端调用它以生成一个,然后在您的 Drop-in show({clientToken}) 选项字段中使用它

if(!req.user.brainTreeCustomerId){
    gateway.customer.create({
        firstName: req.user.name.first,
        lastName: req.user.name.last,
        email: req.user.email
    }, function (err, result) {
        if(err) return error(res, 500, "Something went wrong while creating customer payment profile");

        if(result.success){
            req.user.brainTreeCustomerId = result.customer.id;
            req.user.save();
        }
    });
}

return gateway.clientToken.generate({
    customerId: req.user.brainTreeCustomerId
})
    .then(response => {
        console.log(response);
        return result(res, 200, response.clientToken);
    }).catch(error(res));
于 2020-07-27T12:40:37.623 回答