Skip to content

Commit

Permalink
making changes to support 8.12 schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory,Dake committed Apr 16, 2012
1 parent 53ad54b commit 754ddf6
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
s.description = File.read(File.join(File.dirname(__FILE__), 'DESCRIPTION'))
s.requirements =
[ 'Contact sdksupport@litle.com for more information' ]
s.version = "8.10.3"
s.version = "8.12.0"
s.author = "Litle & Co"
s.email = "sdksupport@litle.com"
s.homepage = "http://www.litle.com/developers"
Expand Down
16 changes: 13 additions & 3 deletions lib/LitleOnlineRequest.rb
Expand Up @@ -64,7 +64,7 @@ def authorization(hash_in)
:allowPartialAuth=>hash_in['allowPartialAuth'],
:healthcareIIAS=>XMLFields.healthcare_iias(optional_field(hash_in['healthcareIIAS'])),
:filtering=>XMLFields.filtering_type(optional_field(hash_in['filtering'])),
:merchantData=>XMLFields.filtering_type(optional_field(hash_in['merchantData'])),
:merchantData=>XMLFields.merchant_data(optional_field(hash_in['merchantData'])),
:recyclingRequest=>XMLFields.recycling_request_type(optional_field(hash_in['recyclingRequest']))
}
end
Expand Down Expand Up @@ -108,7 +108,7 @@ def sale(hash_in)
:allowPartialAuth=>hash_in['allowPartialAuth'],
:healthcareIIAS=>XMLFields.healthcare_iias(optional_field(hash_in['healthcareIIAS'])),
:filtering=>XMLFields.filtering_type(optional_field(hash_in['filtering'])),
:merchantData=>XMLFields.filtering_type(optional_field(hash_in['merchantData'])),
:merchantData=>XMLFields.merchant_data(optional_field(hash_in['merchantData'])),
:recyclingRequest=>XMLFields.recycling_request_type(optional_field(hash_in['recyclingRequest']))
}
hash_out.merge!(get_common_attributes(hash_in))
Expand Down Expand Up @@ -156,7 +156,8 @@ def credit(hash_in)
:processingInstructions=>XMLFields.processing_instructions(optional_field(hash_in['processingInstructions'])),
:pos=>XMLFields.pos(optional_field(hash_in['pos'])),
:amexAggregatorData=>XMLFields.amex_aggregator_data(optional_field(hash_in['amexAggregatorData'])),
:payPalNotes =>hash_in['payPalNotes']
:payPalNotes =>hash_in['payPalNotes'],
:actionReason=>hash_in['actionReason']
}
hash_out.merge!(get_common_attributes(hash_in))
Checker.purge_null(hash_out)
Expand Down Expand Up @@ -362,6 +363,14 @@ def get_merchant_id(hash_in)
return hash_in['merchantId']
end
end

def get_merchant_sdk(hash_in)
if(hash_in['merchantSdk'] == nil)
return 'Ruby;8.12.0'
else
return hash_in['merchantSdk']
end
end

def get_report_group(hash_in)
if (hash_in['reportGroup'] == nil)
Expand Down Expand Up @@ -410,6 +419,7 @@ def build_full_hash(hash_in, merge_hash)
"@version"=> required_field(version),
"@xmlns"=> "http://www.litle.com/schema",
"@merchantId"=> get_merchant_id(hash_in),
"@merchantSdk"=> get_merchant_sdk(hash_in),
:authentication => authentication(hash_in)
}
return litle_online_hash.merge(merge_hash)
Expand Down
11 changes: 11 additions & 0 deletions lib/XMLFields.rb
Expand Up @@ -341,6 +341,17 @@ def XMLFields.filtering_type(hash_in)
Checker.required_missing(hash_out)
return hash_out
end

def XMLFields.merchant_data(hash_in)
hash_out = {
:campaign=>hash_in['campaign'],
:affiliate=>hash_in['affiliate'],
:merchnatGroupingId=>hash_in['merchantGroupingIdType']
}
Checker.purge_null(hash_out)
Checker.required_missing(hash_out)
return hash_out
end

def XMLFields.echeck_type(hash_in)
hash_out= {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_LitleOnlineRequest.rb
Expand Up @@ -294,4 +294,13 @@ def test_ssn_optional
assert_nothing_raised {LitleOnlineRequest.new.authorization(start_hash.merge({'customerInfo'=>{'ssn'=>'000112222'} }))}
end

def test_set_merchant_sdk
litle = LitleOnlineRequest.new
#Explicit - used for integrations
assert_equal 'ActiveMerchant;3.2', litle.send(:get_merchant_sdk, {'merchantSdk'=>'ActiveMerchant;3.2'})
#Implicit - used raw when nothing is specified
assert_equal 'Ruby;8.12.0', litle.send(:get_merchant_sdk, {'NotMerchantSdk'=>'ActiveMerchant;3.2'})
end


end
18 changes: 18 additions & 0 deletions test/unit/test_auth.rb
Expand Up @@ -176,5 +176,23 @@ def test_all_choices_card_and_paypage_and_paypal_and_token
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
end

def test_merchant_data_auth
hash = {
'merchantId' => '101',
'version'=>'8.12',
'orderId'=>'1',
'amount'=>'0',
'orderSource'=>'ecommerce',
'reportGroup'=>'Planets',
'merchantData'=> {
'campaign'=>'foo'
}
}

XMLObject.expects(:new)
Communications.expects(:http_post).with(regexp_matches(/.*<merchantData>.*?<campaign>foo<\/campaign>.*?<\/merchantData>.*/m),kind_of(Hash))
LitleOnlineRequest.new.authorization(hash)
end

end

16 changes: 16 additions & 0 deletions test/unit/test_credit.rb
Expand Up @@ -111,4 +111,20 @@ def test_all_choices_card_and_paypage_and_paypal_and_token
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.credit(hash)}
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
end

def test_action_reason_on_orphaned_refund
hash = {
'merchantId' => '101',
'version'=>'8.12',
'orderId'=>'1',
'amount'=>'2',
'orderSource'=>'ecommerce',
'reportGroup'=>'Planets',
'actionReason'=> 'SUSPECT_FRAUD'
}
XMLObject.expects(:new)
Communications.expects(:http_post).with(regexp_matches(/.*<actionReason>SUSPECT_FRAUD<\/actionReason>.*/m),kind_of(Hash))
LitleOnlineRequest.new.credit(hash)
end

end
18 changes: 18 additions & 0 deletions test/unit/test_sale.rb
Expand Up @@ -245,5 +245,23 @@ def test_all_choices_card_and_paypage_and_paypal_and_token
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
end

def test_merchant_data_sale
hash = {
'merchantId' => '101',
'version'=>'8.12',
'orderId'=>'1',
'amount'=>'0',
'orderSource'=>'ecommerce',
'reportGroup'=>'Planets',
'merchantData'=> {
'affiliate'=>'bar'
}
}

XMLObject.expects(:new)
Communications.expects(:http_post).with(regexp_matches(/.*<merchantData>.*?<affiliate>bar<\/affiliate>.*?<\/merchantData>.*/m),kind_of(Hash))
LitleOnlineRequest.new.sale(hash)
end

end

0 comments on commit 754ddf6

Please sign in to comment.