Sha256: c3883e478a9ee4449970e9931edbe38d514374ccd702eef2e6fbf47c2d5d57c2

Contents?: true

Size: 997 Bytes

Versions: 15

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(details: params, provider: 'paypal', card: params[:payment_type])
          elsif (params[:payment_status] == 'Completed' && params[:custom] == EffectiveOrders.paypal[:secret])
            order_purchased(details: params, provider: 'paypal', card: params[:payment_type])
          else
            order_declined(details: params, provider: 'paypal', card: params[:payment_type])
          end
        end

        head(:ok)
      end


    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
effective_orders-3.2.3 app/controllers/effective/providers/paypal.rb
effective_orders-3.2.2 app/controllers/effective/providers/paypal.rb
effective_orders-3.2.1 app/controllers/effective/providers/paypal.rb
effective_orders-3.2.0 app/controllers/effective/providers/paypal.rb
effective_orders-3.1.7 app/controllers/effective/providers/paypal.rb
effective_orders-3.1.6 app/controllers/effective/providers/paypal.rb
effective_orders-3.1.4 app/controllers/effective/providers/paypal.rb
effective_orders-3.1.3 app/controllers/effective/providers/paypal.rb
effective_orders-3.1.0 app/controllers/effective/providers/paypal.rb
effective_orders-3.0.4 app/controllers/effective/providers/paypal.rb
effective_orders-3.0.3 app/controllers/effective/providers/paypal.rb
effective_orders-3.0.2 app/controllers/effective/providers/paypal.rb
effective_orders-4.0.0beta1 app/controllers/effective/providers/paypal.rb
effective_orders-3.0.1 app/controllers/effective/providers/paypal.rb
effective_orders-3.0.0 app/controllers/effective/providers/paypal.rb