Sha256: 3b30c929418b8b691458df813039e074bb977473801f8aa1ec7ddfd28933c4ae

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

module Effective
  module Providers
    module Paypal
      extend ActiveSupport::Concern

      included do
        if respond_to?(:skip_before_action)
          skip_before_action :verify_authenticity_token, :only => [:paypal_postback]
        else
          skip_before_filter :verify_authenticity_token, :only => [:paypal_postback]
        end
      end

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

        (EffectiveOrders.authorized?(self, :update, @order) rescue false)

        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

7 entries across 7 versions & 1 rubygems

Version Path
effective_orders-2.2.4 app/controllers/effective/providers/paypal.rb
effective_orders-2.2.3 app/controllers/effective/providers/paypal.rb
effective_orders-2.2.2 app/controllers/effective/providers/paypal.rb
effective_orders-2.2.1 app/controllers/effective/providers/paypal.rb
effective_orders-2.2.0 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.17 app/controllers/effective/providers/paypal.rb
effective_orders-2.1.16 app/controllers/effective/providers/paypal.rb