Class: PayXML::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/payxml/message.rb

Overview

This class represents the base class for all XML message payloads used for the PayXML API.

Direct Known Subclasses

Auth::Request, Auth::Response, Error

Constant Summary collapse

PAYXML_VERSION_NUMBER =
'4.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paygate_id, paygate_password) ⇒ Message

Returns a new instance of Message.



13
14
15
16
# File 'lib/payxml/message.rb', line 13

def initialize( paygate_id, paygate_password )
  self.paygate_id = paygate_id
  self.paygate_password = paygate_password
end

Instance Attribute Details

#paygate_idObject

Returns the value of attribute paygate_id.



8
9
10
# File 'lib/payxml/message.rb', line 8

def paygate_id
  @paygate_id
end

#paygate_passwordObject

Returns the value of attribute paygate_password.



9
10
11
# File 'lib/payxml/message.rb', line 9

def paygate_password
  @paygate_password
end

Instance Method Details

#parse(xml_string) ⇒ Object



18
19
20
21
22
23
# File 'lib/payxml/message.rb', line 18

def parse(xml_string)
  doc = Nokogiri::XML(xml_string)
  protocol = doc.xpath("//protocol").first
  self.paygate_id = protocol['pgid']
  self.paygate_password = protocol['pwd']
end

#xml_stringObject



25
26
27
# File 'lib/payxml/message.rb', line 25

def xml_string
  xml_doc.to_s
end