My sandbox account doesn't store payment methods for customer in their vault. I am creating a customer object using:
def create_customer
result = Braintree::Customer.create(
:first_name => params[:first_name],
:last_name => params[:last_name],
:email => params[:email],
:phone => params[:phone]
)
if result.success?
render :json => {'result' => result.customer.id}
else
render :json => {'errors' => result.errors}, :status => 400
end
end
and then storing the customer_id in my database for later use.
When creating client_token I am sending the same customer_id to the API. Here is the code for creating client_token:
def client_token
token = Braintree::ClientToken.generate(
:customer_id => params[:customer_id]
)
render :json => {"token" => token}
end