我正在使用ember.js(2.0),braintree-web进行付款。
用户可以使用Drop-in UI添加其卡信息,如下图所示。
用户可以在帐户页面中看到他们的卡片列表,如下图所示。
如果用户想要删除其卡片列表,可以通过单击删除列表。我能怎么做?我想我可以在收到令牌的deletePaymentMethod中删除。
这是我的payment-selector.js
import Ember from 'ember';
export default Ember.Component.extend({
ajax: Ember.inject.service(),
session: Ember.inject.service(),
createNewPaymentMethod: false,
selectPaymentMethods: Ember.computed(function() {
let array = this.get('paymentMethodsArray');
array.pushObject({id:'newPaymentMethod',title:'Add new payment method'});
return array;
}),
paymentMethodsArray: Ember.computed.map('paymentMethods', function(item, index){
return {id: item.get('token'), title: `${item.get('bin')}...${item.get('last4')}`};
}),
actions: {
updatePaymentMethod: function(selection) {
Ember.Logger.debug(selection);
if (selection.id == 'newPaymentMethod') {
this.set('createNewPaymentMethod', true);
} else {
this.set('createNewPaymentMethod', false);
this.sendAction('onPaymentMethodSelection', {token:selection.id});
}
},
processBraintreeNonce: function(nonce) {
Ember.Logger.debug(nonce);
const self = this;
const authenticated = this.get('session.data.authenticated');
this.get('ajax').request(`account/${authenticated.account.id}/payment_methods`,{
method: 'POST',
data: {
nonce: nonce
}
}).then(function(response){
Ember.Logger.debug(response);
self.sendAction('onPaymentMethodSelection', response.data);
self.set('hideBrainTreeSubmit', true);
}).catch(function(reason){
self.set('hideBrainTreeSubmit', false);
Ember.Logger.debug(reason);
});
}
}
});

答案 0 :(得分:1)
我发了一封邮件给Braintree支持团队。然后我收到了回复。 总之,没有办法删除前端的卡信息。它可以在服务器端完成。
以下是Braintree支持团队的回复
要删除付款方式,您需要使用服务器端SDK之一(Java,.Net,Node.js,PHP,Python,Ruby)。 braintree-web库是一个客户端SDK,它只会帮助您收集付款方式信息以换取付款方式随机数。您仍然需要集成服务器SDK以使用付款方式nonce执行任何操作。你在这里要做的是创建一个AJAX调用并将令牌发送到你的服务器并从那里删除。