Class: CatarseCompraFacil::CompraFacilController

Inherits:
ApplicationController show all
Defined in:
app/controllers/catarse_compra_facil/compra_facil_controller.rb

Constant Summary collapse

SCOPE =
"projects.backers.checkout"

Instance Method Summary collapse

Instance Method Details

#backerObject



31
32
33
34
35
36
37
# File 'app/controllers/catarse_compra_facil/compra_facil_controller.rb', line 31

def backer
  @backer ||= if params['id']
                PaymentEngines.find_payment(id: params['id'])
              elsif params['txn_id']
                PaymentEngines.find_payment(payment_id: params['txn_id']) || (params['parent_txn_id'] && PaymentEngines.find_payment(payment_id: params['parent_txn_id']))
              end
end

#payObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/catarse_compra_facil/compra_facil_controller.rb', line 9

def pay
  begin
    @comprafacil = CatarseCompraFacil::CompraFacil.new({
        :origin => backer.project.id,
        :value => backer.value,
        :info => "" })

    @comprafacil.send_order!

    backer.update_attributes payment_method: 'CompraFacil', entity: @comprafacil.entity, reference: @comprafacil.reference

    flash[:success] = t('success_comprafacil', scope: SCOPE)
    redirect_to main_app.project_backer_path(project_id: backer.project.id, id: backer.id)

  rescue Exception => e
    Rails.logger.info "-----> #{e.inspect}"
    flash[:failure] = t('paypal_error', scope: SCOPE)
    return redirect_to main_app.new_project_backer_path(backer.project)
  end

end

#reviewObject



6
7
# File 'app/controllers/catarse_compra_facil/compra_facil_controller.rb', line 6

def review
end