class RocketGate::Transaction
Constants
- TYPE
Attributes
amount[RW]
credit_card[RW]
currency[RW]
customer[RW]
id[RW]
reference_id[RW]
type[RW]
Public Class Methods
new(*args)
click to toggle source
# File lib/rocketgate/transaction.rb, line 33 def initialize(*args) @amount, @customer, @credit_card, @currency, @id = *args end
Public Instance Methods
is_hashed?()
click to toggle source
# File lib/rocketgate/transaction.rb, line 67 def is_hashed? credit_card && !credit_card.card_hash.nil? end
is_referenced?()
click to toggle source
# File lib/rocketgate/transaction.rb, line 71 def is_referenced? [ TYPE[:confirmation], TYPE[:ticket], TYPE[:void] ].include?(type) && !reference_id.nil? end
to_hash()
click to toggle source
Calls superclass method
# File lib/rocketgate/transaction.rb, line 45 def to_hash if is_referenced? { referenceGUID: reference_id, transactionType: type } else super end end
type=(new_type)
click to toggle source
# File lib/rocketgate/transaction.rb, line 53 def type=(new_type) new_type = TYPE[new_type] if TYPE.keys.include?(new_type) if TYPE.values.include?(new_type) @type = new_type else raise ValidationError.new("Unknown transaction type: #{new_type}") end end
valid?()
click to toggle source
Calls superclass method
# File lib/rocketgate/transaction.rb, line 75 def valid? is_referenced? || is_hashed? || super end