Sha256: fabdd59e3b7c16c92fe41fe51278c8d6a95d7bb5c91349f1c5f6053ede86e023

Contents?: true

Size: 1.22 KB

Versions: 30

Compression:

Stored size: 1.22 KB

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
        raise('paypal provider is not available') unless EffectiveOrders.paypal?

        @order ||= Effective::Order.deep.where(id: (params[:invoice].to_i rescue 0)).first
        @order.current_user = current_user unless admin_checkout?(paypal_params)

        # We do this even if we're not authorized
        EffectiveResources.authorized?(self, :update, @order)

        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

      def paypal_params
        {}
      end

    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
effective_orders-6.23.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.22.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.21.4 app/controllers/effective/providers/paypal.rb
effective_orders-6.21.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.21.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.21.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.21.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.20.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.7 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.6 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.5 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.4 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.19.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.18.4 app/controllers/effective/providers/paypal.rb
effective_orders-6.18.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.18.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.18.1 app/controllers/effective/providers/paypal.rb