title: Stripe / Rails Issue: "Invalid source object: must be a dictionary or a non-empty string"
body: <p>I'm building a custom checkout form in my rails app and getting this error when posting to the controller:</p>
  
  <p>"Invalid source object: must be a dictionary or a non-empty string"</p>
  
  <p>Here's my form:</p>
  
  <pre><code>&lt;script src="https://checkout.stripe.com/checkout.js"&gt;&lt;/script&gt;
  
      &lt;%= form_tag registrations_path, :id=&gt;"stripeForm" do |f| %&gt;
        &lt;h2&gt;Register for the &lt;%= @workshop.name %&gt; Workshop ($&lt;%= @workshop.price %&gt;)&lt;/h2&gt;
  
        &lt;div class="row"&gt;
          &lt;div class="form-group col-sm-6"&gt;
            &lt;%= text_field_tag(:f_name, nil, :placeholder=&gt;"First Name", :class=&gt;"form-control") %&gt;
          &lt;/div&gt;
          &lt;div class="form-group col-sm-6"&gt;
            &lt;%= text_field_tag(:l_name, nil, :placeholder=&gt;"Last Name", :class=&gt;"form-control") %&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="row text-center"&gt;
           &lt;button class="buy-button" id="stripe-button"&gt;Buy Ticket&lt;/button&gt;
           &lt;%= hidden_field_tag 'stripeToken' %&gt;
           &lt;%= hidden_field_tag 'stripeEmail' %&gt;
           &lt;%= hidden_field_tag 'stripeAmount' %&gt;
        &lt;/div&gt;
  
         &lt;script&gt;
       var handler = StripeCheckout.configure({
         key: "&lt;%= ENV['stripe_publishable_key'] %&gt;",
         token: function (token, args) {
           $("#stripeToken").value = token.id;
           $("#stripeEmail").value = token.email;
           $("#stripeAmount").value = &lt;%= @workshop.price * 100 %&gt;;
           $("#stripeForm").submit();
         }
       });
  
       $('#stripe-button').on('click', function (e) {
         // Open Checkout with further options
         $name = $('input[name=f_name]').val() + " " + $('input[name=l_name]').val();
         handler.open({
           name: $name,
           description: "&lt;%= @workshop.name %&gt;" + " workshop",
           amount: &lt;%= @workshop.price * 100 %&gt;
         });
       e.preventDefault();
       });
  
       $(window).on('popstate', function() {
         handler.close();
       });
     &lt;/script&gt;
  
      &lt;% end %&gt;
  </code></pre>
  
  <p>Here's my controller action:</p>
  
  <pre><code>def create
      # Amount in cents
      amount = params[:stripeAmount].to_i * 100
  
      # Create the customer in Stripe
      customer = Stripe::Customer.create(
        email: params[:stripeEmail],
        card: params[:stripeToken]
      )
  
      # Create the charge using the customer data returned by Stripe API
      charge = Stripe::Charge.create(
        customer: customer.id,
        amount: amount,
        description: 'Rails Stripe customer',
        currency: 'usd'
      )
  
      # place more code upon successfully creating the charge
    rescue Stripe::CardError =&gt; e
      flash[:error] = e.message
      redirect_to charges_path
      flash[:notice] = "Please try again"
    end
  </code></pre>
  
  <p>Basically the user fills out first and last name, clicks on pay button. Then they fill out stripe info and submit. I've tried using debugger right after they click submit, and all the token info etc is there as it should be.</p>
  
  <p>But then I get an error as soon as it gets to the create action in the controller, and shows empty strings for all the stripe params.</p>
  
  <p>Where am I going wrong?</p>
  
  <p>Edit: added below strong params to the controller but had no effect:</p>
  
  <pre><code>protected
  
    def registration_params
      params.require(:registration).permit(:stripeEmail, :stripeToken, :stripeAmount)
    end
  </code></pre>