I am working with the Braintree Java API. After reviewing the docs I have several questions that I hope are not altogether obvious.
Information that might help you: Working with Struts. Using .jsp
Question 1 When my customer logs in, I will pass their customerId to Braintree and fetch the Collection of credit cards. The credit card list contains information such as the last 4 of the card number, card type etc. Am I safe to put the returned credit card list to the session so I can output the information in my .jsp page? It is important that my customers can view the payment information as they can save multiple credit cards. Ideally, I will display the last four numbers with asterisks. Is there a security risk since the token exists in the CreditCard class? By setting the credit card list to the session, there is the possibility that the token could be sought out.
Question 2 What is the best way to associate the token with the correct credit card. For example, lets say my customer has 3 credit cards to choose from when purchasing an item. They select the second credit card. How do I associate the correct token with the second card so that when I send the token to Braintree the correct card is charged? The solution I have come up with is to have radio buttons for selection. When the card is selected and the submit button pressed, I will fetch the index of the selected radio button. I will then fetch the card from the array of credit cards. Using that returned CreditCard class, I can get the token and pass it on to Braintree. Does this sound like a good solution to you all?