Class: Geti::AuthClient
Instance Method Summary collapse
- #data(xml, opts) ⇒ Object
-
#get_terminal_settings ⇒ Object
Loads terminal settings for the configured terminal.
- #identifier(name) ⇒ Object
-
#initialize(auth, terminal_opts, env = 'test') ⇒ AuthClient
constructor
A new instance of AuthClient.
-
#process(opts) ⇒ Object
Creates an authorization for funds transfer.
- #service_address ⇒ Object
- #soap_header ⇒ Object
- #terminal_id ⇒ Object
-
#validate(opts) ⇒ Object
Used to verify that an XML request is valid for use on the terminal.
Methods inherited from Client
#certification?, #data_packet, #domain, #soap_client, #soap_request, #xml_parser
Constructor Details
#initialize(auth, terminal_opts, env = 'test') ⇒ AuthClient
Returns a new instance of AuthClient.
2 3 4 5 6 7 8 9 |
# File 'lib/geti/auth_client.rb', line 2 def initialize(auth, terminal_opts, env='test') super @sec_code = terminal_opts[:sec_code] @verify_check = terminal_opts[:verify].include? :check @verify_id = terminal_opts[:verify].include? :identity @dl_required = terminal_opts[:verify].include? :dl end |
Instance Method Details
#data(xml, opts) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/geti/auth_client.rb', line 39 def data(xml, opts) xml.AUTH_GATEWAY do # has an optional REQUEST_ID attribute for later lookups xml.TRANSACTION do xml.TRANSACTION_ID xml.MERCHANT do xml.TERMINAL_ID terminal_id end xml.PACKET do xml.IDENTIFIER identifier(opts[:type]) xml.ACCOUNT do xml.ROUTING_NUMBER opts[:routing_number] xml.ACCOUNT_NUMBER opts[:account_number] xml.ACCOUNT_TYPE opts[:account_type] end xml.CONSUMER do xml.FIRST_NAME opts[:first_name] xml.LAST_NAME opts[:last_name] xml.ADDRESS1 xml.ADDRESS2 xml.CITY xml.STATE xml.ZIP xml.PHONE_NUMBER xml.DL_STATE xml.DL_NUMBER xml.COURTESY_CARD_ID if @verify_id xml.IDENTITY do xml.SSN4 xml.DOB_YEAR end end end xml.CHECK do xml.CHECK_AMOUNT("%.2d" % ((opts[:amount]||0)/100.0)) end end end end end |
#get_terminal_settings ⇒ Object
Loads terminal settings for the configured terminal. Returns a TerminalSettings object that can be used to confirm requested verification features, terminal ID, and XSD/XML templates.
14 15 16 |
# File 'lib/geti/auth_client.rb', line 14 def get_terminal_settings Geti::TerminalSettings.new(soap_request("GetCertificationTerminalSettings")) end |
#identifier(name) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/geti/auth_client.rb', line 80 def identifier(name) { :authorize => 'A', :void => 'V', :override => 'O', :payroll => 'P', :recurring => 'R' }[name] end |
#process(opts) ⇒ Object
Creates an authorization for funds transfer. Returns a Result with both validation and (if valid) authorization responses.
31 32 33 34 35 36 |
# File 'lib/geti/auth_client.rb', line 31 def process(opts) response = soap_request("ProcessSingleCertificationCheck") do data_packet { |xml| data(xml, opts) } end Geti::Response.new(response) end |
#service_address ⇒ Object
89 90 91 |
# File 'lib/geti/auth_client.rb', line 89 def service_address "https://#{domain}/webservices/AuthGateway.asmx?WSDL" end |
#soap_header ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/geti/auth_client.rb', line 93 def soap_header { "AuthGatewayHeader" => { "UserName" => @user, "Password" => @pass, "TerminalID" => terminal_id.to_s }, :attributes! => { 'AuthGatewayHeader' => {'xmlns'=>"http://tempuri.org/GETI.eMagnus.WebServices/AuthGateway"}} } end |
#terminal_id ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/geti/auth_client.rb', line 103 def terminal_id base = { # Guaranteed 'PPD' => 1010, # Debit-only 'POP' => 1110, 'TEL' => 1210, 'C21' => 1610, 'CCD' => 1710, # Debit only 'PPD_cr' => 1810, # Debit and Credit 'CCD_cr' => 1910, # Debit and Credit # Non-Guaranteed 'PPD_ng' => 2010, 'TEL_ng' => 2210, 'WEB' => 2310, # Web is always non-guaranteed 'CCD_ng' => 2710, 'PPD_ng_cr' => 2810, 'CCD_ng_cr' => 2910 }[@sec_code] offset = { [false, false, false] => 0, [true, false, false] => 1, [false, true, true ] => 2, [true, true, true ] => 3, [false, true, false] => 4, [true, true, false] => 5, [false, false, true ] => 6, [true, false, true ] => 7 }[[@dl_required, @verify_check, @verify_id]] base + offset end |
#validate(opts) ⇒ Object
Used to verify that an XML request is valid for use on the terminal. The returned Result will have a validation response but no authorization. NOTE: CERTIFICATION SERVER ONLY
22 23 24 25 26 27 |
# File 'lib/geti/auth_client.rb', line 22 def validate(opts) response = soap_request("AuthGatewayCertification") do data_packet { |xml| data(xml, opts) } end Geti::Response.new(response) end |