Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EBANX: add optional payment_type_code override #5370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/active_merchant/billing/gateways/ebanx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion test/remote/gateways/remote_ebanx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def test_successful_purchase_with_more_options
ip: '127.0.0.1',
email: '[email protected]',
birth_date: '10/11/1980',
person_type: 'personal'
person_type: 'personal',
payment_type_code: 'visa'
})

response = @gateway.purchase(@amount, @credit_card, options)
Expand Down
20 changes: 20 additions & 0 deletions test/unit/gateways/ebanx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading