Class: PayFu::PaypalTransactionsController

Inherits:
ApplicationController show all
Includes:
ActiveMerchant::Billing::Integrations
Defined in:
app/controllers/pay_fu/paypal_transactions_controller.rb

Instance Method Summary collapse

Instance Method Details

#notifyObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/pay_fu/paypal_transactions_controller.rb', line 5

def notify
  notify = Paypal::Notification.new(request.raw_post)
  if notify.acknowledge
    if transaction = PayFu::PaypalTransaction.find_by_transaction_id(notify.transaction_id)
      transaction.update_attributes(transaction_attributes(notify))
    else
      PayFu::PaypalTransaction.create(transaction_attributes(notify))
    end
  end
  render :nothing => true
end

#transaction_attributes(notify) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/pay_fu/paypal_transactions_controller.rb', line 17

def transaction_attributes(notify)
  @transaction_attributes ||= {
    :transaction_id => notify.transaction_id,
    :transaction_type => notify.type,
    :payment_status => notify.status,
    :payment_date => notify.received_at,
    :gross => notify.gross_cents,
    :raw_post => notify.raw
  }
end