Class: VirtualMerchant::Communication

Inherits:
Object
  • Object
show all
Defined in:
lib/virtual_merchant/communication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Communication

Returns a new instance of Communication.



8
9
10
11
12
13
# File 'lib/virtual_merchant/communication.rb', line 8

def initialize(data)
  @xml = data[:xml]
  @url = data[:url]
  @uri = URI.parse(@url)
  @http_referer = data[:http_referer]
end

Instance Attribute Details

#http_refererObject

Returns the value of attribute http_referer.



6
7
8
# File 'lib/virtual_merchant/communication.rb', line 6

def http_referer
  @http_referer
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/virtual_merchant/communication.rb', line 6

def uri
  @uri
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/virtual_merchant/communication.rb', line 6

def url
  @url
end

#xmlObject

Returns the value of attribute xml.



6
7
8
# File 'lib/virtual_merchant/communication.rb', line 6

def xml
  @xml
end

Instance Method Details

#sendObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/virtual_merchant/communication.rb', line 15

def send
  http = Net::HTTP.new(@uri.host, @uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  begin
    http.post(uri.request_uri, xml, header).body
  rescue Exception => e
    false
  end
end