braintree / braintree_ios

Braintree SDK for iOS
https://developer.paypal.com/braintree/docs/start/hello-client/ios/v5
MIT License
563 stars 292 forks source link

Can't get token of credit card in BTCardPaymentMethod object #145

Closed pablomarti closed 8 years ago

pablomarti commented 9 years ago

Hi!

I'm trying to update a payment method as a default. In order to do that, I'm connecting to an API developed in Node.js, following this example: https://developers.braintreepayments.com/ios+node/reference/request/customer/update#update-customer-and-existing-credit-card

The Node.js method requires a token. I have a BTCardPaymentMethod object, which inherits from BTPaymentMethod. I can get the nonce, but I can't get the token required by the Node.js method. How should I proceed? How can I get that token?

Abhijith-Gopi commented 9 years ago

Same issue on the iOS SDK. Not found any "token" for deleting an already existing payment method.

demerino commented 8 years ago

The iOS, JS and Android clients do not return tokens - just nonces. You can send a nonce to your server and then use a variety of methods to retrieve the token for vaulted payment methods. You can also use the customer_id to retrieve payment methods (and their tokens) on your server.

Example: https://developers.braintreepayments.com/ios+node/reference/request/customer/update#update-customer-and-existing-credit-card

gateway.customer.find("theCustomerId", function (err, customer) {
  var token = customer.creditCards[0].token;
});