服務器端有一項功能可以刪除付款方式(result = Braintree::PaymentMethod.delete("the_token")
),但需要付款方式令牌。我如何從客戶端獲取付款方式令牌和臨時數字?Braintree,如何從客戶端刪除具有現時的用戶信用卡?
編輯:我沒有使用UI的下降。我有一個用戶擁有的信用卡自定義列表(使用Javascript v3 SDK)。我想要一個按鈕來刪除卡片。 JS SDK dosnt提供信用卡令牌,只是一個隨機數。將可用於客戶端的數據轉換爲我可以用來刪除服務器上的卡的過程是什麼?
edit2:clent端的信用卡列表使用JavaScript v3 SDK中的VaultManager。它返回fetchPaymentMethodsPayload。
這是客戶端代碼:
_loadPaymentMethods() {
this.paymentService.getBraintreeToken().then(token => {
this.braintreeClient.create({
authorization: token
}, (clientErr, clientInstance) => {
if (clientErr) {
// Handle error in client creation
return;
}
var options = {
client: clientInstance,
};
this.vaultManager.create(options, (err, vaultInstance) => {
if (err) {
console.log(err);
return;
}
vaultInstance.fetchPaymentMethods({ defaultFirst: true }, (err, paymentMethods) => {
paymentMethods.forEach(paymentMethod => {
if(paymentMethod.type == 'CreditCard') {
this.cards.push(paymentMethod);
if(paymentMethod.default) {
this.card = paymentMethod;
}
}
});
});
});
});
});
}
[付款方式隨機數](https://developers.braintreepayments.com/start/overview#payment-method-nonce)通常不對應於有庫存的[付款方式](https://developers.braintreepayments。 COM /參考/響應/支付方法)。隨機數表示臨時支付信息將被消耗。這種情況的主要例外是,如果您使用Drop-in UI並在客戶端令牌中包含['customer_id'](https://developers.braintreepayments.com/guides/drop-in/javascript/#customer- ID)。你可以編輯你的問題來說明你是否在使用Drop-in UI的自動存儲功能嗎? – zepp
假設您通過查找[客戶對象](https://developers.braintreepayments.com/reference/response/customer)來生成用戶信用卡的自定義列表,則可以訪問[支付方法標記](https ://developers.braintreepayments.com/reference/response/payment-method)通過[客戶的付款方式屬性](https://developers.braintreepayments.com/reference/response/customer/#payment_methods)。如果您沒有以這種方式填充付款方式,您是否可以添加生成用戶信用卡列表的代碼? –