lib/pxpay/notification.rb in pxpay-0.1.0 vs lib/pxpay/notification.rb in pxpay-0.1.1
- old
+ new
@@ -1,21 +1,28 @@
module Pxpay
+ # The return notification from Payment Express
class Notification
mattr_accessor :order_details
- attr_accessor :hash, :xml
+ attr_accessor :response
def initialize(response)
- @hash = parse(response)
- @xml = response
+ @response = response
end
-
- def parse(response)
+
+ # Return the xml response
+ def to_xml
+ response
+ end
+
+ # Return the response as a hash
+ def to_hash
require 'nokogiri'
- doc = Nokogiri::XML(response)
+ doc = Nokogiri::XML(self.response)
hash = {}
doc.at_css("Response").element_children.each do |attribute|
- hash[attribute.name.underscore.to_sym] = attribute.inner_text# if ::Pxpay::Base.return_details.include?(attribute.name)
+ hash[attribute.name.underscore.to_sym] = attribute.inner_text
end
+ hash[:valid] = doc.at_css("Response")['valid']
hash
end
end
end
\ No newline at end of file