Sha256: de602962b0eb5e58640bc1d1ada3c0f2f95061fe8668f2a8e00fd0d11dc2a0a8

Contents?: true

Size: 1.12 KB

Versions: 24

Compression:

Stored size: 1.12 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.where(id: (params[:invoice].to_i rescue 0)).first

        # 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], current_user: current_user)
          else
            order_declined(payment: params, provider: 'paypal', card: params[:payment_type])
          end
        end

        head(:ok)
      end

    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
effective_orders-6.9.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.9.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.9.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.8.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.8.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.8.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.7.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.7.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.7.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.7.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.6.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.6.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.6.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.6.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.9 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.8 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.7 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.6 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.5 app/controllers/effective/providers/paypal.rb
effective_orders-6.5.4 app/controllers/effective/providers/paypal.rb