Search code examples
rubybraintreerecurring-billing

BrainTree Recurring Bill: How to store a customer in the Vault


I'm trying to implement a Recurring Bill in my application by using BrainTree. In BrainTree's documentation, to create a Subscription, it requires that the customer has to be stored in the Vault, but the option :store_in_vault is only available for Transaction but I couldn't find any way to create a customer stored in the Vault from my application. I tend to add a Transaction with amount 0$ to the Vault then create the Subscription. Is there any other possibility to do this more appropriately?


Solution

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

    To create a customer stored in the Vault, use Customer.create, passing in the nonce from your client as the payment_method_nonce parameter. This will create a Customer as well as a PaymentMethod.

    Afterwards call Subscription.create using the payment_method_token and the plan_id.