Class: Cardgate::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/cardgate/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Transaction

Returns a new instance of Transaction.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cardgate/transaction.rb', line 8

def initialize(attributes = {})
  attributes.map do |attribute, value|
    if attribute == 'customer' && !value.nil?
      attributes['customer'].map do |attribute, value|
        set_variable_from_attribute(attribute, value)
      end
    else
      set_variable_from_attribute(attribute, value)
    end
  end
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def address
  @address
end

#amountObject (readonly)

Returns the value of attribute amount.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def amount
  @amount
end

#cityObject (readonly)

Returns the value of attribute city.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def city
  @city
end

#company_nameObject (readonly)

Returns the value of attribute company_name.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def company_name
  @company_name
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def country_code
  @country_code
end

#currencyObject (readonly)

Returns the value of attribute currency.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def currency
  @currency
end

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def last_name
  @last_name
end

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def payment_method
  @payment_method
end

#phone_numberObject (readonly)

Returns the value of attribute phone_number.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def phone_number
  @phone_number
end

#postal_codeObject (readonly)

Returns the value of attribute postal_code.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def postal_code
  @postal_code
end

#refObject (readonly)

Returns the value of attribute ref.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def ref
  @ref
end

#site_idObject (readonly)

Returns the value of attribute site_id.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def site_id
  @site_id
end

#site_nameObject (readonly)

Returns the value of attribute site_name.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def site_name
  @site_name
end

#stateObject (readonly)

Returns the value of attribute state.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def state
  @state
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def timestamp
  @timestamp
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



5
6
7
# File 'lib/cardgate/transaction.rb', line 5

def transaction_id
  @transaction_id
end

Instance Method Details

#successful?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/cardgate/transaction.rb', line 20

def successful?
  [200, 210].include?(self.status.to_i)
end