简体   繁体   中英

Braintree VaultManager using react-native-braintree-dropin-ui

I want to let user to delete his saved payment cards I am using this package

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

Code:

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

Is there something I am missing?

You have to create a "braintree customer" then store braintree.customer.id to your user object.

Then if you have a braintree customer id, you can generate a custom client token like me. Call this on your backend to generate one then use that in your Drop-in show({clientToken}) option field

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM