Permalink
Browse files

make changes to allow active merchant to not use the configuration

object, and instead pass all options in.
  • Loading branch information...
1 parent be24770 commit b24f3c939a9295ce2787958bc441a7fc40523cb7 @GregDake GregDake committed Mar 2, 2012
Showing with 29 additions and 10 deletions.
  1. +3 −4 lib/Communications.rb
  2. +1 −1 lib/Configuration.rb
  3. +25 −3 lib/LitleOnlineRequest.rb
  4. +0 −2 test/functional/test_sale.rb
@@ -33,12 +33,11 @@ class Communications
##For http or https post with or without a proxy
def Communications.http_post(post_data,config_hash)
- #setup optional proxy
- proxy_addr = (config_hash['proxy_addr'] or nil)
- proxy_port = ((config_hash['proxy_port']).to_i or nil)
+ proxy_addr = config_hash['proxy_addr']
+ proxy_port = config_hash['proxy_port']
+ litle_url = config_hash['url']
# setup https or http post
- litle_url = (config_hash['url'] or 'https://cert.litle.com/vap/communicator/online')
uri = URI.parse(litle_url)
http_post = Net::HTTP::Post.new(uri.request_uri)
@@ -38,7 +38,7 @@ def config
end
return YAML.load_file(config_file)
rescue
- raise 'Cannot find the configuration file, ' + config_file + ', Please run Setup.rb first'
+ return {}
end
end
@@ -372,9 +372,21 @@ def get_report_group(hash_in)
end
def authentication(hash_in)
+ if(hash_in['user'] == nil)
+ user = @config_hash['user']
+ else
+ user = hash_in['user']
+ end
+
+ if(hash_in['password'] == nil)
+ password = @config_hash['password']
+ else
+ password = hash_in['password']
+ end
+
hash_out = {
- :user =>required_field(@config_hash['user']),
- :password =>required_field(@config_hash['password'])
+ :user =>required_field(user),
+ :password =>required_field(password)
}
Checker.required_missing(hash_out)
end
@@ -388,8 +400,14 @@ def optional_field(value)
end
def build_full_hash(hash_in, merge_hash)
+ if(hash_in['version'] == nil)
+ version = @config_hash['version']
+ else
+ version = hash_in['version']
+ end
+
litle_online_hash = {
- "@version"=> required_field(@config_hash['version']),
+ "@version"=> required_field(version),
"@xmlns"=> "http://www.litle.com/schema",
"@merchantId"=> get_merchant_id(hash_in),
:authentication => authentication(hash_in)
@@ -398,6 +416,10 @@ def build_full_hash(hash_in, merge_hash)
end
def get_common_attributes(hash_in)
+ @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
+ @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
+ @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
+
return {
'@id' => hash_in['id'],
'@customerId' => hash_in['customerId'],
@@ -177,8 +177,6 @@ def test_invalid_embedded_field_values
def test_simple_sale_with_card
hash = {
'merchantId'=>'101',
- 'proxy_addr' => '10.1.2.254',
- 'proxy_port' => '8080',
'version'=>'8.8',
'reportGroup'=>'Planets',
'litleTxnId'=>'123456',

0 comments on commit b24f3c9

Please sign in to comment.