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-6.4.4 app/controllers/effective/providers/paypal.rb
effective_orders-6.4.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.4.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.4.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.4.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.3.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.3.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.3.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.2.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.2.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.5 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.4 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.3 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.2 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.1.0 app/controllers/effective/providers/paypal.rb
effective_orders-6.0.1 app/controllers/effective/providers/paypal.rb
effective_orders-6.0.0 app/controllers/effective/providers/paypal.rb
effective_orders-5.9.4 app/controllers/effective/providers/paypal.rb
effective_orders-5.9.3 app/controllers/effective/providers/paypal.rb