pix_emv_decoder_ruby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +127 -0
- data/lib/pix_emv_decoder_ruby/decoder.rb +39 -0
- data/lib/pix_emv_decoder_ruby/types/additional_data_field_template.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/country_code.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/crc.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/decimal.rb +13 -0
- data/lib/pix_emv_decoder_ruby/types/hash.rb +11 -0
- data/lib/pix_emv_decoder_ruby/types/merchant_account_information.rb +30 -0
- data/lib/pix_emv_decoder_ruby/types/merchant_category_code.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/merchant_city.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/merchant_name.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/payload_format_indicator.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/pix/chave_pix.rb +21 -0
- data/lib/pix_emv_decoder_ruby/types/pix/globally_unique_identifier.rb +21 -0
- data/lib/pix_emv_decoder_ruby/types/pix/informacoes_adicionais.rb +21 -0
- data/lib/pix_emv_decoder_ruby/types/pix/url.rb +21 -0
- data/lib/pix_emv_decoder_ruby/types/point_of_initial_method.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/reference_label.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/string.rb +8 -0
- data/lib/pix_emv_decoder_ruby/types/transaction_amount.rb +17 -0
- data/lib/pix_emv_decoder_ruby/types/transaction_currency.rb +203 -0
- data/lib/pix_emv_decoder_ruby/types/type.rb +20 -0
- data/lib/pix_emv_decoder_ruby/types.rb +24 -0
- data/lib/pix_emv_decoder_ruby.rb +16 -0
- metadata +67 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 85887cdd738b61284476793491f3a188a38b408d1db3b4c62bdaba62632a3f16
|
|
4
|
+
data.tar.gz: 705f5c9be06f601297fbb85ae0cdec6c97a83a712aad1adcb8d97a6e1b37f047
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 873a9e1c87e5c68e83ebe0e97fa492b6e1c36668dd690b209144e5565fc7224e1f262f50d5b3d3c8077046cee87dfef8fa806e30653d3f9d707735e0e888db71
|
|
7
|
+
data.tar.gz: d73363330d7f6ace9450ecd422b8101fac463e8bdaf24b722155a1cbe91c21e83883e627f6ac5dc29bf0b26f0a80547c6d9ade63b867b72e30139de42c8defed
|
data/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# PixEmvDecoderRuby
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/pix_emv_decoder_ruby)
|
|
4
|
+
|
|
5
|
+
A simple Ruby library for decoding **PIX EMV QR Codes** (both static and dynamic).
|
|
6
|
+
It parses the `copia e cola` string into a Ruby hash with meaningful keys like merchant name, PIX key, transaction amount, etc.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem "pix_emv_decoder_ruby"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bundle install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install it yourself:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
gem install pix_emv_decoder_ruby
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
Require the gem:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require "pix_emv_decoder_ruby"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Decode a PIX EMV payload:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
payload = "00020126550014br.gov.bcb.pix0117wgirhad@gmail.com0212awesome test5204000053039865406420.695802BR5914Willian Girhad6009Sao Paulo622805247aec6590a492461a8bb140fe630445CE"
|
|
44
|
+
|
|
45
|
+
decoded = PixEmvDecoderRuby.decode(payload)
|
|
46
|
+
|
|
47
|
+
puts decoded
|
|
48
|
+
# {
|
|
49
|
+
# payload_format_indicator: "01",
|
|
50
|
+
# merchant_account_information: {
|
|
51
|
+
# globally_unique_identifier: "br.gov.bcb.pix",
|
|
52
|
+
# chave_pix: "wgirhad@gmail.com",
|
|
53
|
+
# informacoes_adicionais: "awesome test"
|
|
54
|
+
# },
|
|
55
|
+
# merchant_category_code: "0000",
|
|
56
|
+
# transaction_currency: :brl,
|
|
57
|
+
# transaction_amount: BigDecimal("420.69"),
|
|
58
|
+
# country_code: "BR",
|
|
59
|
+
# merchant_name: "Willian Girhad",
|
|
60
|
+
# merchant_city: "Sao Paulo",
|
|
61
|
+
# additional_data_field_template: {
|
|
62
|
+
# reference_label: "7aec6590a492461a8bb140fe"
|
|
63
|
+
# },
|
|
64
|
+
# crc: "45CE"
|
|
65
|
+
# }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Dynamic QR Code Example
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
payload = "00020126660014br.gov.bcb.pix2544coolbank.net/pix/v1/7aec6590a492461a8bb140fe5204000053039865802BR5903PIX6009Sao Paulo62070503***63041D24"
|
|
72
|
+
|
|
73
|
+
decoded = PixEmvDecoderRuby.decode(payload)
|
|
74
|
+
|
|
75
|
+
puts decoded
|
|
76
|
+
# {
|
|
77
|
+
# payload_format_indicator: "01",
|
|
78
|
+
# merchant_account_information: {
|
|
79
|
+
# globally_unique_identifier: "br.gov.bcb.pix",
|
|
80
|
+
# url: "coolbank.net/pix/v1/7aec6590a492461a8bb140fe"
|
|
81
|
+
# },
|
|
82
|
+
# merchant_category_code: "0000",
|
|
83
|
+
# transaction_currency: :brl,
|
|
84
|
+
# country_code: "BR",
|
|
85
|
+
# merchant_name: "PIX",
|
|
86
|
+
# merchant_city: "Sao Paulo",
|
|
87
|
+
# additional_data_field_template: {
|
|
88
|
+
# reference_label: "***"
|
|
89
|
+
# },
|
|
90
|
+
# crc: "1D24"
|
|
91
|
+
# }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Features
|
|
97
|
+
|
|
98
|
+
- ✅ Supports **Static** and **Dynamic** PIX QR Codes
|
|
99
|
+
- ✅ Returns a clean, Ruby-style hash
|
|
100
|
+
- ✅ Parses `transaction_amount` as `BigDecimal` when available
|
|
101
|
+
- ✅ Provides merchant info, PIX key/URL, CRC, and more
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
Clone the repository and run the tests:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git clone https://github.com/wgirhad/pix_emv_decoder_ruby.git
|
|
111
|
+
cd pix_emv_decoder_ruby
|
|
112
|
+
bundle install
|
|
113
|
+
bundle exec rspec
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Contributing
|
|
119
|
+
|
|
120
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/wgirhad/pix_emv_decoder_ruby).
|
|
121
|
+
This project is intended to be a safe, welcoming space for collaboration.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
class Decoder
|
|
5
|
+
def decode(emv, base: '')
|
|
6
|
+
result = {}
|
|
7
|
+
pointer = 0
|
|
8
|
+
|
|
9
|
+
loop do
|
|
10
|
+
pointer, key, value = pick_next(pointer, emv, base)
|
|
11
|
+
|
|
12
|
+
break if key.nil?
|
|
13
|
+
|
|
14
|
+
result[key] = value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
result
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def pick_next(pointer, emv, base)
|
|
23
|
+
rest = emv[pointer..]
|
|
24
|
+
|
|
25
|
+
return nil if rest.empty?
|
|
26
|
+
|
|
27
|
+
key = rest[0...2]
|
|
28
|
+
length = rest[2...4].to_i
|
|
29
|
+
rest = rest[4...]
|
|
30
|
+
value = rest[0...length]
|
|
31
|
+
pointer = pointer + length + 4
|
|
32
|
+
type_key = "#{base}#{key}"
|
|
33
|
+
|
|
34
|
+
result = Types.fetch(type_key).new(type_key, value)
|
|
35
|
+
|
|
36
|
+
[pointer, result.key, result.value]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class AdditionalDataFieldTemplate < Hash
|
|
6
|
+
def key
|
|
7
|
+
:additional_data_field_template
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.key_code
|
|
11
|
+
'62'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
register AdditionalDataFieldTemplate
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class MerchantAccountInformation < Hash
|
|
6
|
+
def key
|
|
7
|
+
:merchant_account_information
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def value
|
|
11
|
+
@value ||= PixEmvDecoderRuby.decode(@raw_value, base:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.key_code
|
|
15
|
+
'26'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def base
|
|
21
|
+
case @raw_value
|
|
22
|
+
when /^0014br.gov.bcb.pix/i then 'pix'
|
|
23
|
+
else @raw_key
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
register MerchantAccountInformation
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class MerchantCategoryCode < String
|
|
6
|
+
def key
|
|
7
|
+
:merchant_category_code
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.key_code
|
|
11
|
+
'52'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
register MerchantCategoryCode
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class PayloadFormatIndicator < String
|
|
6
|
+
def key
|
|
7
|
+
:payload_format_indicator
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.key_code
|
|
11
|
+
'00'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
register PayloadFormatIndicator
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../string'
|
|
4
|
+
|
|
5
|
+
module PixEmvDecoderRuby
|
|
6
|
+
module Types
|
|
7
|
+
module Pix
|
|
8
|
+
class ChavePix < Types::String
|
|
9
|
+
def key
|
|
10
|
+
:chave_pix
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.key_code
|
|
14
|
+
'pix01'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
register Pix::ChavePix
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../string'
|
|
4
|
+
|
|
5
|
+
module PixEmvDecoderRuby
|
|
6
|
+
module Types
|
|
7
|
+
module Pix
|
|
8
|
+
class GloballyUniqueIdentifier < Types::String
|
|
9
|
+
def key
|
|
10
|
+
:globally_unique_identifier
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.key_code
|
|
14
|
+
'pix00'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
register Pix::GloballyUniqueIdentifier
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../string'
|
|
4
|
+
|
|
5
|
+
module PixEmvDecoderRuby
|
|
6
|
+
module Types
|
|
7
|
+
module Pix
|
|
8
|
+
class InformacoesAdicionais < Types::String
|
|
9
|
+
def key
|
|
10
|
+
:informacoes_adicionais
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.key_code
|
|
14
|
+
'pix02'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
register Pix::InformacoesAdicionais
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../string'
|
|
4
|
+
|
|
5
|
+
module PixEmvDecoderRuby
|
|
6
|
+
module Types
|
|
7
|
+
module Pix
|
|
8
|
+
class Url < Types::String
|
|
9
|
+
def key
|
|
10
|
+
:url
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.key_code
|
|
14
|
+
'pix25'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
register Pix::Url
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class PointOfInitialMethod < String
|
|
6
|
+
def key
|
|
7
|
+
:point_of_initial_method
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.key_code
|
|
11
|
+
'01'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
register PointOfInitialMethod
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class TransactionCurrency < String
|
|
6
|
+
def key
|
|
7
|
+
:transaction_currency
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.key_code
|
|
11
|
+
'53'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def value
|
|
15
|
+
{ '008' => :all,
|
|
16
|
+
'012' => :dzd,
|
|
17
|
+
'032' => :ars,
|
|
18
|
+
'036' => :aud,
|
|
19
|
+
'044' => :bsd,
|
|
20
|
+
'048' => :bhd,
|
|
21
|
+
'050' => :bdt,
|
|
22
|
+
'051' => :amd,
|
|
23
|
+
'052' => :bbd,
|
|
24
|
+
'060' => :bmd,
|
|
25
|
+
'064' => :btn,
|
|
26
|
+
'068' => :bob,
|
|
27
|
+
'072' => :bwp,
|
|
28
|
+
'084' => :bzd,
|
|
29
|
+
'090' => :sbd,
|
|
30
|
+
'096' => :bnd,
|
|
31
|
+
'104' => :mmk,
|
|
32
|
+
'108' => :bif,
|
|
33
|
+
'116' => :khr,
|
|
34
|
+
'124' => :cad,
|
|
35
|
+
'132' => :cve,
|
|
36
|
+
'136' => :kyd,
|
|
37
|
+
'144' => :lkr,
|
|
38
|
+
'152' => :clp,
|
|
39
|
+
'156' => :cny,
|
|
40
|
+
'170' => :cop,
|
|
41
|
+
'174' => :kmf,
|
|
42
|
+
'188' => :crc,
|
|
43
|
+
'191' => :hrk,
|
|
44
|
+
'192' => :cup,
|
|
45
|
+
'203' => :czk,
|
|
46
|
+
'208' => :dkk,
|
|
47
|
+
'214' => :dop,
|
|
48
|
+
'222' => :svc,
|
|
49
|
+
'230' => :etb,
|
|
50
|
+
'232' => :ern,
|
|
51
|
+
'238' => :fkp,
|
|
52
|
+
'242' => :fjd,
|
|
53
|
+
'262' => :djf,
|
|
54
|
+
'270' => :gmd,
|
|
55
|
+
'292' => :gip,
|
|
56
|
+
'320' => :gtq,
|
|
57
|
+
'324' => :gnf,
|
|
58
|
+
'328' => :gyd,
|
|
59
|
+
'332' => :htg,
|
|
60
|
+
'340' => :hnl,
|
|
61
|
+
'344' => :hkd,
|
|
62
|
+
'348' => :huf,
|
|
63
|
+
'352' => :isk,
|
|
64
|
+
'356' => :inr,
|
|
65
|
+
'360' => :idr,
|
|
66
|
+
'364' => :irr,
|
|
67
|
+
'368' => :iqd,
|
|
68
|
+
'376' => :ils,
|
|
69
|
+
'388' => :jmd,
|
|
70
|
+
'392' => :jpy,
|
|
71
|
+
'396' => :xad,
|
|
72
|
+
'398' => :kzt,
|
|
73
|
+
'400' => :jod,
|
|
74
|
+
'404' => :kes,
|
|
75
|
+
'408' => :kpw,
|
|
76
|
+
'410' => :krw,
|
|
77
|
+
'414' => :kwd,
|
|
78
|
+
'417' => :kgs,
|
|
79
|
+
'418' => :lak,
|
|
80
|
+
'422' => :lbp,
|
|
81
|
+
'426' => :lsl,
|
|
82
|
+
'430' => :lrd,
|
|
83
|
+
'434' => :lyd,
|
|
84
|
+
'446' => :mop,
|
|
85
|
+
'454' => :mwk,
|
|
86
|
+
'458' => :myr,
|
|
87
|
+
'462' => :mvr,
|
|
88
|
+
'480' => :mur,
|
|
89
|
+
'484' => :mxn,
|
|
90
|
+
'496' => :mnt,
|
|
91
|
+
'498' => :mdl,
|
|
92
|
+
'504' => :mad,
|
|
93
|
+
'512' => :omr,
|
|
94
|
+
'516' => :nad,
|
|
95
|
+
'524' => :npr,
|
|
96
|
+
'532' => :ang,
|
|
97
|
+
'533' => :awg,
|
|
98
|
+
'548' => :vuv,
|
|
99
|
+
'554' => :nzd,
|
|
100
|
+
'558' => :nio,
|
|
101
|
+
'566' => :ngn,
|
|
102
|
+
'578' => :nok,
|
|
103
|
+
'586' => :pkr,
|
|
104
|
+
'590' => :pab,
|
|
105
|
+
'598' => :pgk,
|
|
106
|
+
'600' => :pyg,
|
|
107
|
+
'604' => :pen,
|
|
108
|
+
'608' => :php,
|
|
109
|
+
'634' => :qar,
|
|
110
|
+
'643' => :rub,
|
|
111
|
+
'646' => :rwf,
|
|
112
|
+
'654' => :shp,
|
|
113
|
+
'682' => :sar,
|
|
114
|
+
'690' => :scr,
|
|
115
|
+
'694' => :sll,
|
|
116
|
+
'702' => :sgd,
|
|
117
|
+
'704' => :vnd,
|
|
118
|
+
'706' => :sos,
|
|
119
|
+
'710' => :zar,
|
|
120
|
+
'728' => :ssp,
|
|
121
|
+
'748' => :szl,
|
|
122
|
+
'752' => :sek,
|
|
123
|
+
'756' => :chf,
|
|
124
|
+
'760' => :syp,
|
|
125
|
+
'764' => :thb,
|
|
126
|
+
'776' => :top,
|
|
127
|
+
'780' => :ttd,
|
|
128
|
+
'784' => :aed,
|
|
129
|
+
'788' => :tnd,
|
|
130
|
+
'800' => :ugx,
|
|
131
|
+
'807' => :mkd,
|
|
132
|
+
'818' => :egp,
|
|
133
|
+
'826' => :gbp,
|
|
134
|
+
'834' => :tzs,
|
|
135
|
+
'840' => :usd,
|
|
136
|
+
'858' => :uyu,
|
|
137
|
+
'860' => :uzs,
|
|
138
|
+
'882' => :wst,
|
|
139
|
+
'886' => :yer,
|
|
140
|
+
'901' => :twd,
|
|
141
|
+
'924' => :zwg,
|
|
142
|
+
'925' => :sle,
|
|
143
|
+
'926' => :ved,
|
|
144
|
+
'927' => :uyw,
|
|
145
|
+
'928' => :ves,
|
|
146
|
+
'929' => :mru,
|
|
147
|
+
'930' => :stn,
|
|
148
|
+
'931' => :cuc,
|
|
149
|
+
'932' => :zwl,
|
|
150
|
+
'933' => :byn,
|
|
151
|
+
'934' => :tmt,
|
|
152
|
+
'936' => :ghs,
|
|
153
|
+
'938' => :sdg,
|
|
154
|
+
'940' => :uyi,
|
|
155
|
+
'941' => :rsd,
|
|
156
|
+
'943' => :mzn,
|
|
157
|
+
'944' => :azn,
|
|
158
|
+
'946' => :ron,
|
|
159
|
+
'947' => :che,
|
|
160
|
+
'948' => :chw,
|
|
161
|
+
'949' => :try,
|
|
162
|
+
'950' => :xaf,
|
|
163
|
+
'951' => :xcd,
|
|
164
|
+
'952' => :xof,
|
|
165
|
+
'953' => :xpf,
|
|
166
|
+
'955' => :xba,
|
|
167
|
+
'956' => :xbb,
|
|
168
|
+
'957' => :xbc,
|
|
169
|
+
'958' => :xbd,
|
|
170
|
+
'959' => :xau,
|
|
171
|
+
'960' => :xdr,
|
|
172
|
+
'961' => :xag,
|
|
173
|
+
'962' => :xpt,
|
|
174
|
+
'963' => :xts,
|
|
175
|
+
'964' => :xpd,
|
|
176
|
+
'965' => :xua,
|
|
177
|
+
'967' => :zmw,
|
|
178
|
+
'968' => :srd,
|
|
179
|
+
'969' => :mga,
|
|
180
|
+
'970' => :cou,
|
|
181
|
+
'971' => :afn,
|
|
182
|
+
'972' => :tjs,
|
|
183
|
+
'973' => :aoa,
|
|
184
|
+
'975' => :bgn,
|
|
185
|
+
'976' => :cdf,
|
|
186
|
+
'977' => :bam,
|
|
187
|
+
'978' => :eur,
|
|
188
|
+
'979' => :mxv,
|
|
189
|
+
'980' => :uah,
|
|
190
|
+
'981' => :gel,
|
|
191
|
+
'984' => :bov,
|
|
192
|
+
'985' => :pln,
|
|
193
|
+
'986' => :brl,
|
|
194
|
+
'990' => :clf,
|
|
195
|
+
'994' => :xsu,
|
|
196
|
+
'997' => :usn,
|
|
197
|
+
'999' => :xxx }.fetch(@raw_value, @raw_value)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
register TransactionCurrency
|
|
202
|
+
end
|
|
203
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PixEmvDecoderRuby
|
|
4
|
+
module Types
|
|
5
|
+
class Type
|
|
6
|
+
def initialize(raw_key, raw_value)
|
|
7
|
+
@raw_key = raw_key
|
|
8
|
+
@raw_value = raw_value
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def key
|
|
12
|
+
@raw_key
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def value
|
|
16
|
+
@raw_value
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'types/type'
|
|
4
|
+
require_relative 'types/string'
|
|
5
|
+
require_relative 'types/hash'
|
|
6
|
+
require_relative 'types/decimal'
|
|
7
|
+
|
|
8
|
+
module PixEmvDecoderRuby
|
|
9
|
+
module Types
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def fetch(key)
|
|
13
|
+
types.fetch(key, Types::String)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def register(type)
|
|
17
|
+
types[type.key_code] = type
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def types
|
|
21
|
+
@types ||= {}
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'pix_emv_decoder_ruby/types'
|
|
4
|
+
require_relative 'pix_emv_decoder_ruby/decoder'
|
|
5
|
+
|
|
6
|
+
Dir.glob("#{__dir__}/pix_emv_decoder_ruby/types/**/*.rb").each do |file|
|
|
7
|
+
require file
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module PixEmvDecoderRuby
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
def decode(...)
|
|
14
|
+
Decoder.new.decode(...)
|
|
15
|
+
end
|
|
16
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pix_emv_decoder_ruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Willian Girhad
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-10-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Enables decoding emv strings from pix (copia e cola)
|
|
14
|
+
email: wgirhad@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- lib/pix_emv_decoder_ruby.rb
|
|
21
|
+
- lib/pix_emv_decoder_ruby/decoder.rb
|
|
22
|
+
- lib/pix_emv_decoder_ruby/types.rb
|
|
23
|
+
- lib/pix_emv_decoder_ruby/types/additional_data_field_template.rb
|
|
24
|
+
- lib/pix_emv_decoder_ruby/types/country_code.rb
|
|
25
|
+
- lib/pix_emv_decoder_ruby/types/crc.rb
|
|
26
|
+
- lib/pix_emv_decoder_ruby/types/decimal.rb
|
|
27
|
+
- lib/pix_emv_decoder_ruby/types/hash.rb
|
|
28
|
+
- lib/pix_emv_decoder_ruby/types/merchant_account_information.rb
|
|
29
|
+
- lib/pix_emv_decoder_ruby/types/merchant_category_code.rb
|
|
30
|
+
- lib/pix_emv_decoder_ruby/types/merchant_city.rb
|
|
31
|
+
- lib/pix_emv_decoder_ruby/types/merchant_name.rb
|
|
32
|
+
- lib/pix_emv_decoder_ruby/types/payload_format_indicator.rb
|
|
33
|
+
- lib/pix_emv_decoder_ruby/types/pix/chave_pix.rb
|
|
34
|
+
- lib/pix_emv_decoder_ruby/types/pix/globally_unique_identifier.rb
|
|
35
|
+
- lib/pix_emv_decoder_ruby/types/pix/informacoes_adicionais.rb
|
|
36
|
+
- lib/pix_emv_decoder_ruby/types/pix/url.rb
|
|
37
|
+
- lib/pix_emv_decoder_ruby/types/point_of_initial_method.rb
|
|
38
|
+
- lib/pix_emv_decoder_ruby/types/reference_label.rb
|
|
39
|
+
- lib/pix_emv_decoder_ruby/types/string.rb
|
|
40
|
+
- lib/pix_emv_decoder_ruby/types/transaction_amount.rb
|
|
41
|
+
- lib/pix_emv_decoder_ruby/types/transaction_currency.rb
|
|
42
|
+
- lib/pix_emv_decoder_ruby/types/type.rb
|
|
43
|
+
homepage: https://rubygems.org/gems/pix_emv_decoder_ruby
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata:
|
|
47
|
+
rubygems_mfa_required: 'true'
|
|
48
|
+
post_install_message:
|
|
49
|
+
rdoc_options: []
|
|
50
|
+
require_paths:
|
|
51
|
+
- lib
|
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 3.1.0
|
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
requirements: []
|
|
63
|
+
rubygems_version: 3.5.11
|
|
64
|
+
signing_key:
|
|
65
|
+
specification_version: 4
|
|
66
|
+
summary: Decodes pix emv strings
|
|
67
|
+
test_files: []
|