Sha256: f255ecd09add9b4c0707fb251151e11f9c2cb246c8244459eb1aa600166ba96c
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
class CatarseIugu::IuguController < ApplicationController layout false def review contribution end def pay begin payment.save! charge = Iugu::Charge.create( "token" => params[:token], "email" => contribution.payer_email, "items" => [ { "description" => contribution.project.name, "quantity" => "1", "price_cents" => contribution.price_in_cents } ] ) if charge.success flash[:notice] = "ContribuiĆ§Ć£o feita com sucesso!" payment.pay! PaymentEngines.create_payment_notification contribution_id: contribution.id, payment_id: payment.id redirect_to main_app.project_contribution_path(contribution.project, contribution) else flash[:error] = "Houve um erro ao realizar o pagamento." redirect_to main_app.new_project_contribution_path(contribution.project) end rescue Exception => e Rails.logger.info "-----> #{e.inspect}" flash[:failure] = e.message return redirect_to main_app.new_project_contribution_path(contribution.project) end end private def contribution @contribution ||= PaymentEngines.find_contribution(params[:id]) end def payment @payment ||= PaymentEngines.new_payment( contribution: contribution, value: contribution.value, gateway: "Iugu", payment_method: 'Iugu' ) end end
Version data entries
3 entries across 3 versions & 1 rubygems