Skip to content

Commit 79aab2d

Browse files
committed
Support /credit_card/country input
1 parent 772629e commit 79aab2d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v2.2.0
4+
5+
* Added the input `/credit_card/country`. This is the country where the
6+
issuer of the card is located. This may be passed instead of the
7+
`/credit_card/issuer_id_number` if you do not wish to pass partial
8+
account numbers or if your payment processor does not provide them. You
9+
may provide this using the `country` attribute on
10+
`Minfraud::Components::CreditCard`.
11+
312
## v2.1.0 (2022-01-25)
413

514
* Adds the following new processor to `Minfraud::Components::Payment`:

lib/minfraud/components/credit_card.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ class CreditCard < Base
4141
# @return [String, nil]
4242
attr_accessor :bank_phone_number
4343

44+
# The two character ISO 3166-1 alpha-2 country code where the issuer of
45+
# the card is located. This may be passed instead of {::issuer_id_number}
46+
# if you do not wish to pass partial account numbers, or if your payment
47+
# processor does not provide them.
48+
#
49+
# @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
50+
#
51+
# @return [String, nil]
52+
attr_accessor :country
53+
4454
# A token uniquely identifying the card. The token should consist of
4555
# non-space printable ASCII characters. If the token is all digits, it
4656
# must be more than 19 characters long. The token must not be a primary
@@ -96,6 +106,7 @@ def last_4_digits=(last4)
96106
# correspond to one of the available attributes.
97107
def initialize(params = {})
98108
@bank_phone_country_code = params[:bank_phone_country_code]
109+
@country = params[:country]
99110
@issuer_id_number = params[:issuer_id_number]
100111
@last_digits = params[:last_digits] || params[:last_4_digits]
101112
@bank_name = params[:bank_name]
@@ -114,6 +125,7 @@ def validate
114125
return if !Minfraud.enable_validation
115126

116127
validate_telephone_country_code('bank_phone_country_code', @bank_phone_country_code)
128+
validate_country_code('country', @country)
117129
validate_regex('issuer_id_number', /\A(?:[0-9]{6}|[0-9]{8})\z/, @issuer_id_number)
118130
validate_regex('last_digits', /\A(?:[0-9]{2}|[0-9]{4})\z/, @last_digits)
119131
validate_string('bank_name', 255, @bank_name)

spec/components/credit_card_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,11 @@
8787
was_3d_secure_successful: true,
8888
)
8989
end
90+
91+
it 'accepts country code' do
92+
Minfraud::Components::CreditCard.new(
93+
country: 'CA',
94+
)
95+
end
9096
end
9197
end

0 commit comments

Comments
 (0)