Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created April 18, 2012 15:46
Show Gist options
  • Save coderforhire/2414454 to your computer and use it in GitHub Desktop.
Save coderforhire/2414454 to your computer and use it in GitHub Desktop.
<%= form_for(@purchase) do |f| %>
<%= f.hidden_field :stripe_card_token %>
<% if @purchase.stripe_card_token.present? %>
Credit card has been provided.
<% else %>
<div class="field">
<%= label_tag :card_number, "Credit Card Number" %>
<%= text_field_tag :card_number, nil, name: nil %>
</div>
<div class="field">
<%= label_tag :card_code, "Security Code on Card (CVV)" %>
<%= text_field_tag :card_code, nil, name: nil %>
</div>
<div class="field">
<%= label_tag :card_month, "Card Expiration" %>
<%= select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month"} %>
<%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} %>
</div>
<% end %>
<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>
<% if @purchase.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@purchase.errors.count, "error") %> prohibited this purchase from being saved:</h2>
<ul>
<% @purchase.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
~
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment