I am using the Braintree Sping Example found here: https://github.com/braintree/braintree_spring_example.
The controller class has a method that charges a new credit card/customer a particular amount. The controller gets that amount from the POST data.
Instead of using a new card/customer, I'd like to use a vaulted credit card.
It seems that the way to do this is by creating a new PaymentMethodRequest as shown here: https://developers.braintreepayments.com/reference/request/payment-method/create/java
But when I look at the API, I do not see how to set an amount to charge with PaymentMethodRequest. Unlike the TransactionRequest class, PaymentMethodRequest does not allow the setting of an amount.
So, given a customerid, how do I charge a vaulted card a one-time fee?
Thanks for the help.
This is the method that processes the post information
public String postForm(@RequestParam("amount") String amount, @RequestParam("payment_method_nonce") String nonce, Model model, final RedirectAttributes redirectAttributes) {
// ... validate the amount ...
TransactionRequest request = new TransactionRequest()
.amount(decimalAmount)
.paymentMethodNonce(nonce)
.options()
.submitForSettlement(true)
.done();
Result<Transaction> result = gateway.transaction().sale(request);
// ... process result....
}
It seems like I should be able to do
PaymentMethodRequest request = new PaymentMethodRequest()
.amount(decimalAmount) // this isn't actually allowed by the class
.customerId(customer.getId())
.token("the_token")
.paymentMethodNonce(nonceFromTheClient);
But PaymentMethodRequest does not have that functionality.