Class: Fe::PaymentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Fe::PaymentsController
- Defined in:
- app/controllers/fe/payments_controller.rb
Instance Method Summary collapse
- #approve ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#edit ⇒ Object
Allow applicant to edit payment /applications/1/payment_page/edit js: provide a partial to replace the answer_sheets page area.
-
#staff_search ⇒ Object
TODO this be moved to a decorotor or cru_lib as per Josh’s instructions not to have Staff code in FE.
- #update ⇒ Object
Instance Method Details
#approve ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/fe/payments_controller.rb', line 84 def approve @payment = Fe::Payment.find(params[:id]) @application = @payment.answer_sheet @payment.auth_code = si_user.user.person.account_no case @payment.payment_type when 'Staff' staff_approval staff_payment_processed_email(@payment) when 'Mail' Fe::Notifier.notification(@application.email, # RECIPIENTS Fe.from_email, # FROM "Check Received", # LIQUID TEMPLATE NAME {'name' => @application.applicant.informal_full_name}).deliver end @payment.approve! @payment.application.complete end |
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/fe/payments_controller.rb', line 21 def create Fe::Payment.transaction do @payment = @application.payments.new(payment_params) if @application.payments.non_denied.length > 0 @payment.errors.add(:base, "You have already submitted a payment for this application.") render :action => "error" else @payment.amount = Fe.cost @payment.status = 'Pending' if @payment.valid? case @payment.payment_type when "Credit Card" card_type = params[:payment][:card_type] creditcard = ActiveMerchant::Billing::CreditCard.new( :brand => card_type, :number => @payment.card_number, :month => @payment.expiration_month, :year => @payment.expiration_year, :verification_value => @payment.security_code, :first_name => @payment.first_name, :last_name => @payment.last_name ) if creditcard.valid? response = GATEWAY.purchase(@payment.amount * 100, creditcard) if response.success? @payment.approve! # TODO: Send notification email else @payment.errors.add(:base, "Credit card transaction failed: #{response.}") #Send email this way instead of raising error in order to still give an error message to user. # Fe::Notifier.notification('[email protected]', # RECIPIENTS # "[email protected]", # FROM # "Credit Card Error", # LIQUID TEMPLATE NAME # {'error' => "Credit card transaction failed: #{response.message} \n #{response.inspect} \n #{creditcard.inspect}"}).deliver end else @payment.errors.add(:card_number, "is invalid. Check the number and/or the expiration date.") end when "Mail" @payment.approve! when "Staff" @payment.save send_staff_payment_request(@payment) end end end end end |
#destroy ⇒ Object
112 113 114 115 |
# File 'app/controllers/fe/payments_controller.rb', line 112 def destroy @payment = @application.payments.find(params[:id]) @payment.destroy end |
#edit ⇒ Object
Allow applicant to edit payment /applications/1/payment_page/edit js: provide a partial to replace the answer_sheets page area
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/fe/payments_controller.rb', line 11 def edit @payment = Fe::Payment.find(params[:id]) @application = @payment.answer_sheet # if this isn't a staff payment they shouldn't be here for this staff person unless 'Staff' == @payment.payment_type && current_person.isStaff? render('no_access') and return end @payment.status = "Approved" # set the status so a default radio button will be selected end |
#staff_search ⇒ Object
TODO this be moved to a decorotor or cru_lib as per Josh’s instructions not to have Staff code in FE
103 104 105 106 107 108 109 110 |
# File 'app/controllers/fe/payments_controller.rb', line 103 def staff_search #@payment = @application.payments.new(params[:payment].slice(:payment_type, :payment_account_no, :auth_code)) @payment = @application.payments.new(staff_search_payment_params) if @payment.staff_first.to_s.strip.empty? || @payment.staff_last.to_s.strip.empty? render; return end @results = Staff.order('"lastName", "firstName"').where("(\"firstName\" like ? OR \"preferredName\" like ?) AND \"lastName\" like ? and \"removedFromPeopleSoft\" <> 'Y'", @payment.staff_first+'%', @payment.staff_first+'%', @payment.staff_last+'%') end |
#update ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/fe/payments_controller.rb', line 73 def update @payment = Fe::Payment.includes({:application => :applicant}).find(params[:id]) @application = @payment.answer_sheet @person = @application.applicant @payment.status = params[:payment][:status] staff_approval @payment.save! staff_payment_processed_email(@payment) @payment.answer_sheet.complete end |