class AuthorizeNet::API::ApiTransaction
Public Class Methods
new(api_login_id = nil, api_transaction_key = nil, options = {})
click to toggle source
Calls superclass method
AuthorizeNet::XmlTransaction::new
# File lib/authorize_net/api/api_transaction.rb, line 57 def initialize(api_login_id = nil, api_transaction_key = nil, options = {}) super end
Public Instance Methods
deserialize(xml,responseClass)
click to toggle source
# File lib/authorize_net/api/api_transaction.rb, line 119 def deserialize(xml,responseClass) responseClass.from_xml(xml) end
make_request(request,responseClass,type)
click to toggle source
# File lib/authorize_net/api/api_transaction.rb, line 65 def make_request(request,responseClass,type) setOAuthOptions() unless responseClass.nil? or request.nil? begin @xml = serialize(request,type) respXml = send_request(@xml) @response = deserialize(respXml.body,responseClass) rescue Exception => ex ex end end end
send_request(xml)
click to toggle source
# File lib/authorize_net/api/api_transaction.rb, line 102 def send_request(xml) url = URI.parse(@gateway) httpRequest = Net::HTTP::Post.new(url.path) httpRequest.content_type = 'text/xml' httpRequest.body = xml connection = Net::HTTP.new(url.host, url.port) connection.use_ssl = true if @verify_ssl connection.verify_mode = OpenSSL::SSL::VERIFY_PEER else connection.verify_mode = OpenSSL::SSL::VERIFY_NONE end response = connection.start {|http| http.request(httpRequest)} end
serialize(object,type)
click to toggle source
# File lib/authorize_net/api/api_transaction.rb, line 78 def serialize(object,type) doc = Nokogiri::XML::Document.new doc.root = object.to_xml constants = YAML.load_file(File.dirname(__FILE__) + "/constants.yml") clientId = constants['clientId'] builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |x| x.send(type.to_sym, :xmlns => XML_NAMESPACE) { x.merchantAuthentication { if !@access_token.blank? x.accessToken @access_token end if !@api_login_id.blank? || (@access_token.blank? && @api_login_id.blank?) x.name @api_login_id x.transactionKey @api_transaction_key end } x.clientId clientId x.send:insert, doc.root.element_children } end builder.to_xml end
setOAuthOptions()
click to toggle source
Calls superclass method
AuthorizeNet::XmlTransaction#setOAuthOptions
# File lib/authorize_net/api/api_transaction.rb, line 61 def setOAuthOptions() super end