1
votes

I am trying to use the latest (v3.5.0 as of Dec. 2014) Braintree (BT) iOS sdk in my app. I was able to get a client token from my server and present BT's Drop In viewController:

Braintree *braintree = [Braintree braintreeWithClientToken:self.clientToken];
BTDropInViewController *dropInViewController = [braintree dropInViewControllerWithDelegate:self];
[self.navigationController pushViewController:dropInViewController animated:YES];

and BT generates a nonce, which I could capture in a BT delegate method and send to my server for transaction.

The problem I am trying to solve is that since users of my app make payments frequently, I have to save their cards info in the app so they make their next payments by just selecting one of their saved cards; otherwise they will have to enter their card info every time they make a payment. Basically, I just couldn't figure out how BT is getting the saved payment cards list as shown in the right image here:

https://github.com/braintree/braintree_ios#braintree-vzero-sdk-for-ios

Any pointer to what I need to do (or sample code) to save card info for future one-touch-payment? Thanks.

1

1 Answers

1
votes

There are two ways to go about this:

  1. Embed the customer_id in your client token. In ruby, it will look like this:

    @client_token = Braintree::ClientToken.generate( :customer_id => a_customer_id )

This change will only impact Drop In. Manually tokenized cards still need to be saved in the Vault explicitly.

  1. Alternatively, use the nonce you are currently receiving to save the payment method in the vault. In ruby, it will look like this:

    result = Braintree::PaymentMethod.create( :customer_id => "YOUR_CUSTOMER_ID", :payment_method_nonce => "NONCE-FROM-CLIENT" )

In both cases, you can create transactions from the vault using the token (the nonce is no longer needed).