Class: PayFu::AlipayTransactionsController

Inherits:
ApplicationController show all
Includes:
ActiveMerchant::Billing::Integrations
Defined in:
app/controllers/pay_fu/alipay_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/alipay_transactions_controller.rb', line 5

def notify
  notify = Alipay::Notification.new(request.new_post)
  if notify.acknowledge
    if transaction = PayFu::AlipayTransaction.find_by_transaction_id(notify.trade_no)
      transaction.update_attributes(transaction_attributes(notify))
    else
      PayFu::AlipayTransaction.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/alipay_transactions_controller.rb', line 17

def transaction_attributes(notify)
  @transaction_attributes ||= {
    :transaction_id => notify.trade_no,
    :transaction_type => notify.payment_type,
    :payment_status => notify.trade_status,
    :payment_date => notify.notify_time,
    :gross => notify.total_fee,
    :raw_post => notify.raw
  }
end