Sha256: 24d57247fbb3dbeaa1c07d86d256d150323db3a729fcdcf3f337434d2615a396

Contents?: true

Size: 957 Bytes

Versions: 9

Compression:

Stored size: 957 Bytes

Contents

module Effective
  module Providers
    module Paypal
      extend ActiveSupport::Concern

      included do
        skip_before_filter :verify_authenticity_token, :only => [:paypal_postback]

        if defined?(CanCan)
          skip_authorization_check only: [:paypal_postback]
        end
      end

      def paypal_postback
        @order ||= Effective::Order.where(id: (params[:invoice].to_i rescue 0)).first

        if @order.present?
          if @order.purchased?
            order_purchased(details: params, provider: 'paypal', card: params[:payment_type])
          elsif (params[:payment_status] == 'Completed' && params[:custom] == EffectiveOrders.paypal[:secret])
            order_purchased(details: params, provider: 'paypal', card: params[:payment_type])
          else
            order_declined(details: params, provider: 'paypal', card: params[:payment_type])
          end
        end

        head(:ok)
      end


    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
effective_orders-2.1.6 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.5 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.4 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.3 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.2 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.1 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.0 app/controllers/effective/providers/paypal.rb
effective_orders-2.0.1 app/controllers/effective/providers/paypal.rb
effective_orders-2.0.0 app/controllers/effective/providers/paypal.rb