Class: RocketGate::Transaction
- Inherits:
-
Object
- Object
- RocketGate::Transaction
- Extended by:
- Forwardable
- Includes:
- Hashable, Validatable
- Defined in:
- lib/rocketgate/transaction.rb
Constant Summary collapse
- TYPE =
{ auth: 'CC_AUTH', confirmation: 'CC_CONFIRM', credit: 'CC_CREDIT', purchase: 'CC_PURCHASE', rebill_cancel: 'REBILL_CANCEL', rebill_update: 'REBILL_UPDATE', scrub: 'CARDSCRUB', ticket: 'CC_TICKET', void: 'CC_VOID' }
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#credit_card ⇒ Object
Returns the value of attribute credit_card.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#id ⇒ Object
Returns the value of attribute id.
-
#reference_id ⇒ Object
Returns the value of attribute reference_id.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Transaction
constructor
A new instance of Transaction.
- #is_hashed? ⇒ Boolean
- #is_referenced? ⇒ Boolean
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
Methods included from Hashable
Methods included from Validatable
included, #invalid_attributes, #validate!
Constructor Details
#initialize(*args) ⇒ Transaction
Returns a new instance of Transaction.
33 34 35 |
# File 'lib/rocketgate/transaction.rb', line 33 def initialize(*args) @amount, @customer, @credit_card, @currency, @id = *args end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def amount @amount end |
#credit_card ⇒ Object
Returns the value of attribute credit_card.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def credit_card @credit_card end |
#currency ⇒ Object
Returns the value of attribute currency.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def customer @customer end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def id @id end |
#reference_id ⇒ Object
Returns the value of attribute reference_id.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def reference_id @reference_id end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/rocketgate/transaction.rb', line 6 def type @type end |
Instance Method Details
#is_hashed? ⇒ Boolean
67 68 69 |
# File 'lib/rocketgate/transaction.rb', line 67 def is_hashed? credit_card && !credit_card.card_hash.nil? end |
#is_referenced? ⇒ Boolean
71 72 73 |
# File 'lib/rocketgate/transaction.rb', line 71 def is_referenced? [ TYPE[:confirmation], TYPE[:ticket], TYPE[:void] ].include?(type) && !reference_id.nil? end |
#to_hash ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rocketgate/transaction.rb', line 45 def to_hash if is_referenced? { referenceGUID: reference_id, transactionType: type } else super end end |
#valid? ⇒ Boolean
75 76 77 |
# File 'lib/rocketgate/transaction.rb', line 75 def valid? is_referenced? || is_hashed? || super end |