-
-
Save jerome/3286578 to your computer and use it in GitHub Desktop.
Sample Credit Card Validation with ActiveMerchant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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