SO in my iOS app (and Java backend) users can purchase things. When they create an account they are required to provide us with their payment card information. I want to be able to save this card information when their account is created in app, and tie it to a UUID with which it will be looked up. Furthermore, whenever the user then wants to buy something, I want to easily be able to get their payment information they provided on sign up, based on their UUID and charge the card stored in it. This seems like an extremely common use case for Braintree but I can't find examples online regarding how to implement it and I am stuck.
So how do I:
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
CustomerRequest request = new CustomerRequest() .id("customer_123") .paymentMethodNonce(nonceFromTheClient); Result<Customer> result = gateway.customer().create(request);
In order to find a customer’s payment method information later using the customer ID, you can call
Customer.find() and then retrieve that customer’s payment methods:
Customer customer = gateway.customer().find("customer_123"); customer.getPaymentMethods().get(0).getToken();
Alternatively, you can create a transaction with a customer ID and an amount, which will automatically use the customer's default payment method:
TransactionRequest request = new TransactionRequest() .customerId("customer_123") .amount(new BigDecimal("10.00")); Result<Transaction> result = gateway.transaction().sale(request);