diff --git a/Rakefile b/Rakefile index bc8ab35..9e8e4b1 100644 --- a/Rakefile +++ b/Rakefile @@ -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" diff --git a/lib/LitleOnlineRequest.rb b/lib/LitleOnlineRequest.rb index 1f7eeb5..b9900a7 100644 --- a/lib/LitleOnlineRequest.rb +++ b/lib/LitleOnlineRequest.rb @@ -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 @@ -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)) @@ -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) @@ -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) @@ -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) diff --git a/lib/XMLFields.rb b/lib/XMLFields.rb index 7e290fb..bd8e17f 100644 --- a/lib/XMLFields.rb +++ b/lib/XMLFields.rb @@ -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= { diff --git a/test/unit/test_LitleOnlineRequest.rb b/test/unit/test_LitleOnlineRequest.rb index 8635883..ebf4966 100644 --- a/test/unit/test_LitleOnlineRequest.rb +++ b/test/unit/test_LitleOnlineRequest.rb @@ -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 diff --git a/test/unit/test_auth.rb b/test/unit/test_auth.rb index 3d84b11..c08cac1 100644 --- a/test/unit/test_auth.rb +++ b/test/unit/test_auth.rb @@ -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(/.*.*?foo<\/campaign>.*?<\/merchantData>.*/m),kind_of(Hash)) + LitleOnlineRequest.new.authorization(hash) + end + end diff --git a/test/unit/test_credit.rb b/test/unit/test_credit.rb index 8af0ac3..1dd7732 100644 --- a/test/unit/test_credit.rb +++ b/test/unit/test_credit.rb @@ -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(/.*SUSPECT_FRAUD<\/actionReason>.*/m),kind_of(Hash)) + LitleOnlineRequest.new.credit(hash) + end + end \ No newline at end of file diff --git a/test/unit/test_sale.rb b/test/unit/test_sale.rb index b1226c5..1994f01 100644 --- a/test/unit/test_sale.rb +++ b/test/unit/test_sale.rb @@ -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(/.*.*?bar<\/affiliate>.*?<\/merchantData>.*/m),kind_of(Hash)) + LitleOnlineRequest.new.sale(hash) + end + end