diff --git a/lib/active_merchant/billing/gateways/flex_charge.rb b/lib/active_merchant/billing/gateways/flex_charge.rb index 955925bcc7d..7a7c05dd390 100644 --- a/lib/active_merchant/billing/gateways/flex_charge.rb +++ b/lib/active_merchant/billing/gateways/flex_charge.rb @@ -41,6 +41,7 @@ def purchase(money, credit_card, options = {}) add_address(post, credit_card, address(options)) add_customer_data(post, options) add_three_ds(post, options) + add_metadata(post, options) commit(:purchase, post) end @@ -114,6 +115,11 @@ def inquire(authorization, options = {}) commit(:inquire, {}, order_id, :get) end + def add_metadata(post, options) + post[:Source] = 'Spreedly' + post[:ExtraData] = options[:extra_data] if options[:extra_data].present? + end + private def address(options) diff --git a/test/remote/gateways/remote_flex_charge_test.rb b/test/remote/gateways/remote_flex_charge_test.rb index b19dad30c09..731020877eb 100644 --- a/test/remote/gateways/remote_flex_charge_test.rb +++ b/test/remote/gateways/remote_flex_charge_test.rb @@ -26,7 +26,8 @@ def setup cvv_result_code: '111', cavv_result_code: '111', timezone_utc_offset: '-5', - billing_address: address.merge(name: 'Cure Tester') + billing_address: address.merge(name: 'Cure Tester'), + extra_data: { hello: 'world' }.to_json } @cit_options = @options.merge( diff --git a/test/unit/gateways/flex_charge_test.rb b/test/unit/gateways/flex_charge_test.rb index aec427eb14e..341165ab298 100644 --- a/test/unit/gateways/flex_charge_test.rb +++ b/test/unit/gateways/flex_charge_test.rb @@ -25,7 +25,8 @@ def setup cavv_result_code: '111', timezone_utc_offset: '-5', billing_address: address.merge(name: 'Cure Tester'), - sense_key: 'abc123' + sense_key: 'abc123', + extra_data: { hello: 'world' }.to_json } @cit_options = { @@ -108,6 +109,8 @@ def test_successful_purchase assert_equal request['orderId'], @options[:order_id] assert_equal request['idempotencyKey'], @options[:idempotency_key] assert_equal request['senseKey'], 'abc123' + assert_equal request['Source'], 'Spreedly' + assert_equal request['ExtraData'], { hello: 'world' }.to_json assert_equal request['transaction']['timezoneUtcOffset'], @options[:timezone_utc_offset] assert_equal request['transaction']['amount'], @amount assert_equal request['transaction']['responseCode'], @options[:response_code]