Class: Pxpay::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/pxpay/notification.rb

Overview

The return notification from Payment Express

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/pxpay/notification.rb', line 5

def response
  @response
end

Instance Method Details

#to_hashObject

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_xmlObject

Return the xml response



12
13
14
# File 'lib/pxpay/notification.rb', line 12

def to_xml
  response
end