title: Stripe Custom Checkout Issue with Rails
body: <p>I'm currently creating a job board where when a customer posts a job board they pay for it in one form and it will then post the job and charge there card all at once.</p>
  
  <p>First, I used the standard Stripe Checkout button along with my listings form and it submitted both my form and took payment.</p>
  
  <p>Then I tried customizing the Stripe Checkout button using the custom docs <a href="https://stripe.com/docs/checkout#integration-custom" rel="nofollow noreferrer"><strong>found here</strong></a> but I can't seem to understand what I'm missing. </p>
  
  <p>Now when I click on the button it pops up like normal but when I submit the button my Rails form doesn't create nor does it charge Stripe. </p>
  
  <p><strong>listings_controller.rb</strong></p>
  
  <pre><code>def create
    p @listing = Listing.new(listing_params)
    @categories = Category.all.map{|c| [ c.title, c.id ] }
    charge_error = nil
  
    p @listing.valid?
    p @listing.errors
  
    if @listing.valid?
      begin
        customer = Stripe::Customer.create(
          :email =&gt; params[:stripeEmail],
          :card =&gt; params[:stripeToken]
        )
  
        charge = Stripe::Charge.create(
          :customer =&gt; customer.id,
          :amount =&gt; @amount,
          :description =&gt; 'New Job Posting',
          :currency =&gt; 'usd'
        )
  
      rescue Stripe::CardError =&gt; e
        p 'rescue'
        p e
        charge_error = e.message
      end
  
      if charge_error
        p 'change error not nil'
        p charge_error
        flash[:error] = charge_error
        render :new
      else
        p 'trying to save listing'
        p @listing.save
        redirect_to @listing
      end
    else
      p 'listing not valid'
      flash[:error] = 'one or more errors in your orders'
      render :new
    end
  end
  </code></pre>
  
  <p><strong>listings/_form.html.erb</strong></p>
  
  <pre><code>//Top of the page //
  &lt;script src="https://checkout.stripe.com/checkout.js"&gt;&lt;/script&gt;
  
  &lt;button class='btn btn-block btn-primary' id='customButton'&gt;
    Pay and Post Your Job Posting!
  &lt;/button&gt;
  
  &lt;% end %&gt;
  
  &lt;script&gt;
    var handler = StripeCheckout.configure({
      key: "pk_test_iSItYFJUx04fB9Ax6yGQjRDP",
      image: "https://stripe.com/img/documentation/checkout/marketplace.png",
      name: "Example Name",
      description: "Pro Subscription ($29 per month)",
      panelLabel: "Subscribe",
      allowRememberMe: false,
      locale: 'auto',
      token: function(token) {
        token.id
      }
    });
  
    document.getElementById('customButton').addEventListener('click', function(e) {
      handler.open({
        name: 'Example Name #2',
        description: 'Subscripe ($99/monthly)',
        amount: 2000
      });
      e.preventDefault();
    });
  
    // Close Checkout on page navigation:
    window.addEventListener('popstate', function() {
      handler.close();
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>If you need any other info please ask. Thank you!</p>