title: Stripe Checkout with Custom Integration in Rails
body: <p>I am trying to implement <a href="https://stripe.com/docs/checkout">Stripe Checkout</a> using the custom integration in a rails app - my checkout form shows a green checkmark saying it submitted but the payment is not being processed.  The simple integration works well, as do subscription payments on other parts of my site.</p>
  
  <p>Like the simple integration, I am trying to place the custom integration script inside of a form_tag - I followed the <a href="https://stripe.com/docs/checkout/guides/rails">Rails Checkout guide</a>, which unfortunately is only written for the simple integration.  Like the guide, I have a charges controller, with new and create actions to show the form and create the charges.</p>
  
  <p>Charges Controller:</p>
  
  <pre><code>class ChargesController &lt; ApplicationController
  
  def new
  end
  
  def create
    # Amount in cents
    @amount = 500
  
    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; 'Rails Stripe customer',
      :currency    =&gt; 'usd'
    )
  
  rescue Stripe::CardError =&gt; e
    flash[:error] = e.message
    redirect_to charges_path
  end
  
  end
  </code></pre>
  
  <p>And in my new view, the form is setup as follows:</p>
  
  <pre><code>&lt;%= form_tag charges_path do %&gt;
    &lt;script src="https://checkout.stripe.com/checkout.js"&gt;&lt;/script&gt;
  
      &lt;button id="customButton" class="btn btn-large btn-primary"&gt;Buy Now&lt;/button&gt;
  
      &lt;script&gt;
        var handler = StripeCheckout.configure({
          key: '&lt;%= ENV["STRIPE_PUBLIC_KEY"] %&gt;',
          image: '/assets/my_logo.png',
          token: function(token, args) {
            // Use the token to create the charge with a server-side script.
          }
        });
  
        document.getElementById('customButton').addEventListener('click', function(e) {
          // Open Checkout with further options
          handler.open({
            name: 'My Company',
            description: 'Product ($60.00)',
            amount: 60*100,
            shippingAddress: true
          });
          e.preventDefault();
        });
      &lt;/script&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I have tried just about everything I can think of, but the form will not be submitted to trigger the create action.  I see the note to use a server side script, but can anyone point me in the right direction on what I may be missing?  </p>
  
  <p>Any help is much appreciated!! Thanks!</p>