Permalink
Browse files

Pull credit cards from our system rather than stripe

  • Loading branch information...
1 parent 29175b2 commit 4faf0cb167ec6316568daf09c2327c8710070b54 @jordanbyron jordanbyron committed Oct 19, 2012
View
4 app/assets/javascripts/pr.payment_processor.coffee
@@ -13,10 +13,6 @@ class PR.PaymentProcessor
$.facebox { div: '#update-credit-card' }, 'update-credit-card'
e.preventDefault()
- $(document).on 'click', 'a.current-cc', (e) ->
- $.facebox { ajax: $(this).attr('href') }, 'current-credit-card'
- e.preventDefault()
-
formSubmit: (event) =>
event.preventDefault();
View
2 app/assets/stylesheets/partials/_settings.sass
@@ -55,6 +55,8 @@ form.edit_user
display: none
a.current-cc
margin-left: 10px
+ #current-credit-card
+ margin-left: 1em
#facebox
.update-credit-card, .current-credit-card
View
8 app/controllers/users_controller.rb
@@ -19,6 +19,7 @@ def notifications; end
def billing
@subscriptions = SubscriptionDecorator.decorate(
@user.subscriptions.order("start_date"))
+ @credit_card = current_user.credit_card
end
def update_credit_card
@@ -29,13 +30,6 @@ def update_credit_card
redirect_to billing_settings_path
end
- def current_credit_card
- payment_gateway = current_user.payment_gateway
- @card = payment_gateway.current_credit_card
-
- render :layout => false
- end
-
def update
params[:current_page] ||= :edit
View
7 app/models/credit_card.rb
@@ -0,0 +1,7 @@
+class CreditCard < ActiveRecord::Base
+ belongs_to :user
+
+ def description
+ "XXXX-XXXX-XXXX-#{last_four} #{expiration_month}/#{expiration_year}"
+ end
+end
View
2 app/models/user.rb
@@ -7,6 +7,8 @@ class User < ActiveRecord::Base
has_many :subscriptions
has_many :payment_logs
+ has_one :credit_card
+
validates_uniqueness_of :contact_email, :on => :update
validates :status, :inclusion => {
:in => STATUSES, :message => "%{value} is not a valid status" }
View
5 app/views/users/billing.html.haml
@@ -27,9 +27,8 @@
- if @user.payment_provider == "stripe"
%p
= link_to "Update your credit card", '#', :class => "btn update-cc"
- = link_to "Show which card we are currently billing",
- current_credit_card_path,
- :class => "current-cc", :rel => "facebox"
+ - if @credit_card
+ %span#current-credit-card Current Card: #{@credit_card.description}
#update-credit-card
%h1 Update your credit card
View
15 db/migrate/20121019183135_create_credit_cards.rb
@@ -0,0 +1,15 @@
+class CreateCreditCards < ActiveRecord::Migration
+ def up
+ create_table :credit_cards do |t|
+ t.belongs_to :user
+ t.string :last_four
+ t.integer :expiration_month
+ t.integer :expiration_year
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :credit_cards
+ end
+end
View
12 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121011002134) do
+ActiveRecord::Schema.define(:version => 20121019183135) do
create_table "announcements", :force => true do |t|
t.text "title"
@@ -80,6 +80,15 @@
t.datetime "updated_at"
end
+ create_table "credit_cards", :force => true do |t|
+ t.integer "user_id"
+ t.string "last_four"
+ t.integer "expiration_month"
+ t.integer "expiration_year"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
t.integer "attempts", :default => 0
@@ -150,7 +159,6 @@
t.string "contact_email"
t.string "access_token"
t.boolean "notify_updates", :default => true, :null => false
- t.text "mailchimp_web_id"
t.text "payment_provider"
t.text "payment_provider_id"
end

0 comments on commit 4faf0cb

Please sign in to comment.