diff --git a/lib/active_merchant/billing/gateways/flex_charge.rb b/lib/active_merchant/billing/gateways/flex_charge.rb index ed2ab26e96d..3471711e72a 100644 --- a/lib/active_merchant/billing/gateways/flex_charge.rb +++ b/lib/active_merchant/billing/gateways/flex_charge.rb @@ -30,9 +30,8 @@ def initialize(options = {}) end def purchase(money, credit_card, options = {}) - options[:transactionType] ||= 'Purchase' + post = { transactionType: options.fetch(:transactionType, 'Purchase') } - post = {} add_merchant_data(post, options) add_base_data(post, options) add_invoice(post, money, credit_card, options) @@ -198,7 +197,6 @@ def add_invoice(post, money, credit_card, options) avsResultCode: options[:avs_result_code], cvvResultCode: options[:cvv_result_code], cavvResultCode: options[:cavv_result_code], - transactionType: options[:transactionType], cardNotPresent: credit_card.is_a?(String) ? false : credit_card.verification_value.blank? }.compact end diff --git a/test/remote/gateways/remote_flex_charge_test.rb b/test/remote/gateways/remote_flex_charge_test.rb index 1c1d5c2125f..d38cff1a7b6 100644 --- a/test/remote/gateways/remote_flex_charge_test.rb +++ b/test/remote/gateways/remote_flex_charge_test.rb @@ -27,7 +27,7 @@ def setup cavv_result_code: '111', timezone_utc_offset: '-5', billing_address: address.merge(name: 'Cure Tester'), - extra_data: { hello: 'world' }.to_json + extra_data: '' } @cit_options = @options.merge( diff --git a/test/unit/gateways/flex_charge_test.rb b/test/unit/gateways/flex_charge_test.rb index 2c6eabc1a91..09683bc59f3 100644 --- a/test/unit/gateways/flex_charge_test.rb +++ b/test/unit/gateways/flex_charge_test.rb @@ -119,7 +119,7 @@ def test_successful_purchase assert_equal request['transaction']['avsResultCode'], @options[:avs_result_code] assert_equal request['transaction']['cvvResultCode'], @options[:cvv_result_code] assert_equal request['transaction']['cavvResultCode'], @options[:cavv_result_code] - assert_equal request['transaction']['transactionType'], 'Purchase' + assert_equal request['transactionType'], 'Purchase' assert_equal request['payer']['email'], @options[:email] assert_equal request['description'], @options[:description] @@ -141,7 +141,7 @@ def test_successful_authorization @gateway.authorize(@amount, @credit_card, @options) end.check_request do |_method, endpoint, data, _headers| request = JSON.parse(data) - assert_equal request['transaction']['transactionType'], 'Authorization' if /evaluate/.match?(endpoint) + assert_equal request['transactionType'], 'Authorization' if /evaluate/.match?(endpoint) end.respond_with(successful_access_token_response, successful_purchase_response) end