Search code examples
javabraintreepayment-method

Braintree error in creating new payment method with existing address - Java


I'm using Java Braintree API and I'm having issues when I try to add a new payment method to an existing customer using an existing address.

PaymentMethodRequest request = new PaymentMethodRequest()
                              .customerId(someId)
                              .paymentMethodNonce(paymentMethodNonce)
                              .billingAddressId("ny")
                              .options()
                              .failOnDuplicatePaymentMethod(true)
                              .done();
Result<? extends PaymentMethod> result = gateway.paymentMethod().create(request);

In result.message I have "Cannot provide both a billing address and a billing address ID." but in the request I only provide the billing address Id and not the full address. What's wrong? Thanks for your help.


Solution

  • I've omitted that I'm using Sandbox account and a 'fake-valid-visa-nonce'. I've contacted Braintree support, they reply that in the fake nonce there is already and address, that's why when I try to use an existing address and that fake nonce I got the error.