Sha256: a971d24e84152b3ced6a1c2991c1c9442ab23f381d5bd30dcf9918f2f28565bb

Contents?: true

Size: 1.06 KB

Versions: 88

Compression:

Stored size: 1.06 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

        (EffectiveResources.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

88 entries across 88 versions & 1 rubygems

Version Path
effective_orders-5.4.1 app/controllers/effective/providers/paypal.rb
effective_orders-5.4.0 app/controllers/effective/providers/paypal.rb
effective_orders-5.3.2 app/controllers/effective/providers/paypal.rb
effective_orders-5.3.1 app/controllers/effective/providers/paypal.rb
effective_orders-5.3.0 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.17 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.16 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.15 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.14 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.13 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.12 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.11 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.10 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.9 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.8 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.7 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.6 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.5 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.4 app/controllers/effective/providers/paypal.rb
effective_orders-5.2.3 app/controllers/effective/providers/paypal.rb