2016-08-16 1 views
0

ember.js (2.0), braintree-web을 사용하고 있습니다.ember.js에서 braintree-web으로 추가 된 카드 목록을 삭제하는 방법

사용자는 아래 그림과 같은 드롭 인 UI를 사용하여 카드 정보를 추가 할 수 있습니다.

users card list

그리고 사용자는 이미지 아래 같은 계정 페이지에서 자신의 카드 목록을 볼 수 있습니다. 사용자가 자신의 카드 목록을 삭제하고자 할 경우

added card list

, 목록은 클릭에 의해 삭제 될 수 있습니다. 어떻게해야합니까? 토큰을받은 deletePaymentMethod에서 삭제할 수 있다고 생각합니다.

여기에 결제-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); 
 
     }); 
 
    } 
 
    } 
 
});

답변

1

내가 브레인 지원 팀에 메일을 보낼 수 있습니다. 그 때 나는 응답을 받았다. 결론적으로 프런트 엔드에서 카드 정보를 삭제할 방법이 없습니다. 서버 측에서 수행 할 수 있습니다. 다음은

이 결제 수단을 삭제하려면 브레인 지원 팀에서 응답, 당신은 자바, 닷넷, Node.js를, PHP, 파이썬에서 사용할 수있는 서버 측 SDK 중 하나를 (사용해야합니다 , 루비). braintree-web 라이브러리는 지불 방법 nonce 대신 결제 방법 정보를 수집하는 데 도움이되는 클라이언트 SDK입니다. 지불 방법 nonce로 조치를 수행하려면 서버 SDK를 통합해야합니다. 여기서 할 일은 AJAX 호출을 작성하여 서버에 토큰을 보내고 거기에서 삭제하는 것입니다.