Class: Moneytree::Transaction

Inherits:
ApplicationRecord show all
Defined in:
app/models/moneytree/transaction.rb

Direct Known Subclasses

Payment, Refund

Instance Method Summary collapse

Instance Method Details

#cardObject



16
17
18
# File 'app/models/moneytree/transaction.rb', line 16

def card
  payment_provider.card_for(self)
end

#process_response(response) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/moneytree/transaction.rb', line 20

def process_response(response)
  if response.success?
    update!(
      status: :completed,
      psp_error: response.message,
      details: (details || {}).merge(response.body)
    )
  else
    # FIXME: pending state
    update!(
      status: :failed,
      psp_error: response.message
    )
  end
end