Class: PaymentNotificationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/payment_notifications_controller.rb

Constant Summary collapse

SUCCESSFUL_PAYPAL_STATES =
%w[instant echeck completed processed pending]

Instance Method Summary collapse

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/payment_notifications_controller.rb', line 27

def create
  if request_seems_to_be_valid()
    PaymentNotification.create!(:params  => params,
                                :cart_id => params[:invoice],
                                :status  => params[:payment_status].downcase,
                                :transaction_id => params[:txn_id])
  else
    Rails.logger.warn("Something was wrong with this transaction! See PaymentNotification entry for cart_id #{params[:invoice]} and transaction_id #{params[:txn_id]}")
  end
  render :nothing => true
end

#indexObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/payment_notifications_controller.rb', line 13

def index
  if request_seems_to_be_valid()
    pm = PaymentNotification.create!(:params  => params,
                                     :cart_id => params[:invoice],
                                     :status  => params[:payment_status].downcase,
                                     :transaction_id => params[:txn_id])
    render :text => pm.inspect
  else
    Rails.logger.warn("Something was wrong with this transaction! See PaymentNotification entry for cart_id #{params[:invoice]} and transaction_id #{params[:txn_id]}")
    render :text => 'test failed'
  end
end