issuer_response_codes 0.1.2 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +3 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +11 -9
- data/README.md +166 -8
- data/issuer_response_codes.gemspec +2 -0
- data/lib/issuer_response_codes/code.rb +8 -2
- data/lib/issuer_response_codes/context.rb +4 -0
- data/lib/issuer_response_codes/locale_library.rb +3 -1
- data/lib/issuer_response_codes/tds_code.rb +26 -0
- data/lib/issuer_response_codes/version.rb +1 -1
- data/lib/issuer_response_codes.rb +2 -1
- data/lib/locale/da.yml +149 -38
- data/lib/locale/de.yml +292 -0
- data/lib/locale/ee.yml +149 -38
- data/lib/locale/en.yml +277 -77
- data/lib/locale/it.yml +289 -0
- data/lib/locale/lt.yml +149 -38
- data/lib/locale/lv.yml +149 -38
- data/lib/locale/pl.yml +294 -76
- data/lib/locale/sv.yml +149 -38
- metadata +36 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad61b730d7f8151c677659149d3e2f9f52416a252978d330586e45468ec9a36c
|
4
|
+
data.tar.gz: fdde772836f137b8824fd4722373b9a3c3269a2e0f3fa309bfe9aa0ea721aebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6266292743bb5a74798642b73c8eb14516fe70827e3d2db872b3f04e82d601fc8c64a32a736e4eee1c53580a365fc119d8cab87112b3d6be050acde4fe02d0cb
|
7
|
+
data.tar.gz: 4eedf727e8ba8f84072f9b36ca66f9b47772d4bf2c91cdcc858c945adf9c712573c6f463260f7095762e7ebb7df2840d15349ddcff3b3c501be294a6333edafa
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
issuer_response_codes (0.
|
4
|
+
issuer_response_codes (0.2.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
backport (1.
|
10
|
+
backport (1.2.0)
|
11
11
|
benchmark (0.1.1)
|
12
12
|
bundler-audit (0.8.0)
|
13
13
|
bundler (>= 1.2.0, < 3)
|
14
14
|
thor (~> 1.0)
|
15
15
|
byebug (11.1.3)
|
16
|
+
diff-lcs (1.4.4)
|
16
17
|
e2mmap (0.1.0)
|
17
18
|
jaro_winkler (1.5.4)
|
18
19
|
kramdown (2.3.1)
|
19
20
|
rexml
|
20
21
|
kramdown-parser-gfm (1.1.0)
|
21
22
|
kramdown (~> 2.0)
|
22
|
-
mini_portile2 (2.5.
|
23
|
+
mini_portile2 (2.5.3)
|
23
24
|
minitest (5.14.4)
|
24
|
-
nokogiri (1.11.
|
25
|
+
nokogiri (1.11.7)
|
25
26
|
mini_portile2 (~> 2.5.0)
|
26
27
|
racc (~> 1.4)
|
27
28
|
parallel (1.20.1)
|
@@ -34,22 +35,23 @@ GEM
|
|
34
35
|
reverse_markdown (2.0.0)
|
35
36
|
nokogiri
|
36
37
|
rexml (3.2.5)
|
37
|
-
rubocop (1.
|
38
|
+
rubocop (1.18.2)
|
38
39
|
parallel (~> 1.10)
|
39
40
|
parser (>= 3.0.0.0)
|
40
41
|
rainbow (>= 2.2.2, < 4.0)
|
41
42
|
regexp_parser (>= 1.8, < 3.0)
|
42
43
|
rexml
|
43
|
-
rubocop-ast (>= 1.
|
44
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
44
45
|
ruby-progressbar (~> 1.7)
|
45
46
|
unicode-display_width (>= 1.4.0, < 3.0)
|
46
|
-
rubocop-ast (1.
|
47
|
+
rubocop-ast (1.7.0)
|
47
48
|
parser (>= 3.0.1.1)
|
48
49
|
ruby-progressbar (1.11.0)
|
49
|
-
solargraph (0.
|
50
|
-
backport (~> 1.
|
50
|
+
solargraph (0.42.3)
|
51
|
+
backport (~> 1.2)
|
51
52
|
benchmark
|
52
53
|
bundler (>= 1.17.2)
|
54
|
+
diff-lcs (~> 1.4)
|
53
55
|
e2mmap
|
54
56
|
jaro_winkler (~> 1.5)
|
55
57
|
kramdown (~> 2.3)
|
data/README.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# IssuerResponseCodes
|
2
2
|
|
3
|
-
This gem provides a quite comprehensive library of Issuer Response Code descriptions (for both cardholders and merchants) with suggested actions in
|
3
|
+
This gem provides a quite comprehensive library of Issuer Response Code and 3D-Secure Status Code descriptions (for both cardholders and merchants) with suggested actions in 9 languages:
|
4
4
|
- Complete locales:
|
5
|
-
|
6
|
-
|
5
|
+
- en
|
6
|
+
- pl
|
7
7
|
|
8
8
|
- Incomplete locales:
|
9
9
|
- da
|
10
|
+
- de
|
10
11
|
- ee
|
12
|
+
- it
|
11
13
|
- lt
|
12
14
|
- lv
|
13
15
|
- sv
|
@@ -59,11 +61,22 @@ def response_code_description
|
|
59
61
|
::ISSUER_RESPONSE_CODES.code(id: '43', locale: :pl).description
|
60
62
|
#=> "Karta oznaczona jako skradziona. Skontaktuj się z Twoim bankiem w celu wyjaśnienia przyczyny problemu."
|
61
63
|
end
|
64
|
+
|
65
|
+
def tds_code_description
|
66
|
+
::ISSUER_RESPONSE_CODES.tds_code(id: '09').description
|
67
|
+
#=> "Security failure"
|
68
|
+
|
69
|
+
::ISSUER_RESPONSE_CODES.tds_code(id: '09', target: :cardholder).description
|
70
|
+
#=> "Card authentication failed"
|
71
|
+
|
72
|
+
::ISSUER_RESPONSE_CODES.tds_code(id: '09', locale: :pl).description
|
73
|
+
#=> "Niepowodzenie autoryzacji karty"
|
74
|
+
end
|
62
75
|
```
|
63
76
|
|
64
77
|
## Usage
|
65
78
|
|
66
|
-
This gem provides an easy way of handling Issuer Response Codes. Whether you need detailed descriptions, short reasons or suggestions of what to do when a certain Code appeared, we've got you covered. Certain more explicit codes like `Stolen card' are masked behind more generic terms when you choose to target cardholders.
|
79
|
+
This gem provides an easy way of handling Issuer Response Codes and 3D-Secure Status Codes. Whether you need detailed descriptions, short reasons or suggestions of what to do when a certain Code appeared, we've got you covered. Certain more explicit codes like `Stolen card' are masked behind more generic terms when you choose to target cardholders.
|
67
80
|
|
68
81
|
### IssuerResponseCodes::Code
|
69
82
|
#### Creation options
|
@@ -135,7 +148,7 @@ code.reason #=> "Karta utraciła ważność."
|
|
135
148
|
|
136
149
|
#### Methods
|
137
150
|
|
138
|
-
#####
|
151
|
+
##### reason
|
139
152
|
|
140
153
|
The `reason` method returns a relatively short description of the main reason why the Issuer Response Code appeared in the first place.
|
141
154
|
|
@@ -150,7 +163,7 @@ code = ::IssuerResponseCodes::Code.new(id: '59')
|
|
150
163
|
code.reason #=> "Your bank has declined this transaction"
|
151
164
|
```
|
152
165
|
|
153
|
-
#####
|
166
|
+
##### behaviour
|
154
167
|
|
155
168
|
The `behaviour` method returns a suggestion of what to do when the Issuer Response Code appeared. Mainly for cardholders.
|
156
169
|
|
@@ -165,9 +178,9 @@ code = ::IssuerResponseCodes::Code.new(id: '59')
|
|
165
178
|
code.behaviour #=> "Please contact your card issuer to get more details and try again later."
|
166
179
|
```
|
167
180
|
|
168
|
-
#####
|
181
|
+
##### description/humanize
|
169
182
|
|
170
|
-
The `description` method is a combination of both the `reason` and `behaviour` of a Issuer Response Code
|
183
|
+
The `description` method (aliased as `humanize`) is a combination of both the `reason` and `behaviour` of a Issuer Response Code
|
171
184
|
|
172
185
|
```ruby
|
173
186
|
code = ::IssuerResponseCodes::Code.new(id: '14')
|
@@ -180,6 +193,148 @@ code = ::IssuerResponseCodes::Code.new(id: '59')
|
|
180
193
|
code.description #=> "Your bank has declined this transaction. Please contact your card issuer to get more details and try again later."
|
181
194
|
```
|
182
195
|
|
196
|
+
##### fraudulent_code?
|
197
|
+
|
198
|
+
The `fraudulent_code?` method returns `true` when the Code indicates fraud.
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
code = ::IssuerResponseCodes::Code.new(id: '14')
|
202
|
+
code.fraudulent_code? #=> false
|
203
|
+
|
204
|
+
code = ::IssuerResponseCodes::Code.new(id: '04')
|
205
|
+
code.fraudulent_code? #=> true
|
206
|
+
|
207
|
+
code = ::IssuerResponseCodes::Code.new(id: '43')
|
208
|
+
code.fraudulent_code? #=> true
|
209
|
+
```
|
210
|
+
|
211
|
+
### IssuerResponseCodes::TdsCode
|
212
|
+
#### Creation options
|
213
|
+
|
214
|
+
##### Targets
|
215
|
+
|
216
|
+
You can choose the main target of these descriptions (certain details are hidden for cardholders)
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
# Default values are as follows:
|
220
|
+
# target: :merchant, locale: :en
|
221
|
+
|
222
|
+
# fraud_notice is set to true by default when target = :merchant
|
223
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11')
|
224
|
+
code.reason #=> "Suspected fraud."
|
225
|
+
|
226
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11', target: :merchant)
|
227
|
+
code.reason #=> "Suspected fraud."
|
228
|
+
|
229
|
+
# fraud_notice is set to false by default when target = :cardholder
|
230
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11', target: :cardholder)
|
231
|
+
code.reason #=> "Card authentication failed."
|
232
|
+
```
|
233
|
+
|
234
|
+
##### Fraud notice
|
235
|
+
|
236
|
+
Certain 3D-Secure status codes may signify that the transaction may be viewed as a fraud attempt. As such, this gem provides appropriate warnings. You can manually decide whether these warnings/notices should be added to descriptions or behaviour suggestions generated by this gem.
|
237
|
+
|
238
|
+
By default descriptions targeted at merchants have these warnings, while those targeted at cardholders omit them.
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '09', target: :merchant)
|
242
|
+
code.behaviour #=> "Please use a different card or contact issuer. Transactions with this code may be considered fraudulent."
|
243
|
+
|
244
|
+
# fraud_notice is set to false by default when target = :cardholder
|
245
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '09', target: :cardholder)
|
246
|
+
code.behaviour #=> "Please use a different card or contact issuer."
|
247
|
+
```
|
248
|
+
|
249
|
+
This however can be overridden by explicitly passing the `fraud_notice` keyword parameter
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
# default options can be overridden
|
253
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '09', target: :merchant, fraud_notice: false)
|
254
|
+
code.behaviour #=> "Please use a different card or contact issuer."
|
255
|
+
|
256
|
+
# fraud_notice is set to false by default when target = :cardholder
|
257
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '09', target: :cardholder, fraud_notice: true)
|
258
|
+
code.behaviour #=> "Please use a different card or contact issuer. Transactions with this code may be considered fraudulent."
|
259
|
+
```
|
260
|
+
|
261
|
+
##### Locale
|
262
|
+
|
263
|
+
The default locale is `:en`. There are 7 in total: `%i[en pl da ee lt lv sv]`. Only the first two are complete, the rest are partially in English.
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11', target: :cardholder)
|
267
|
+
code.reason #=> "Card authentication failed."
|
268
|
+
|
269
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11', locale: :en, target: :cardholder)
|
270
|
+
code.reason #=> "Card authentication failed."
|
271
|
+
|
272
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11', locale: :pl, target: :cardholder)
|
273
|
+
code.reason #=> "Negatywny wynik silnego uwierzytelnienia w systemie banku."
|
274
|
+
```
|
275
|
+
|
276
|
+
#### Methods
|
277
|
+
|
278
|
+
##### reason
|
279
|
+
|
280
|
+
The `reason` method returns a relatively short description of the main reason why the 3D-Secure status code appeared in the first place.
|
281
|
+
|
282
|
+
```ruby
|
283
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '01')
|
284
|
+
code.reason #=> "Card authentication failed."
|
285
|
+
|
286
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '07')
|
287
|
+
code.reason #=> "Invalid transaction."
|
288
|
+
|
289
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '20')
|
290
|
+
code.reason #=> "Non-Payment transaction not supported."
|
291
|
+
```
|
292
|
+
|
293
|
+
##### behaviour
|
294
|
+
|
295
|
+
The `behaviour` method returns a suggestion of what to do when the 3D-Secure status code appeared. Mainly for cardholders.
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '01')
|
299
|
+
code.behaviour #=> "Check entered data and try again."
|
300
|
+
|
301
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '07')
|
302
|
+
code.behaviour #=> "Please check funds on your account and try again later."
|
303
|
+
|
304
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '20')
|
305
|
+
code.behaviour #=> "Please contact your card issuer to get more details and try again later."
|
306
|
+
```
|
307
|
+
|
308
|
+
##### description/humanize
|
309
|
+
|
310
|
+
The `description` method (aliased as `humanize`) is a combination of both the `reason` and `behaviour` of a Issuer Response Code
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '01')
|
314
|
+
code.description #=> "Invalid card number. Check entered data and try again."
|
315
|
+
|
316
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '07')
|
317
|
+
code.description #=> "Insufficient funds. Please check funds on your account and try again later."
|
318
|
+
|
319
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '20')
|
320
|
+
code.description #=> "Your bank has declined this transaction. Please contact your card issuer to get more details and try again later."
|
321
|
+
```
|
322
|
+
|
323
|
+
##### fraudulent_code?
|
324
|
+
|
325
|
+
The `fraudulent_code?` method returns `true` when the TdsCode indicates fraud.
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '11')
|
329
|
+
code.fraudulent_code? #=> true
|
330
|
+
|
331
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '22')
|
332
|
+
code.fraudulent_code? #=> false
|
333
|
+
|
334
|
+
code = ::IssuerResponseCodes::TdsCode.new(id: '26')
|
335
|
+
code.fraudulent_code? #=> false
|
336
|
+
```
|
337
|
+
|
183
338
|
### Custom default configuration
|
184
339
|
|
185
340
|
You can make use of the `Context` class to easily create your own default configurations. Contexts work as proxies which create codes for you.
|
@@ -198,6 +353,9 @@ code = ISSUER_RESPONSE_CODES.code(id: '43')
|
|
198
353
|
code.reason #=> "Bank odrzucił autoryzację."
|
199
354
|
code.behaviour #=> "Skontaktuj się z Twoim bankiem w celu wyjaśnienia przyczyny problemu. UWAGA: Nie należy powtarzać obciążeń dla tej karty! Może to zostać uznane za próbę oszustwa!"
|
200
355
|
|
356
|
+
tds_code = ISSUER_RESPONSE_CODES.tds_code(id: '11')
|
357
|
+
tds_code.reason #=> "Niepowodzenie autoryzacji karty"
|
358
|
+
|
201
359
|
# these can always be overridden
|
202
360
|
code = ISSUER_RESPONSE_CODES.code(id: '43', locale: :en, target: :merchant, fraud_notice: false)
|
203
361
|
code.reason #=> "Stolen card."
|
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'bundler'
|
30
30
|
spec.add_development_dependency 'bundler-audit'
|
31
31
|
spec.add_development_dependency 'byebug'
|
32
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
33
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
32
34
|
spec.add_development_dependency 'rubocop'
|
33
35
|
spec.add_development_dependency 'solargraph'
|
34
36
|
end
|
@@ -33,8 +33,14 @@ module IssuerResponseCodes
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def behaviour
|
36
|
-
|
37
|
-
|
36
|
+
behaviour_str = LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.behaviour", locale: locale, default: :unknown)
|
37
|
+
return behaviour_str unless fraud_notice && fraudulent_code?
|
38
|
+
|
39
|
+
"#{behaviour_str} #{LOCALE_LIBRARY.dig(path: 'issuer_response_codes.fraud_notice')}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def fraudulent_code?
|
43
|
+
@fraudulent_code ||= LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.fraudulent_codes", locale: locale)
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
@@ -24,5 +24,9 @@ module IssuerResponseCodes
|
|
24
24
|
def code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
|
25
25
|
Code.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
|
26
26
|
end
|
27
|
+
|
28
|
+
def tds_code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
|
29
|
+
TdsCode.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require 'byebug'
|
5
4
|
|
6
5
|
module IssuerResponseCodes
|
7
6
|
class LocaleLibrary
|
@@ -18,6 +17,7 @@ module IssuerResponseCodes
|
|
18
17
|
def dig(path:, locale: :en, scope: '', default: nil, substitute: '')
|
19
18
|
result = __dig__(path: path, locale: locale, scope: scope, default: default)
|
20
19
|
return result unless result
|
20
|
+
return result unless result.is_a? ::String
|
21
21
|
|
22
22
|
result.gsub(/%{substitute}/, substitute)
|
23
23
|
end
|
@@ -48,6 +48,8 @@ module IssuerResponseCodes
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def dig_provided_path(path, scope, locale)
|
51
|
+
return if path.nil? || path.empty?
|
52
|
+
|
51
53
|
full_path_array = [locale]
|
52
54
|
full_path_array.append(*scope.split('.').map(&:to_sym))
|
53
55
|
full_path_array.append(*path.split('.').map(&:to_sym))
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IssuerResponseCodes
|
4
|
+
class TdsCode < Code
|
5
|
+
def humanize
|
6
|
+
"#{reason} #{behaviour}"
|
7
|
+
end
|
8
|
+
|
9
|
+
alias description humanize
|
10
|
+
|
11
|
+
def reason
|
12
|
+
LOCALE_LIBRARY.dig(path: id, scope: "tds_status_codes.targeted.#{target}", locale: locale, default: :unknown)
|
13
|
+
end
|
14
|
+
|
15
|
+
def behaviour
|
16
|
+
behaviour_str = LOCALE_LIBRARY.dig(path: id, scope: "tds_status_codes.behaviour", locale: locale, default: :unknown)
|
17
|
+
return behaviour_str unless fraud_notice && fraudulent_code?
|
18
|
+
|
19
|
+
"#{behaviour_str} #{LOCALE_LIBRARY.dig(path: 'tds_status_codes.fraud_notice')}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def fraudulent_code?
|
23
|
+
@fraudulent_code ||= LOCALE_LIBRARY.dig(path: id, scope: "tds_status_codes.fraudulent_codes", locale: locale)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -4,13 +4,14 @@ require "issuer_response_codes/version"
|
|
4
4
|
require "issuer_response_codes/locale_library"
|
5
5
|
require "issuer_response_codes/context"
|
6
6
|
require "issuer_response_codes/code"
|
7
|
+
require "issuer_response_codes/tds_code"
|
7
8
|
|
8
9
|
module IssuerResponseCodes
|
9
10
|
class IllegalTarget < StandardError; end
|
10
11
|
class IllegalLocale < StandardError; end
|
11
12
|
|
12
13
|
AVAILABLE_TARGETS = %i[merchant cardholder].freeze
|
13
|
-
AVAILABLE_LOCALES = %i[en pl da ee lt lv sv].freeze
|
14
|
+
AVAILABLE_LOCALES = %i[en pl da de ee it lt lv sv].freeze
|
14
15
|
|
15
16
|
LOCALE_LIBRARY = LocaleLibrary.new
|
16
17
|
end
|