Module: Effective::Providers::Paypal

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/effective/providers/paypal.rb

Instance Method Summary collapse

Instance Method Details

#paypal_postbackObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/effective/providers/paypal.rb', line 14

def paypal_postback
  @order ||= Effective::Order.where(id: (params[:invoice].to_i rescue 0)).first

  (EffectiveOrders.authorized?(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