class Transaction

Attributes

amount[R]
created_at[R]
order_id[R]
refunded_transaction_id[R]

Public Class Methods

new(hash = {}) click to toggle source
# File lib/mock_braintree/transaction.rb, line 6
def initialize(hash = {})
  @amount = hash[:amount]
  @options = hash.fetch(:options, nil)
  @order_id = hash.fetch(:order_id, nil)
  @submit_for_settlement = submit_for_settlement
  @created_at = Time.now.utc
  @refunded_transaction_id = hash.fetch(:id, nil)
  @void = hash.fetch(:void, false)
end

Public Instance Methods

id() click to toggle source
# File lib/mock_braintree/transaction.rb, line 32
def id
  @id ||= SecureRandom.hex(3)
end
status() click to toggle source
# File lib/mock_braintree/transaction.rb, line 16
def status
  if @void == true
    'voided'
  elsif (amount.to_f < 2000) && (submit_for_settlement == true)
    'submitted_for_settlement'
  elsif (amount.to_f < 2000) && (submit_for_settlement == false)
    'authorized'
  elsif (amount.to_f >= 2000) && amount.to_i < 3000
    'processor_declined'
  elsif (amount.to_f >= 3000) && amount.to_i <= 3000.99
    'failed'
  else
    'authorized'
  end
end

Private Instance Methods

submit_for_settlement() click to toggle source
# File lib/mock_braintree/transaction.rb, line 38
def submit_for_settlement
  if @options != nil
    @options.fetch(:submit_for_settlement, false)
  else
    false
  end
end