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.6.3 app/controllers/effective/providers/paypal.rb
effective_orders-4.6.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.6.0 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.12 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.11 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.10 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.9 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.8 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.7 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.6 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.5 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.4 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.3 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.1 app/controllers/effective/providers/paypal.rb
effective_orders-4.5.0 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.10 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.9 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.8 app/controllers/effective/providers/paypal.rb
effective_orders-4.4.7 app/controllers/effective/providers/paypal.rb