Created
November 17, 2011 00:19
-
-
Save christopherdbull/1371976 to your computer and use it in GitHub Desktop.
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
def create | |
build_resource | |
card = ActiveMerchant::Billing::CreditCard.new( | |
:number => params[:expiry_number], | |
:month => params[:expiry_month], | |
:year => params[:date_year], | |
:name => params[:name_on_card], | |
:verification_value => :params[:cvv] | |
) | |
if card.valid? | |
response = GATEWAY.purchase(5750, card, purchase_options) | |
if response.success? | |
puts response.inspect | |
resource.orders.create!(amount: 57.50, item: "subscription") | |
resource.register | |
else | |
#set_flash_message :notice | |
clean_up_passwords(resource) | |
respond_with_navigational(resource) { render_with_scope :new } | |
end | |
end | |
if resource.save | |
if resource.active_for_authentication? | |
set_flash_message :notice, :signed_up if is_navigational_format? | |
sign_in(resource_name, resource) | |
respond_with resource, :location => after_sign_up_path_for(resource) | |
else | |
set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format? | |
expire_session_data_after_sign_in! | |
respond_with resource, :location => after_inactive_sign_up_path_for(resource) | |
end | |
else | |
clean_up_passwords(resource) | |
respond_with_navigational(resource) { render_with_scope :new } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment