class Geti::AppClient

Constants

MERCHANT_OWNERSHIP
MERCHANT_SERVICE_TYPES
MERCHANT_TYPES

Public Instance Methods

board_merchant_ach(application) click to toggle source
# File lib/geti/app_client.rb, line 153
def board_merchant_ach(application)
  response = soap_request("BoardCertificationMerchant_ACH", "board_certification_merchant_ach") do
    data_packet { |xml| data(xml, application) }
  end
  annotate_response(response[:response])
end
comments(opts) click to toggle source
# File lib/geti/app_client.rb, line 286
def comments(opts)
  [taxpayer_info(opts), ip_address(opts), email_address(opts)].compact.join(', ')
end
data(xml, opts) click to toggle source
# File lib/geti/app_client.rb, line 176
def data(xml, opts)
  opts = filter_invalid_characters(opts)
  filename = "%s_%s.xml" % [opts[:id].to_s, Time.now.strftime("%d_%b_%Y_%H_%M_%S")]
  xml.Envelope do
    xml.Body :FileName => filename, :FileDate => Time.now.iso8601 do
      xml.NewMerchant({
        :isoID              => opts[:iso_id] || "9999",
        :merchCrossRefID    => opts[:id],
        :merchName          => opts[:name], # Legal Name
        :merchTypeID        => MERCHANT_TYPES.index(opts[:industry]), # "Type of goods sold"
        :merchServiceType   => opts[:service_type] || "GOLD",
        # TODO: Tax ID
        :merchAddress1      => opts[:address], # TODO: Is this mailing or DBA address?
        :merchCity          => opts[:city],
        :merchState         => opts[:state],
        :merchZip           => opts[:zip],
        :merchPhone         => opts[:phone],
        # TODO: Fax number
        :merchAchFlatFee    => "",
        :merchNonAchFlatFee => "",
        :merchPercentFee    => "",
        :merchComments      => comments(opts),
        :merchReturnFee     => "",
        # TODO: Web Address
        # TODO: Email address
      }) do
        xml.BusinessInfo({
          :merchOwnership => merchant_ownership(opts),
          :merchAvgCheckAmount => opts[:average_amount],
          :merchMaxCheckAmount => opts[:max_amount],
          :merchTotalTimeInBusiness => opts[:days_in_business],
        })
        xml.NewLocation({
          :locName           => opts[:name], # DBA name?
          :locCrossRefID     => opts[:id],
          :locAddress1       => opts[:physical_address], # TODO: Is this mailing or DBA address?
          :locCity           => opts[:physical_city],
          :locState          => opts[:physical_state],
          :locZip            => opts[:physical_zip],
          :locPhone          => opts[:physical_phone],
          :locStatementFee   => "0",
          :locMinimumFee     => "0",
          :locFeesRoutingNum => opts[:routing_number],
          :locFeesAccountNum => opts[:account_number],
          # TODO: Days in operation at this location?
        }) do
          xml.Statement({
            :locStatementAttn     => opts[:contact_name], # TODO: Where does title/alternate go?
            :locStatementAddress1 => opts[:physical_address], # TODO: Is this mailing or DBA address?
            :locStatementCity     => opts[:physical_city],
            :locStatementState    => opts[:physical_state],
            :locStatementZip      => opts[:physical_zip],
          })
          xml.NewPOC({
            :pocFirstName => opts[:principal_first_name],
            :pocLastName  => opts[:principal_last_name],
            :pocTitle     => opts[:principal_title],
            # TODO: % Ownership
            :pocAddress   => opts[:principal_address], # TODO: Is this mailing or DBA address?
            :pocCity      => opts[:principal_city],
            :pocState     => opts[:principal_state],
            :pocZip       => opts[:principal_zip],
            :pocDOB       => opts[:principal_dob], # Y-M-D
            :pocSSN       => opts[:principal_ssn], # 9-digits?
            # TODO: Driver's License

            :pocPrimary => "1",
            :pocComments => "",
          })
          xml.NewTerminal({
            :termCrossRefID       => opts[:id],
            :termCheckLimit       => "500.00",
            :termPeripheral       => "63",
            :termTypeID           => "660",
            :termVerificationOnly => "0",
          })
          # More NewTerminal entries
        end
      end
    end
  end
