Skip to content

Commit

Permalink
Credorax: Update 3DS version mapping
Browse files Browse the repository at this point in the history
Update so that if a 3DS version starts with 2 it doesn't
default to 2.0 but on what is passed in for the three_ds_version
field.

Unit:
82 tests, 394 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
51 tests, 173 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
88.2353% passed
  • Loading branch information
Alma Malambo committed Jul 10, 2024
1 parent 6f024c9 commit 4f34933
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Orbital: Update to accept UCAF Indicator GSF [almalee24] #5150
* CyberSource: Add addtional invoiceHeader fields [yunnydang] #5161
* MerchantWarrior: Update phone, email, ip and store ID [almalee24] #5158
* Credorax: Update 3DS version mapping [almalee24] #5159

== Version 1.136.0 (June 3, 2024)
* Shift4V2: Add new gateway based on SecurionPay adapter [heavyblade] #4860
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/credorax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def add_normalized_3d_secure_2_data(post, options)
three_d_secure_options[:eci],
three_d_secure_options[:cavv]
)
post[:'3ds_version'] = three_d_secure_options[:version]&.start_with?('2') ? '2.0' : three_d_secure_options[:version]
post[:'3ds_version'] = three_d_secure_options[:version] == '2' ? '2.0' : three_d_secure_options[:version]
post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
end

Expand Down
22 changes: 16 additions & 6 deletions test/remote/gateways/remote_credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ def setup
@credit_card = credit_card('4176661000001015', verification_value: '281', month: '12')
@fully_auth_card = credit_card('5223450000000007', brand: 'mastercard', verification_value: '090', month: '12')
@declined_card = credit_card('4176661000001111', verification_value: '681', month: '12')
@three_ds_card = credit_card('4761739000060016', verification_value: '212', month: '12')
@three_ds_card = credit_card('5455330200000016', verification_value: '737', month: '10', year: Time.now.year + 2)
@address = {
name: 'Jon Smith',
address1: '123 Your Street',
address2: 'Apt 2',
city: 'Toronto',
state: 'ON',
zip: 'K2C3N7',
country: 'CA',
phone_number: '(123)456-7890'
}
@options = {
order_id: '1',
currency: 'EUR',
billing_address: address,
billing_address: @address,
description: 'Store Purchase'
}
@normalized_3ds_2_options = {
reference: '345123',
shopper_email: 'john.smith@test.com',
shopper_ip: '77.110.174.153',
shopper_reference: 'John Smith',
billing_address: address(),
shipping_address: address(),
billing_address: @address,
shipping_address: @address,
order_id: '123',
execute_threed: true,
three_ds_version: '2',
Expand Down Expand Up @@ -348,7 +358,7 @@ def test_failed_capture

capture = @gateway.capture(0, auth.authorization)
assert_failure capture
assert_equal 'Invalid amount', capture.message
assert_equal 'System malfunction', capture.message
end

def test_successful_purchase_and_void
Expand Down Expand Up @@ -482,7 +492,7 @@ def test_successful_credit
def test_failed_credit_with_zero_amount
response = @gateway.credit(0, @declined_card, @options)
assert_failure response
assert_equal 'Invalid amount', response.message
assert_equal 'Transaction not allowed for cardholder', response.message
end

def test_successful_verify
Expand Down
4 changes: 2 additions & 2 deletions test/unit/gateways/credorax_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def test_adds_3ds2_fields_via_normalized_hash
@gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
end.check_request do |_endpoint, data, _headers|
assert_match(/i8=#{eci}%3A#{cavv}%3Anone/, data)
assert_match(/3ds_version=2.0/, data)
assert_match(/3ds_version=2/, data)
assert_match(/3ds_dstrxid=#{ds_transaction_id}/, data)
end.respond_with(successful_purchase_response)
end
Expand All @@ -526,7 +526,7 @@ def test_adds_default_cavv_when_omitted_from_normalized_hash
@gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
end.check_request do |_endpoint, data, _headers|
assert_match(/i8=#{eci}%3Anone%3Anone/, data)
assert_match(/3ds_version=2.0/, data)
assert_match(/3ds_version=2.2.0/, data)
assert_match(/3ds_dstrxid=#{ds_transaction_id}/, data)
end.respond_with(successful_purchase_response)
end
Expand Down

0 comments on commit 4f34933

Please sign in to comment.