Sha256: a7d64c64167909d086109ebcbfc1b6d67e25118f618e672b0ca97800bb2286dd

Contents?: true

Size: 653 Bytes

Versions: 1

Compression:

Stored size: 653 Bytes

Contents

module Pxpay
  # The return notification from Payment Express 
  class Notification
    mattr_accessor :order_details
    attr_accessor :response
  
    def initialize(response)
      @response = response
    end
    
    # Return the xml response
    def to_xml
      response
    end 
    
    # Return the response as a hash
    def to_hash
      require 'nokogiri'
      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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pxpay-0.1.1 lib/pxpay/notification.rb