end
email_address(opts) click to toggle source
# File lib/geti/app_client.rb, line 290
def email_address(opts)
  return unless opts[:email]
  "Email: %s" % opts[:email]
end
filter_invalid_characters(opts) click to toggle source
# File lib/geti/app_client.rb, line 259
def filter_invalid_characters(opts)
  opts = opts.dup
  opts[:address].gsub!(/[^a-zA-Z0-9 #-:;']/, '') if opts[:address]
  opts[:physical_address].gsub!(/[^a-zA-Z0-9 #-:;']/, '') if opts[:physical_address]
  opts[:principal_address].gsub!(/[^a-zA-Z0-9 #-:;']/, '') if opts[:principal_address]

  opts[:city].gsub!(/[^a-zA-Z0-9 ]/, '') if opts[:city]
  opts[:physical_city].gsub!(/[^a-zA-Z0-9 ]/, '') if opts[:physical_city]
  opts[:principal_city].gsub!(/[^a-zA-Z0-9 ]/, '') if opts[:principal_city]

  opts[:principal_ssn].gsub!(/[^0-9]/, '') if opts[:principal_ssn]
  opts
end
ip_address(opts) click to toggle source
# File lib/geti/app_client.rb, line 295
def ip_address(opts)
  return unless opts[:ip]
  "Signup IP: %s" % opts[:ip]
end
merchant_ownership(opts) click to toggle source
# File lib/geti/app_client.rb, line 300
def merchant_ownership(opts)
  MERCHANT_OWNERSHIP.index((opts[:business_type]||'').gsub('_', ' '))
end
retrieve_merchant_status(id) click to toggle source
# File lib/geti/app_client.rb, line 160
def retrieve_merchant_status(id)
  response = soap_request("RetrieveCertificationMerchantStatus") do
    {'MerchantID' => id}
  end
  annotate_response(response[:response])
end
service_address() click to toggle source
# File lib/geti/app_client.rb, line 273
def service_address
  "https://#{domain}/webservices/AppGateway.asmx?WSDL"
end
soap_header() click to toggle source
# File lib/geti/app_client.rb, line 277
def soap_header
  { "RemoteAccessHeader" => {
      "UserName" => @user,
      "Password" => @pass
    },
    :attributes! => { "RemoteAccessHeader" => {"xmlns"=>"http://tempuri.org/GETI.eMagnus.WebServices/AppGateway"}}
  }
end
taxpayer_info(opts) click to toggle source
# File lib/geti/app_client.rb, line 304
def taxpayer_info(opts)
  if merchant_ownership(opts) == '3' # Sole Proprietorship
    ["Tax Info: #{opts[:taxpayer_name]}", opts[:taxpayer_id], "SSN: #{opts[:principal_ssn]}"]
  else
    ["Tax Info: #{opts[:taxpayer_name]}", opts[:taxpayer_id]]
  end.join(" - ")
end
upload_supporting_docs(id, filedata) click to toggle source
# File lib/geti/app_client.rb, line 167
def upload_supporting_docs(id, filedata)
  response = soap_request("UploadCertificationSupportingDocs") do
    { 'MerchantID' => id,
      'DataPacket' => Base64.encode64(filedata)
    }
  end
  annotate_response(response[:response])
end

Private Instance Methods

annotate_response(response) click to toggle source
# File lib/geti/app_client.rb, line 313
def annotate_response(response)
  response[:success] = response[:validation_message][:result] == "Passed"
  response.delete(:"@xmlns:xsd")
  response.delete(:"@xmlns:xsi")
  remove_key_at_signs!(response)
  response
end
remove_key_at_signs!(hash) click to toggle source
# File lib/geti/app_client.rb, line 321
def remove_key_at_signs!(hash)
  hash.keys.each do |key|
    if hash[key].kind_of? Hash
      remove_key_at_signs!(hash[key])
    end
    if key.to_s[0..0] == '@'
      hash[key.to_s.sub('@','').to_sym] = hash.delete(key)
    end
  end
end