Sha256: 697c957a278efd6f5fe0e8065d739e4418ee8dc46e240b8d454ca4c3b65e553a

Contents?: true

Size: 881 Bytes

Versions: 2

Compression:

Stored size: 881 Bytes

Contents

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

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

        if PagarMe::validate_fingerprint(contribution.try(:payment_id), params[:fingerprint])

          if params[:current_status] == 'paid' && params[:desired_status] == 'refunded'
            contribution.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 contribution
      @contribution ||=  PaymentEngines.find_payment({ payment_id: params[:id] })
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
catarse_pagarme-2.5.1 app/controllers/catarse_pagarme/notifications_controller.rb
catarse_pagarme-2.5.0 app/controllers/catarse_pagarme/notifications_controller.rb