Sha256: dfca55d0000ee832c97b6e643aa17ea6be62668254ce05cf3820ee590c4d4f0a

Contents?: true

Size: 887 Bytes

Versions: 6

Compression:

Stored size: 887 Bytes

Contents

module CatarsePagarme
  class NotificationsController < CatarsePagarme::ApplicationController
    skip_before_filter :authenticate_user!

    def create
      if payment
        payment.payment_notifications.create(contribution: payment.contribution, extra_data: params.to_json)

        if PagarMe::validate_fingerprint(payment.try(:gateway_id), params[:fingerprint])

          if params[:current_status] == 'paid' && params[:desired_status] == 'refunded'
            payment.try(:invalid_refund)
          else
            delegator.change_status_by_transaction(params[:current_status])
            delegator.update_fee
          end

          return render nothing: true, status: 200
        end
      end

      render nothing: true, status: 404
    end

    protected

    def payment
      @payment ||=  PaymentEngines.find_payment({ gateway_id: params[:id] })
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
catarse_pagarme-2.6.5 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.6.4 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.6.3 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.6.2 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.6.1 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.6.0 app/controllers/catarse_pagarme/notifications_controller.rb