Class: CatarseMoip::NotificationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CatarseMoip::NotificationsController
- Defined in:
- app/controllers/catarse_moip/notifications_controller.rb
Defined Under Namespace
Classes: TransactionStatus
Instance Attribute Summary collapse
-
#payment ⇒ Object
Returns the value of attribute payment.
Instance Method Summary collapse
Instance Attribute Details
#payment ⇒ Object
Returns the value of attribute payment.
6 7 8 |
# File 'app/controllers/catarse_moip/notifications_controller.rb', line 6 def payment @payment end |
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 |
# File 'app/controllers/catarse_moip/notifications_controller.rb', line 24 def create return render :nothing => true, :status => 200 rescue Exception => e return render :text => "#{e.inspect}: #{e.} recebemos: #{params}", :status => 422 end |
#process_moip_message ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/catarse_moip/notifications_controller.rb', line 35 def payment.with_lock do payment_notification = payment.payment_notifications.create({ contribution: payment.contribution, extra_data: JSON.parse( params.to_json.force_encoding('iso-8859-1').encode('utf-8')) }) payment_id = (payment.gateway_id.gsub(".", "").to_i rescue 0) if payment_id <= params[:cod_moip].to_i payment.update_attributes payment_id: params[:cod_moip] if (params[:valor].to_i/100.0) < payment.value && params[:valor] #return payment.invalid! unless payment.invalid_payment? return end case params[:status_pagamento].to_i when TransactionStatus::PROCESS payment_notification.deliver_process_notification when TransactionStatus::AUTHORIZED, TransactionStatus::FINISHED payment.pay! unless payment.paid? when TransactionStatus::WRITTEN_BACK, TransactionStatus::REFUNDED payment.refund! unless payment.refunded? when TransactionStatus::CANCELED unless payment.refused? payment.refuse! if payment.slip_payment? payment_notification.deliver_slip_canceled_notification end end end end end end |