diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb index e45266141a0..f757447acc9 100644 --- a/lib/active_merchant/billing/gateways/ebanx.rb +++ b/lib/active_merchant/billing/gateways/ebanx.rb @@ -103,7 +103,7 @@ def store(credit_card, options = {}) post = {} add_integration_key(post) customer_country(post, options) - add_payment_type(post) + add_payment_type(post, options) post[:creditcard] = payment_details(credit_card) commit(:store, post, options) @@ -112,7 +112,7 @@ def store(credit_card, options = {}) def verify(credit_card, options = {}) post = {} add_integration_key(post) - add_payment_type(post) + add_payment_type(post, options) customer_country(post, options) post[:card] = payment_details(credit_card) post[:device_id] = options[:device_id] if options[:device_id] @@ -220,13 +220,13 @@ def add_invoice(post, money, options) def add_card_or_token(post, payment, options) payment = payment.split('|')[0] if payment.is_a?(String) - add_payment_type(post[:payment]) + add_payment_type(post[:payment], options) post[:payment][:creditcard] = payment_details(payment) post[:payment][:creditcard][:soft_descriptor] = options[:soft_descriptor] if options[:soft_descriptor] end - def add_payment_type(post) - post[:payment_type_code] = 'creditcard' + def add_payment_type(post, options) + post[:payment_type_code] = options[:payment_type_code] || 'creditcard' end def payment_details(payment) diff --git a/test/remote/gateways/remote_ebanx_test.rb b/test/remote/gateways/remote_ebanx_test.rb index 1b1d391772f..1f864343810 100644 --- a/test/remote/gateways/remote_ebanx_test.rb +++ b/test/remote/gateways/remote_ebanx_test.rb @@ -71,7 +71,8 @@ def test_successful_purchase_with_more_options ip: '127.0.0.1', email: 'joe@example.com', birth_date: '10/11/1980', - person_type: 'personal' + person_type: 'personal', + payment_type_code: 'visa' }) response = @gateway.purchase(@amount, @credit_card, options) diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb index 9c5c91325f8..e19f4e93427 100644 --- a/test/unit/gateways/ebanx_test.rb +++ b/test/unit/gateways/ebanx_test.rb @@ -54,6 +54,26 @@ def test_successful_purchase_with_soft_descriptor assert_success response end + def test_successful_purchase_with_default_payment_type_code + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |_method, _endpoint, data, _headers| + assert_match %r{"payment_type_code\":\"creditcard\"}, data + end.respond_with(successful_purchase_response) + + assert_success response + end + + def test_successful_purchase_with_payment_type_code_override + response = stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, @credit_card, @options.merge({ payment_type_code: 'visa' })) + end.check_request do |_method, _endpoint, data, _headers| + assert_match %r{"payment_type_code\":\"visa\"}, data + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_purchase_with_stored_credentials_cardholder_recurring options = @options.merge!({ stored_credential: {