2015-04-30 50 views
2

我試圖更新通過下面的代碼保存在用新值布倫特裏庫信用卡: -布倫特裏 - TokenizeCard不工作

var data = { 
     cardholderName: $('#cardholder_name').val(), 
     expirationDate: $('#expiration_date').val(), 
     cvv: $('#cvv').val(), 
     billingAddress: { 
      firstName: $('#firstName').val(), 
      lastName: $('#lastName').val(), 
      streetAddress: $('#streetAddress').val(), 
      locality: $('#city').val(), 
      region: $('#state').val(), 
      postalCode: $('#postalCode').val(), 
      countryName: $('input[name="country"]').val(), 
     } 
    }; 
    if($('#number').prop('disabled') == false) { 
     data.number = $('#number').val(); 
    } 
    data.billingAddress['options'] = { updateExisting: true }; 

var client = new braintree.api.Client({clientToken: "<?=$client_token?>"}); 
client.tokenizeCard(data, function (err, nonce) { 
}); 

上面的代碼工作正常,當我刪除

data.billingAddress['options'] = { updateExisting: true }; 

如果我包含上面的行,我收到錯誤無法標記卡。當我通過javascript對信用卡進行標記時,如何更新現有賬單地址?

回答

2

我在布倫特裏工作。如果您需要任何其他幫助,請隨時通過[email protected]與我們聯繫。

致電tokenizeCard時,包含在呼叫中的卡和帳單地址信息未添加到您的保險箱中。因此,不應使用updateExisting,並且在嘗試標記卡時會返回錯誤。

要更新現有信用卡,您需要將收到的隨機數傳遞到服務器,然後撥打Braintree_PaymentMethod::update()來更新信息。在撥打此電話時,您需要確保擁有原始信用卡的令牌(當您首次撥打Braintree_PaymentMethod::create()Braintree_CreditCard::create())時會返回此號碼。