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 59 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 125 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 67 def make_request(request, responseClass, type) setOAuthOptions unless responseClass.nil? || request.nil? begin @xml = serialize(request, type) LogHelper.log.debug(@xml) respXml = send_request(@xml) @response = deserialize(respXml.body, responseClass) LogHelper.log.debug(respXml.body) return @response rescue Exception => ex LogHelper.log.error(ex.message) ex.backtrace.each {|line| LogHelper.log.error(line)} ex end end end
send_request(xml)
click to toggle source
# File lib/authorize_net/api/api_transaction.rb, line 108 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 85 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) do x.merchantAuthentication do x.accessToken @access_token unless @access_token.blank? if !@api_login_id.blank? || (@access_token.blank? && @api_login_id.blank?) x.name @api_login_id x.transactionKey @api_transaction_key end end x.clientId clientId x.send :insert, doc.root.element_children end 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 63 def setOAuthOptions super end