Skip to content

Instantly share code, notes, and snippets.

@davidlee
Forked from anonymous/gist:83976
Created March 24, 2009 06:41
Show Gist options
  • Save davidlee/83979 to your computer and use it in GitHub Desktop.
Save davidlee/83979 to your computer and use it in GitHub Desktop.
def donation_uk_giftaid
unless request.post?
redirect_to :action=>"donate"
return
end
@heroPage = HeroPage.search_url(params[:url], DateTime.now)
hero_page_variables("preview", true)
if session[:mydonation_id]
@donation = Donation.find_by_id(session[:mydonation_id])
@donation.update_attributes(params[:donation])
else
@donation = create_donation_from_form_post_and_hero_page
end
def create_donation_from_form_post_and_hero_page
# Set the amount for the donation
amount = params[:donation][:amount]
amount = params[:donation_amount][:amount] rescue nil if amount.empty?
# Determine payment gateway for donation, use the nil feature in
pm = PaymentGatewayManager.make_from_model(@heroPage.event,true,true)
Donation.new("amount" => amount,
:add_to_edh_mailing_list => params[:donation][:add_to_edh_mailing_list],
:show_email_to_hero => params[:donation][:show_email_to_hero],
:add_to_charity_mailing_list => params[:donation][:add_to_charity_mailing_list],
:add_to_receipt_mailing_list => params[:donation][:add_to_receipt_mailing_list],
:comments => params[:donation][:comments],
:firstname => params[:donation][:firstname],
:heroPage => @heroPage,
:charityProfile => @heroPage.charityProfile,
:donation_status_id => 1,
:donation_type_id => (@activeHero ? 3 : 1),
:currency => @currency,
:payment_manager_id => (pm ? pm.payment_manager_id : nil))
end
end
Parameters: {"commit"=>"      Make Donation      ", "url"=>"Bert_Watt", "action"=>"donation_uk_giftaid", "donation_amount"=>{"amount"=>"25"}, "controller"=>"hero_pages", "donation"=>{"comments"=>"", "add_to_charity_mailing_list"=>"0", "add_to_receipt_mailing_list"=>"0", "firstname"=>"", "amount"=>"", "add_to_edh_mailing_list"=>"0", "show_email_to_hero"=>"0"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment