class Orbital::Gateway::Api

Constants

CURRENCY_CODES
CURRENCY_EXPONENTS

Public Class Methods

new(options = {}) click to toggle source
# File lib/orbital/gateway/api.rb, line 30
def initialize(options = {})
end

Public Instance Methods

api_version() click to toggle source
# File lib/orbital/gateway/api.rb, line 8
def api_version
  ENV.fetch("ORBITAL_GATEWAY_API_VERSION", "7.4")
end
orbital_connection_id() click to toggle source
# File lib/orbital/gateway/api.rb, line 16
def orbital_connection_id
  ENV.fetch("ORBITAL_CONNECTION_ID", "not-configured")
end
orbital_connection_password() click to toggle source
# File lib/orbital/gateway/api.rb, line 20
def orbital_connection_password
  ENV.fetch("ORBITAL_CONNECTION_PASSWORD", "not-configured")
end
orbital_merchant_id() click to toggle source
# File lib/orbital/gateway/api.rb, line 12
def orbital_merchant_id
  ENV.fetch("ORBITAL_MERCHANT_ID", "not-configured")
end
post(body, trace_number=nil) click to toggle source
# File lib/orbital/gateway/api.rb, line 33
def post(body, trace_number=nil)
  response = self.class.post(url_endpoint, body: body, timeout: 30, headers: modify_headers(body.size.to_s, trace_number))
end
set_bin() click to toggle source
# File lib/orbital/gateway/api.rb, line 24
def set_bin
  ENV.fetch("ORBITAL_BIN", "stratus")
end
url_endpoint() click to toggle source
# File lib/orbital/gateway/api.rb, line 4
def url_endpoint
  ENV.fetch("ORBITAL_GATEWAY_BASE_URL", "https://orbitalvar1.chasepaymentech.com/authorize")
end

Private Instance Methods

add_bin_merchant_and_terminal(xml) click to toggle source
# File lib/orbital/gateway/api.rb, line 86
def add_bin_merchant_and_terminal(xml)
  xml.tag! :BIN, bin
  xml.tag! :MerchantID, orbital_merchant_id
  xml.tag! :TerminalID, '001'
end
add_xml_credentials(xml) click to toggle source
# File lib/orbital/gateway/api.rb, line 81
def add_xml_credentials(xml)
  xml.tag! :OrbitalConnectionUsername, orbital_connection_id
  xml.tag! :OrbitalConnectionPassword, orbital_connection_password
end
base_request() click to toggle source
# File lib/orbital/gateway/api.rb, line 65
def base_request
  xml = xml_envelope
  xml.tag! :Request do
    xml.tag! :NewOrder do
      add_xml_credentials(xml)
      add_bin_merchant_and_terminal(xml)
    end
  end
end
bin() click to toggle source
# File lib/orbital/gateway/api.rb, line 57
def bin
  available_bins = {
    'stratus' => '000001',
    'pns'     => '000002'
  }
  available_bins[set_bin]
end
headers() click to toggle source
# File lib/orbital/gateway/api.rb, line 46
def headers
  {
    'MIME-Version' => '1.1',
    'Content-Type' => "application/PTI#{api_version.gsub(/\./, '')}",
    'Content-Transfer-Encoding' => 'text',
    'Request-Number' => '1',
    'Document-Type' => 'Request',
    'Interface-Version' => 'Ruby|Orbital Gateway'
  }
end
modify_headers(size, trace_number=nil) click to toggle source
# File lib/orbital/gateway/api.rb, line 39
def modify_headers(size, trace_number=nil)
  head = headers
  head.merge!('Trace-Number' => trace_number.to_s,
                 'Merchant-Id'  => orbital_merchant_id) if trace_number
  head
end
xml_envelope() click to toggle source
# File lib/orbital/gateway/api.rb, line 75
def xml_envelope
  xml = Builder::XmlMarkup.new(:indent => 2)
  xml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')
  xml
end