Class: Spree::BankSlipsController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/spree/bank_slips_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
10
11
# File 'app/controllers/spree/bank_slips_controller.rb', line 8

def show
  data = open(@slip.pdf)
  send_data data.read, filename: "boleto_#{@slip.id}.pdf", type: 'application/pdf'
end

#status_changedObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/spree/bank_slips_controller.rb', line 13

def status_changed
  if params[:data]
    case params[:data][:status].to_sym
      # Captura o pagamento
      when :paid then @slip.payment.capture!
      # Cancela o pagamento e o pedido
      when :canceled, :expired
        @slip.payment.void_transaction!
        @slip.order.cancel!
    end
  end
  render nothing: true, status: 200
end