title: Stripe creating new customer for existing users' purchases
body: <p>I've found that if a user purchases a product a second time, a new customer is created in my Stripe dashboard. I would like it so once a customer makes their first purchase, following purchases will be charged to that existing customer and their saved card. 
  My app is running Rails 4.</p>
  
  <p><strong>charges_controller.rb</strong></p>
  
  <pre><code>def create
    @user = current_user
    @gift = Gift.friendly.find(params[:gift_id])
    @charge = Charge.new(charge_params)
    @codes = Code.all
    @code = @gift.codes.where(:used =&gt; false).order("created_at ASC").first
    token = params[:stripeToken]
    if @user.customer_id.nil?
      # Create customer
        customer = Stripe::Customer.create(
        :card =&gt; token,
        :email =&gt; @user.email
      )
      # Charge the customer instead of the card
      Stripe::Charge.create(
        :amount =&gt; (@gift.price * 100).to_i,
        :currency =&gt; "cad",
        :customer =&gt; customer.id
      )
      # Customer_id is set to the Stripe customer.id
      customer_id = customer.id
      # If the transaction is approved
      if @charge.save
        # And user selects save_cc
        if @charge.save_cc == true
          # Update User's cusomter_id field to the var
          @user.update_attributes(:customer_id =&gt; customer_id)
          send_code(@user, @gift, @charge, @code)
        else 
          send_code(@user, @gift, @charge, @code)                     
        end 
      else 
        render 'charges/new'
      end 
    else
      # If user already has customer_id
      Stripe::Charge.create(
        :amount =&gt; (@gift.price * 100).to_i,
        :currency =&gt; "cad",
        :customer =&gt; @user.customer_id
      )
      if @charge.save 
        send_code(@user, @gift, @charge, @code)
      else 
        render 'charges/new'
      end 
    end 
  end
  </code></pre>