Class: SecureTrading::Requests::TDSQuery

Inherits:
SecureTrading::Request show all
Defined in:
lib/secure_trading/requests/tds_query.rb

Instance Attribute Summary collapse

Attributes inherited from SecureTrading::Request

#connection, #response

Instance Method Summary collapse

Methods inherited from SecureTrading::Request

#error_message, #initialize, #process, #sanitized_xml_request, #xml_request

Constructor Details

This class inherits a constructor from SecureTrading::Request

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def currency
  @currency
end

#merchant_nameObject

Returns the value of attribute merchant_name.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def merchant_name
  @merchant_name
end

#orderObject

Returns the value of attribute order.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def order
  @order
end

#payment_methodObject

Returns the value of attribute payment_method.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def payment_method
  @payment_method
end

#term_urlObject

Returns the value of attribute term_url.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def term_url
  @term_url
end

#user_agentObject

Returns the value of attribute user_agent.



5
6
7
# File 'lib/secure_trading/requests/tds_query.rb', line 5

def user_agent
  @user_agent
end

Instance Method Details

#enrollment_statusObject



42
43
44
# File 'lib/secure_trading/requests/tds_query.rb', line 42

def enrollment_status
  self.response.operation_response['Enrolled']
end

#invalid_details?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/secure_trading/requests/tds_query.rb', line 26

def invalid_details?
  ## This can actually mean quite a few other things but for now we're assuming the card details are invalid
  ## as this is the most likely cause for result 0
  self.response.result == 0
end

#is_enrolled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/secure_trading/requests/tds_query.rb', line 38

def is_enrolled?
  self.response.operation_response['Enrolled'].upcase == 'Y'
end

#request_3d_auth?Boolean

Should we perform a 3d auth for this card?

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/secure_trading/requests/tds_query.rb', line 33

def request_3d_auth?
  return false if self.response.result == 2
  self.response.result == 1 && ['Y', 'N', 'U'].include?(self.response.operation_response['Enrolled'])
end

#request_typeObject



7
8
9
# File 'lib/secure_trading/requests/tds_query.rb', line 7

def request_type
  'ST3DCARDQUERY'
end

#to_hashObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/secure_trading/requests/tds_query.rb', line 11

def to_hash
  {
    'Operation' => {
                      'SiteReference' => self.connection.site_reference, 
                      'Amount' => self.amount, 
                      'Currency' => self.currency || 'GBP', 
                      'TermUrl' => self.term_url,
                      'MerchantName' => self.merchant_name
                    },
    'CustomerInfo' => self.user_agent,
    'PaymentMethod' => {'CreditCard' => self.payment_method },
    'Order' => self.order
  }
end