【问题标题】:how can I delete added card list with braintree-web on ember.js如何在 ember.js 上使用 Braintree-web 删除添加的卡片列表
【发布时间】:2016-08-16 23:21:35
【问题描述】:

我正在使用 ember.js(2.0)、braintree-web 进行支付。

用户可以使用如下图所示的 Drop-in UI 添加他们的卡信息。

users card list

用户可以在如下图所示的帐户页面中查看他们的卡列表。

added card list

如果用户想删除他们的卡片列表,可以通过点击删除列表。我能怎么做?我想我可以在收到令牌的 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);
      });
    }
  }
});

【问题讨论】:

    标签: ember.js braintree


    【解决方案1】:

    我向 Braintree 支持团队发送了一封邮件。然后我收到了回复。 总之,前端卡信息是没有办法删除的。它可以在服务器端完成。

    以下是 Braintree 支持团队的回复

    要删除付款方式,您需要使用其中一种服务器端 SDK(适用于 Java、.Net、Node.js、PHP、Python、Ruby)。 Braintree-web 库是一个客户端 SDK,它仅帮助您收集支付方式信息以换取支付方式随机数。您仍然需要集成服务器 SDK 以使用付款方式 nonce 执行任何操作。您在这里要做的是创建一个 AJAX 调用并将令牌发送到您的服务器并从那里删除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多