Skip to content

Commit

Permalink
Credorax: Add support for gateway card validation
Browse files Browse the repository at this point in the history
This change allows the `cardholder_name_inquiry` flag to be sent. If set to true, it will trigger first and last name data to be sent for c22, and c23. $0 auth transactions to validate cards also require the value for a9 to be set to 5.

Remote Tests:
52 tests, 176 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
88.4615% passed

Unit Tests
83 tests, 399 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
rachelkirk committed Nov 11, 2024
1 parent 63a738b commit 15d05f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/active_merchant/billing/gateways/credorax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def authorize(amount, payment_method, options = {})
add_3ds_2_optional_fields(post, options)
add_echo(post, options)
add_submerchant_id(post, options)
add_cardholder_name_inquiry(post, options)
add_stored_credential(post, options)
add_processor(post, options)
add_authorization_details(post, options)
Expand Down Expand Up @@ -355,6 +356,14 @@ def add_customer_name(post, options)
post[:j13] = options[:last_name] if options[:last_name]
end

def add_cardholder_name_inquiry(post, options)
return unless options[:cardholder_name_inquiry] == true

post[:c22] = options[:first_name] if options[:first_name]
post[:c23] = options[:last_name] if options[:last_name]
post[:a9] = '5'
end

def add_3d_secure(post, options)
if (options[:eci] && options[:xid]) || (options[:three_d_secure] && options[:three_d_secure][:version]&.start_with?('1'))
add_3d_secure_1_data(post, options)
Expand Down
8 changes: 8 additions & 0 deletions test/remote/gateways/remote_credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ def test_successful_authorize_with_authorization_details
assert response.authorization
end

def test_sucessful_zero_authorize_with_name_inquiry
extra_options = @options.merge({ cardholder_name_inquiry: true })
response = @gateway.authorize(0, @credit_card, extra_options)
assert_success response
assert_equal 'Succeeded', response.message
assert response.authorization
end

def test_successful_authorize_with_auth_data_via_3ds1_fields
options = @options.merge(
eci: '02',
Expand Down
13 changes: 13 additions & 0 deletions test/unit/gateways/credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,19 @@ def test_credit_adds_echo_field
end.respond_with(successful_credit_response)
end

def test_authorize_adds_cardholder_name_inquiry
@options[:cardholder_name_inquiry] = true
@options[:first_name] = 'Art'
@options[:last_name] = 'Vandelay'
stub_comms do
@gateway.authorize(0, @credit_card, @options)
end.check_request do |_endpoint, data, _headers|
assert_match(/c22=Art/, data)
assert_match(/c23=Vandelay/, data)
assert_match(/a9=5/, data)
end.respond_with(successful_credit_response)
end

def test_purchase_omits_phone_when_nil
# purchase passes the phone number when provided
@options[:billing_address][:phone] = '555-444-3333'
Expand Down

0 comments on commit 15d05f1

Please sign in to comment.