Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8763941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:54:11+00:00 2026-06-13T15:54:11+00:00

I’m using Stripe in my Rails 3 application to do creditcard payments. I’m roughly

  • 0

I’m using Stripe in my Rails 3 application to do creditcard payments. I’m roughly following the railscast on Stripe integration though my app is doing just a single charge for now and not subscription billing like Ryan shows.

The problem is, I can’t get the processCard() function to fire. I’ll be the first to admit I’m not a javascript guru (or any kind of guru for that matter). It doesn’t give a javascript error, it instead submits the form to rails (without any credit card details) and fails since stripe_card_token is nil. I’ve placed some alert() dialogs spaced throughout for some very crude debugging to see where the hangup is. My model name is Payment which is really the only deviation so far from Ryan’s code apart from the temporary alert() dialogs.

So my question is twofold: How can I reliably track down what’s causing the problem? and Where did I go wrong?

Here’s the Javascript:

jQuery ->
  Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
  payment.setupForm()

payment =
  setupForm: ->
    $('#new_payment').submit ->
      $('input[type=submit]').attr('disabled', true)
      alert("before processCard")
      payment.processCard()
      alert("after processCard")
      false
      # else
      #   true

  processCard: ->
    alert("processCard start")
    card =
      number: $('#credit_card_number').val()
      cvc: $('#cvc').val()
      expMonth: $('#card_month').val()
      expYear: $('#card_year').val()
    alert("card values are set")
    Stripe.createToken(card, payment.handleStripeResponse)
    alert("After createToken")

  handleStripeResponse: (status, response) ->
    if status == 200
      alert(response.id)
      # $('#payment_stripe_card_token').val(response.id)
      # $('#new_payment')[0].submit()
    else
      alert(response.error.message)
      # $('#stripe_error').text(response.error.message)
      # $('input[type=submit]').attr('disabled', false)

And the associated view:

<%= simple_form_for @payment, :html => { :class => 'form-horizontal'} do |f| %>
<fieldset>
  <legend>Pay via Credit Card</legend>

    <%= f.input :stripe_card_token, :as => :hidden, :id => 'stripe_card_token' %>

    <div class="well well-small">
      <%= current_user.full_name %><br />
      <%= current_user.email %><br />
      This is the name we have on file for you. If it's not correct, please <%= link_to "change it now", edit_user_registration_path(current_user) %>
    </div>

<div id="stripe_error">
  <noscript>JavaScript is not enabled and is required for this form. First enable it in your web browser settings.</noscript>
</div>

<div id="credit-card">
  <div class="control-group string required">
    <%= label_tag :credit_card_number, "Card Number", :class => "control-label string required" %>
    <div class="controls">
      <%= text_field_tag :credit_card_number, nil, :class => "string required", :name => nil %>
    </div>
  </div>

  <div class="control-group string required">
    <%= label_tag :cvc, "Security code (CVC)", :class => "control-label string required" %>
    <div class="controls">
      <%= text_field_tag :cvc, nil, :class => "string required", :name => nil %>
    </div>
  </div>

  <div class="control-group date required">
    <%= label_tag :card_month, "Expiration Date", :class => "control-label date required"%>
    <div class="controls">
      <%= select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month", :class => "date required span2"} %>
      <%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+25}, {name: nil, id: "card_year", :class => "date required span2"} %>
    </div>
  </div>

    <h4>Your unpaid courses</h4>
    <% @unpaid_subs.each do |sub| %>
      <%= sub.course.name %>&nbsp;|&nbsp;<%= sub.course.credits %><br />
    <% end %>

<div class="form-actions">
<%= f.submit nil, :class=>"btn btn-primary" %>
<%= link_to "Cancel", courses_path, :class=>"btn" %>
</div>
</fieldset>
<% end %>

Related Question(No accepted answer): What is wrong with my CoffeScript in Stripe?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:54:12+00:00Added an answer on June 13, 2026 at 3:54 pm

    I figured out the problem. Thanks a ton “@mu is too short”. Your suggestion of stripping it down to just the required js and html ultimately helped me find the error.

    It turns out I had misspelled the name attribute on my meta tag that has the Stripe public key. In the application layout, it was missing the “r” in “stripe-key”:

    <%= tag :meta, :name => "stipe-key", :content => STRIPE_PUBLIC_KEY %>
    

    I had a super hard time finding this since it didn’t cause any exceptions or show up in the logs. To find the cause of the problem, I did two things:

    • I placed alert() dialogs in key places of the javascript to pause the script as it runs and find which function wasn’t working. Kind of crude, but it worked.
    • As @mu is too short said in the comments:

    Are you sure that there’s no other JavaScript getting in your way? Restart by writing the
    HTML by hand and getting rid of all (Coffee|Java)Script except the stripe libraries,
    jQuery, and your code.

    In doing this, I found that the javascript won’t run properly if there is an error in some other javascript on the page. By stripping the view down to just the essentials, I not only ultimately found the problem with the variable name, but also found several unrelated errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.