Skip to content

Commit

Permalink
Priority: fix for bin lookup
Browse files Browse the repository at this point in the history
Description
-------------------------
Send 8 digits for bin lookups instead of 7.

Unit tests
-------------------------
6159 tests, 80990 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote tests
-------------------------
31 tests, 84 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
83.871% passed

Failures not related to changes

Rubocop
-------------------------
808 files inspected, no offenses detected
  • Loading branch information
Buitragox authored and Alma Malambo committed Jan 8, 2025
1 parent 9a46606 commit 55b1766
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
* Hi Pay: Don't add 3ds when :three_ds_2 is missing [Buitragox] #5355
* SecurePayAU: Send order ID for payments with stored card [dacook] #3979
* Orbital: Add XSD version testing to unit test [almalee24] #5375
* Priority: fix for bin lookup [Buitragox] #5366

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/priority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def url(action, params, ref_number: '', credit_card_number: nil)
when 'void'
base_url + "/#{ref_number}?force=true"
when 'verify'
(verify_url + '?search=') + credit_card_number.to_s[0..6]
(verify_url + '?search=') + credit_card_number.to_s[0..7]
when 'get_payment_status', 'close_batch'
batch_url + "/#{params}"
when 'create_jwt'
Expand Down Expand Up @@ -366,7 +366,7 @@ def parse(body)
end

def success_from(response, action)
return !response['bank'].empty? if action == 'verify' && response['bank']
return !response['bank'].empty? if action == 'verify' && response['bank'] && !response.dig('bank', 'name').blank?

%w[Approved Open Success Settled Voided].include?(response['status'])
end
Expand Down
111 changes: 111 additions & 0 deletions test/unit/gateways/priority_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ def test_failed_credit_invalid_credit_card_month
assert response.test?
end

def test_successful_verify
@gateway.stubs(:create_jwt).returns(jwt_response)

response = stub_comms(@gateway, :ssl_get) do
@gateway.verify(@credit_card)
end.respond_with(successful_bin_search_response)

assert_success response
end

def test_failed_verify_no_bank
@gateway.stubs(:create_jwt).returns(jwt_response)

response = stub_comms(@gateway, :ssl_get) do
@gateway.verify(credit_card('4242424242424242'))
end.respond_with(no_bank_bin_search_response)

assert_failure response
end

def successful_refund_response
%(
{
Expand Down Expand Up @@ -1422,4 +1442,95 @@ def failed_credit_response
}
)
end

def jwt_response
response = {
processorName: 'TSYS',
jwtToken: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InZvcnRleDAwMDEifQ.eyJ1aWQiOiIxMjc2QzU5Qi03OUJFLTQ5QzEtQkE4Ri01RTM0MkFENzBGQjkiLCJncmFudHMiOlsiZ2xvYmFsIiwicHBzOm14LW1lcmNoYW50IiwibWVyY2hhbnQ6MTAwMDAwMzMxMCIsInhtaWQ6ODczOTczMTIwODY2MTM0NCJdLCJyb2xlIjoibXgtbWVyY2hhbnQtcmVwb3J0IiwiZmx5SW5BbGxvd2VkIjpmYWxzZSwidXNlck5hbWUiOiJzeXN0ZW11c2VyLm14bWVyY2hhbnQiLCJpYXQiOjE3MzQxMTk3ODIsImV4cCI6MTczNDIwNjE4MiwiYXVkIjoiaHR0cHM6Ly9zYW5kYm94Lm14bWVyY2hhbnQuY29tIiwiaXNzIjoiaHR0cHM6Ly9zYW5kYm94Lm14bWVyY2hhbnQuY29tIiwic3ViIjoiblNGQ0V5eHdkVG9vOHhJOWVNcldMUWRnIn0.Tvm7c_YXQupGXCn2Pf6MlN0VMnTVZxHFn4OQ2ojaSyMJUq4tTFdf8xPqAbQql-JEaekZfUJmwbGF_zaxgY4VKQ'
}

ActiveMerchant::Billing::Response.new(
true,
response,
response
)
end

def successful_bin_search_response
%(
{
"id": "41111111",
"bin": "41111111",
"bank": {
"www": "www.jpmorganchase.com",
"name": "JPMORGAN CHASE BANK N.A.",
"phone": "416-981-9200"
},
"type": "",
"brand": "VISA",
"level": "",
"source": "pci.bindb.com",
"country": {
"iso": "840",
"info": "Wilmington",
"name": "United States",
"abbreviation2": "US",
"abbreviation3": "USA"
},
"created": "2024-02-15T15:58:38.306Z",
"creator": {
"id": "system",
"user": "system"
},
"prepaid": null,
"business": null,
"modified": "2024-02-15T15:58:38.306Z",
"modifier": {
"id": "system",
"user": "system"
},
"reloadable": null,
"isCreditCard": true
}
)
end

def no_bank_bin_search_response
%(
{
"id": "42424242",
"bin": "42424242",
"bank": {
"www": "",
"name": "",
"phone": ""
},
"type": "CREDIT",
"brand": "VISA",
"level": "CLASSIC",
"source": "pci.bindb.com",
"country": {
"iso": "826",
"info": "",
"name": "United Kingdom",
"abbreviation2": "GB",
"abbreviation3": "GBR"
},
"created": "2023-04-03T12:39:37.033Z",
"creator": {
"id": "system",
"user": "system"
},
"prepaid": false,
"business": false,
"modified": "2024-01-16T06:29:37.125Z",
"modifier": {
"id": "system",
"user": "system"
},
"reloadable": false,
"isCreditCard": true
}
)
end
end

0 comments on commit 55b1766

Please sign in to comment.