Sha256: 7886ed3dd3c1b21a342672ba6bd86122e7076363fe5ba65e4687c060b64a4c9c

Contents?: true

Size: 997 Bytes

Versions: 69

Compression:

Stored size: 997 Bytes

Contents

module Effective
  module Providers
    module Paypal
      extend ActiveSupport::Concern

      included do
        skip_before_action :verify_authenticity_token, only: [:paypal_postback]
      end

      # TODO: Make paypal postback work with admin checkout workflow

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

        (EffectiveOrders.authorize!(self, :update, @order) rescue false)

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

        head(:ok)
      end


    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
effective_orders-4.4.6 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.5 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.4 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.3 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.1 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.0 app/controllers/effective/providers/paypal.rb
effective_orders-4.3.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.3.1 app/controllers/effective/providers/paypal.rb
effective_orders-4.3.0 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.7 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.6 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.5 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.4 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.3 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.1 app/controllers/effective/providers/paypal.rb
effective_orders-4.2.0 app/controllers/effective/providers/paypal.rb
effective_orders-4.1.5 app/controllers/effective/providers/paypal.rb
effective_orders-4.1.4 app/controllers/effective/providers/paypal.rb