I'm using BrainTree drop-in UI, and I'm generating a client token as follows:
token = Braintree::ClientToken.generate(customer_id: some_id, options: {make_default: true })
Then updating the customer through:
Braintree::Customer.update(
some_id,
payment_method_nonce: options[:payment_method_nonce]
)
However the selected credit card isn't set as the default one, as checking customer.default_payment_method
always returns the same card. So any clue to update the default payment method when updating customer?
Edit
After some investigation, it seems when I add a new payment method, it is set as the default one, however when choosing a saved payment method, it is not set as default.
I ended up using the following code:
Braintree::PaymentMethod.create(
customer_id: some_id,
payment_method_nonce: options[:payment_method_nonce],
options: {
make_default: true
}
)