Skip to content

Instantly share code, notes, and snippets.

@ZenCocoon
Created August 7, 2012 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ZenCocoon/3282974 to your computer and use it in GitHub Desktop.
Save ZenCocoon/3282974 to your computer and use it in GitHub Desktop.
Sample Credit Card Validation with ActiveMerchant
# encoding: utf-8
#
class Account::CreditCardController < Account::BaseController
# GET /account/credit_card
def edit
@account = current_account
@credit_card = ActiveMerchant::Billing::CreditCard.new
end
# PUT /account/credit_card
def update
@account = current_account
@credit_card = ActiveMerchant::Billing::CreditCard.new(params['credit_card'])
if @credit_card.valid? && @account.subscription.update_credit_card(@credit_card)
flash[:admin_success] = "admin.account.credit_card.update.success"
redirect_to account_url
else
render :edit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment