[英]Braintree VaultManager using react-native-braintree-dropin-ui
我想讓用戶刪除他保存的支付卡 我正在使用這個包
"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 => { ...
有什么我想念的嗎?
您必須創建一個“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));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.