ruby-on-railsbraintreebraintree-rails

how to stop braintree to store payment_methode without asking for server side nonce?


I have installed Braintree on our system for users subscriptions and everything works well, except for one strange behave of Braintree which is storing payment method without my server-side nonce.

My goal is to let the user have a maximum of 3 payment methods stored on his customer account.

Here is what I expect each time user add a payment method:

  1. server generates and sends the SDK to client-side
  2. client sends me nonce
  3. server sends a nonce and customer id to Braintree
  4. Brain tree store payment method of customer

Here is what I get after storing first payment method:

  1. server generates and sends the SDK to client-side
  2. client sends me nonce
  3. Brain tree already stored the payment method of the customer!

As you see Braintree stores payment_method without asking me for step 3. which is not good because then I can not limit the number of payment_methods which stored in the customer profile.


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    It sounds like you are passing a customer ID into the client token generation. As a result, the Drop-in UI displays a customer's stored payment methods and automatically stores any new payment methods added by the customer in your Braintree Vault upon tokenization.

    If you are using Drop-in version 1.18.0 or later, you can pass vaultCard as false in the dropin.create option. You could then Vault the card server-side using the store_in_vault_on_success parameter or follow your desired workflow from here.