Sha256: 7be40625ae82313a072eca9eda712231ef443a49a95769ac61650fa28134b52f

Contents?: true

Size: 907 Bytes

Versions: 12

Compression:

Stored size: 907 Bytes

Contents

module Spree
  class PagSeguroController < BaseController
    protect_from_forgery :except => [:notify]
    skip_before_filter :restriction_access
    
    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
    
    def callback
    end
    
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spree_pag_seguro-1.0.7 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.6 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.5 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.4 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.3 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.2 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.1 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.0.rc6 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.0.rc5 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.0.rc4 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.0.rc3 app/controllers/spree/pag_seguro_controller.rb
spree_pag_seguro-1.0.0.rc2 app/controllers/spree/pag_seguro_controller.rb