Class: Pxpay::Notification
- Inherits:
-
Object
- Object
- Pxpay::Notification
- Defined in:
- lib/pxpay/notification.rb
Overview
The return notification from Payment Express
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Notification
constructor
Create a new Notification from Payment Express’ response.
-
#to_hash ⇒ Object
Return the response as a hash.
-
#to_xml ⇒ Object
Return the xml response.
Constructor Details
#initialize(response) ⇒ Notification
Create a new Notification from Payment Express’ response
7 8 9 |
# File 'lib/pxpay/notification.rb', line 7 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/pxpay/notification.rb', line 5 def response @response end |
Instance Method Details
#to_hash ⇒ Object
Return the response as a hash
17 18 19 20 21 22 23 24 25 |
# File 'lib/pxpay/notification.rb', line 17 def to_hash doc = ::Nokogiri::XML( self.response ) hash = {} doc.at_css("Response").element_children.each do |attribute| hash[attribute.name.underscore.to_sym] = attribute.inner_text end hash[:valid] = doc.at_css("Response")['valid'] hash end |
#to_xml ⇒ Object
Return the xml response
12 13 14 |
# File 'lib/pxpay/notification.rb', line 12 def to_xml response end |