Class: Spree::PagseguroController
- Inherits:
-
StoreController
- Object
- StoreController
- Spree::PagseguroController
- Defined in:
- app/controllers/spree/pagseguro_controller.rb
Instance Method Summary collapse
Instance Method Details
#callback ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/controllers/spree/pagseguro_controller.rb', line 5 def callback @order = Spree::Order.find_by_number(params[:order]) pagseguro_transaction = Spree::PagseguroTransaction.find_by_order_id(@order.number) pagseguro_transaction.update_attribute :state, 'waiting' redirect_to spree.order_path(@order) end |
#notify ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/spree/pagseguro_controller.rb', line 14 def notify logger.info "[PAGSEGURO] Gateway is calling /notify" logger.info params #notification = Spree::PagseguroTransaction.update_last_transaction(params) #payment_method = Spree::PaymentMethod.where(type: 'Spree::Gateway::PagSeguro').first @order = Spree::Order.find_by_number(notification.reference) payment = @order.payments.where(:state => "checkout", :payment_method_id => payment_method.id).last if notification.approved? logger.info "[PAGSEGURO] Order #{@order.number} approved" payment.complete! else logger.info "[PAGSEGURO] Order #{@order.number} failed" payment.failure! end render nothing: true, head: :ok end |