Class: SecureTrading::Request
- Inherits:
-
Object
- Object
- SecureTrading::Request
- Defined in:
- lib/secure_trading/request.rb
Direct Known Subclasses
SecureTrading::Requests::Authorisation, SecureTrading::Requests::AuthorisationReversal, SecureTrading::Requests::Refund, SecureTrading::Requests::Settlement, SecureTrading::Requests::TDSQuery, SecureTrading::Requests::TransactionQuery
Defined Under Namespace
Classes: ConnectionFailed, ConnectionTimeout, PrematureXpayQuery
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#error_message ⇒ Object
Returns the error message provided from Xpay.
-
#initialize(connection) ⇒ Request
constructor
A new instance of Request.
-
#process ⇒ Object
Send the XML request, using the provided connection.
-
#sanitized_xml_request ⇒ Object
Return a sanitized version of the xml request for storing in a data store.
-
#xml_request ⇒ Object
Return the full XML request for this request.
Constructor Details
#initialize(connection) ⇒ Request
Returns a new instance of Request.
11 12 13 |
# File 'lib/secure_trading/request.rb', line 11 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
8 9 10 |
# File 'lib/secure_trading/request.rb', line 8 def connection @connection end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/secure_trading/request.rb', line 9 def response @response end |
Instance Method Details
#error_message ⇒ Object
Returns the error message provided from Xpay
22 23 24 |
# File 'lib/secure_trading/request.rb', line 22 def @error_message end |
#process ⇒ Object
Send the XML request, using the provided connection.
16 17 18 19 |
# File 'lib/secure_trading/request.rb', line 16 def process post_to_xpay! self.response.success? end |
#sanitized_xml_request ⇒ Object
Return a sanitized version of the xml request for storing in a data store. Sensitive card numbers and security codes will be replaced with asterisks and the certificate will be removed.
37 38 39 40 41 42 43 44 |
# File 'lib/secure_trading/request.rb', line 37 def sanitized_xml_request xml = xml_request.dup %w{ Number SecurityCode }.each do |field| xml.gsub!(/\<#{field}\>(.+)\<\/#{field}\>/) { "<#{field}>" + ('*' * $1.size) + "</#{field}>" } end xml.gsub!(/\<Certificate\>(.*)\<\/Certificate\>/m, '<Certificate>{FILTERED}</Certificate>') xml end |
#xml_request ⇒ Object
Return the full XML request for this request. The full output from this method should be sent to the secure trading Xpay API.
28 29 30 31 32 33 |
# File 'lib/secure_trading/request.rb', line 28 def xml_request attributes = {} attributes['RequestBlock'] = {'Version' => SECURETRADING_API_VERSION} attributes['Request'] = {'Type' => self.request_type} @xml_request ||= Util.to_xml({'Request' => self.to_hash, 'Certificate' => self.connection.certificate}, :root => 'RequestBlock', :attributes => attributes) end |