Skip to content

Commit

Permalink
update cards to sources, closes andrewculver#155
Browse files Browse the repository at this point in the history
  • Loading branch information
durfee committed Jun 15, 2016
1 parent 745f983 commit 08dcfb2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Version 1.3.1 (NOT released on rubygems)
author: 0.0.12 - 1.3.0 @yas4891 etal. from repo, 1.3.1 @durfee

Fixed using credit cards under new API (2016-03-07). Changed use of 'card' to 'source'.

No support for ACH yet.


## Version 0.0.12 (NOT released on rubygems)
author: Christoph Engelhardt (@yas4891)

Expand Down
4 changes: 2 additions & 2 deletions app/concerns/koudoku/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def processing!

# store the customer id.
self.stripe_id = customer.id
self.last_four = customer.cards.retrieve(customer.default_card).last4
self.last_four = customer.sources.retrieve(customer.default_source).last4

finalize_new_subscription!
finalize_upgrade!
Expand Down Expand Up @@ -127,7 +127,7 @@ def processing!
customer.save

# update the last four based on this new card.
self.last_four = customer.cards.retrieve(customer.default_card).last4
self.last_four = customer.sources.retrieve(customer.default_source).last4
finalize_card_update!

end
Expand Down
19 changes: 11 additions & 8 deletions app/controllers/koudoku/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SubscriptionsController < ApplicationController
before_filter :load_plans, only: [:index, :edit]

def load_plans
@plans = ::Plan.order(:display_order)
@plans = ::Plan.order(:price)
end

def unauthorized
Expand Down Expand Up @@ -74,6 +74,9 @@ def index
redirect_to koudoku.edit_owner_subscription_path(current_owner, current_owner.subscription)
end

# Load all plans.
@plans = ::Plan.order(:display_order).all

# Don't prep a subscription unless a user is authenticated.
unless no_owner?
# we should also set the owner of the subscription here.
Expand All @@ -96,7 +99,7 @@ def new
end

else
raise I18n.t('koudoku.failure.feature_depends_on_devise')
raise "This feature depends on Devise for authentication."
end

else
Expand All @@ -120,7 +123,7 @@ def create
flash[:notice] = after_new_subscription_message
redirect_to after_new_subscription_path
else
flash[:error] = I18n.t('koudoku.failure.problem_processing_transaction')
flash[:error] = 'There was a problem processing this transaction.'
render :new
end
end
Expand All @@ -129,7 +132,7 @@ def show
end

def cancel
flash[:notice] = I18n.t('koudoku.confirmations.subscription_cancelled')
flash[:notice] = "You've successfully cancelled your subscription."
@subscription.plan_id = nil
@subscription.save
redirect_to owner_subscription_path(@owner, @subscription)
Expand All @@ -140,10 +143,10 @@ def edit

def update
if @subscription.update_attributes(subscription_params)
flash[:notice] = I18n.t('koudoku.confirmations.subscription_updated')
flash[:notice] = "You've successfully updated your subscription."
redirect_to owner_subscription_path(@owner, @subscription)
else
flash[:error] = I18n.t('koudoku.failure.problem_processing_transaction')
flash[:error] = 'There was a problem processing this transaction.'
render :edit
end
end
Expand All @@ -169,8 +172,8 @@ def after_new_subscription_path
def after_new_subscription_message
controller = ::ApplicationController.new
controller.respond_to?(:new_subscription_notice_message) ?
controller.try(:new_subscription_notice_message) :
I18n.t('koudoku.confirmations.subscription_upgraded')
controller.try(:new_subscription_notice_message) :
"You've been successfully upgraded."
end
end
end
2 changes: 1 addition & 1 deletion lib/koudoku/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Koudoku
VERSION = "1.3.0"
VERSION = "1.3.1"
end

0 comments on commit 08dcfb2

Please sign in to comment.