class Spreedly::GatewayTransaction
Attributes
gateway_specific_fields[R]
gateway_specific_response_fields[R]
response[R]
shipping_address[R]
Public Class Methods
new(xml_doc)
click to toggle source
Calls superclass method
# File lib/spreedly/transactions/gateway_transaction.rb, line 9 def initialize(xml_doc) super response_xml_doc = xml_doc.at_xpath('.//response') shipping_address_xml_doc = xml_doc.at_xpath('.//shipping_address') @response = response_xml_doc ? Response.new(response_xml_doc) : nil @shipping_address = shipping_address_xml_doc ? ShippingAddress.new(shipping_address_xml_doc) : nil @gateway_specific_fields = parse_gateway_fields(xml_doc, './/gateway_specific_fields') @gateway_specific_response_fields = parse_gateway_fields(xml_doc, './/gateway_specific_response_fields') end
Public Instance Methods
parse_gateway_fields(xml_doc, path)
click to toggle source
# File lib/spreedly/transactions/gateway_transaction.rb, line 19 def parse_gateway_fields(xml_doc, path) result = {} xml_doc.at_xpath(path).xpath('*').each do |node| node_name = node.name.to_sym if (node.elements.empty?) result[node_name] = node.text else node.elements.each do |childnode| result[node_name] ||= {} result[node_name][childnode.name.to_sym] = childnode.text end end end result end