Class: Spree::PagSeguroController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/pag_seguro_controller.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



25
26
# File 'app/controllers/spree/pag_seguro_controller.rb', line 25

def callback
end

#notifyObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/pag_seguro_controller.rb', line 6

def notify
  notification = Spree::PaymentNotification.create_from_params(params)
  
  if notification.approved?
    Order.transaction do
      @order = Spree::Order.find(notification.id)
      
      # 1. Assume that if payment notification comes, it's exactly for the amount
      # sent to pagseguro (safe assumption -- cart can't be edited while on pagseguro)
      # 2. Can't use Order#total, as it's intercepted by spree-multi-currency
      # which might lead to lots of false "credit owed" payment states
      # (when they should be "complete")
      @order.payment.complete
    end
  end
  
  render nothing: true, head: :ok
end