Sha256: 84e9ba87f2e7d2c804c132ee4ad439913f2bb9704fff8da43ecde5b04ce3901e

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Spree
  class PagSeguroController < Spree::BaseController
    protect_from_forgery :except => [:notify]
    
    def notify
      email = Spree::PagSeguro::Config.email
      token = Spree::PagSeguro::Config.token
      notification_code = params[:notificationCode]
      notification = ::PagSeguro::Notification.new(email, token, notification_code)
      
      logger.info "PagSeguro Notification code: #{notification_code}\n\n\n"
      logger.info "PagSeguro Notification inspect:\n#{notification.inspect}"
      
      if notification.approved?
        order = Spree::Order.find(notification.id)
        order.payment.complete
        while order.state != 'complete'
          order.next
        end
      end
      render nothing: true, head: :ok
    end
    
    def callback
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_pag_seguro-1.0.0.beta17 app/controllers/spree/pag_seguro_controller.rb