qrcode_pix_ruby 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52e5a20fafc6b73338560780df06dd35cd0a458e29fe8e3a2a401b723a59a301
4
- data.tar.gz: 8a3307288998e027a9aec36113a7b8dd4d543e97663c60ffd9fda0b6ba99e880
3
+ metadata.gz: 4286f32be5f071b29e6f504834595f8f5dbc0ef1fdced824b76cfef429763c15
4
+ data.tar.gz: 24c12240f5df73f9dff448f1521401e990b0b2f7d3b78b4131a6e5294e14f61e
5
5
  SHA512:
6
- metadata.gz: 6131ff1fabc61f1f3c51fae3ffdf93e6297eddefc98341e25b36bb8de84ca64f7570d62219eaf2ad21a83ac37b4bd762acd93624031e0b835e5faa84b8fe1aa1
7
- data.tar.gz: 9bf41ca90b8a2213264cf7e2ec89f83c959a0ad6c98052624f16ec94ddc6b477b61160f545c7b9243d138ab5e07061f51aa80068f2a5205d7c31b8b1322627a9
6
+ metadata.gz: 71a8669277a170358742ffbb6bbfbb7dc6c0a4d6050640050ae793d329e6af5b535756672f27b156bd9dc22c0c1a465e371cdd0393097e09fdb2074101221f5c
7
+ data.tar.gz: 93e4f118bd2df45b4ed2f56a012808a0d63e40e40e9c5283ad34baf4550684997d434694f14b7227b52f0bdfda42933f5e862763a66be2dd355013d3d154d5c7
@@ -3,6 +3,17 @@ name: CI
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
+ dockerfile:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+
11
+ - name: Build Dockerfile
12
+ run: docker build -t qrcode_pix_ruby_specs .
13
+
14
+ - name: Run tests inside Docker container
15
+ run: docker run -v $(pwd):/app/ -i qrcode_pix_ruby_specs
16
+
6
17
  tests:
7
18
  runs-on: ubuntu-latest
8
19
  strategy:
@@ -18,6 +18,7 @@ jobs:
18
18
  - name: Install dependencies
19
19
  run: |
20
20
  cd demo/
21
+ bundle install
21
22
  bundle update qrcode_pix_ruby
22
23
  cd ../
23
24
 
@@ -41,4 +42,9 @@ jobs:
41
42
  HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }}
42
43
 
43
44
  - name: Publish to Heroku
44
- run: git push heroku `git subtree split --prefix demo master`:master --force
45
+ run: |
46
+ git config user.name 'Pedro Furtado'
47
+ git config user.email 'pedro.felipe.azevedo.furtado@gmail.com'
48
+ git add --all
49
+ git commit -m 'Publish to Heroku'
50
+ git push heroku `git subtree split --prefix demo master`:master --force
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
1
  .rspec_status
2
- *.lock
2
+ /Gemfile.lock
3
3
  *.gem
4
4
  coverage/
5
5
  *.log
data/.rubocop.yml CHANGED
@@ -5,6 +5,9 @@ AllCops:
5
5
  - spec/*
6
6
  - demo/*
7
7
 
8
+ Style/RegexpLiteral:
9
+ Enabled: false
10
+
8
11
  Layout/LineLength:
9
12
  Max: 120
10
13
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2021-07-10
4
+
5
+ - Add URL option for PIX, in order to generate dynamic QR Codes
6
+
3
7
  ## [0.3.4] - 2021-06-28
4
8
 
5
9
  - Fix behavior of EMV field 'repeatable' (the logic was inversed)
data/Dockerfile CHANGED
@@ -1,8 +1,6 @@
1
1
  FROM ruby:3.0.0-alpine
2
2
  RUN apk update && apk add git
3
- RUN mkdir -p /app/
4
- WORKDIR /app/
5
- VOLUME /app/
6
- COPY . /app/
3
+ WORKDIR /app
4
+ COPY . .
7
5
  RUN bundle install
8
6
  CMD bundle exec rake
data/README.md CHANGED
@@ -29,13 +29,14 @@ Or install it yourself as:
29
29
 
30
30
  gem install qrcode_pix_ruby
31
31
 
32
- ## Usage
32
+ ## Usage (examples)
33
+
34
+ ### Static QR Code
33
35
 
34
36
  ```ruby
35
37
  require 'qrcode_pix_ruby'
36
38
 
37
- pix = QrcodePixRuby::Payload.new
38
-
39
+ pix = QrcodePixRuby::Payload.new
39
40
  pix.pix_key = 'minhachavedopix'
40
41
  pix.description = 'Pagamento do pedido 123456'
41
42
  pix.merchant_name = 'Fulano de Tal'
@@ -50,31 +51,31 @@ pix.repeatable = false
50
51
  # QRCode copia-e-cola
51
52
  puts pix.payload
52
53
 
53
- # QRCode estático
54
+ # QRCode para uso em imagens
54
55
  puts pix.base64
55
56
  ```
56
57
 
57
- 🚨 Important note: BACEN (Banco Central do Brasil) sets a variety of rules for each field in QRCode Payload (maximum number of characters, invalid values, mandatory and optional fields, and so on). So, pay attention that a QRCode payload+base64 generated by the gem can be valid, theorically, but may not be accepted in banking apps because of these restrictions (that are out of scope of gem).
58
+ ### Dynamic QR Code
58
59
 
59
- ## Useful links
60
+ ```ruby
61
+ require 'qrcode_pix_ruby'
60
62
 
61
- * https://github.com/joseviniciusnunes/qrcode-pix
62
- * https://www.bcb.gov.br/content/estabilidadefinanceira/forumpireunioes/AnexoI-PadroesParaIniciacaodoPix.pdf
63
- * https://github.com/renatomb/php_qrcode_pix
64
- * https://www.gerarpix.com.br
65
- * https://github.com/fbbergamo/gerador-pix
66
- * https://pix.ae
67
- * https://pix.nascent.com.br/tools/pix-qr-decoder
68
- * https://openpix.com.br/qrcode/scanner
69
- * https://openpix.com.br/qrcode/debug
70
- * https://github.com/william-costa/wdev-qrcode-pix-estatico-php
71
- * https://www.youtube.com/watch?v=eO11iFgrdCA
72
- * https://qrcodepix.dinheiro.tech
73
- * http://decoder.qrcodepix.dinheiro.tech
74
- * https://www.bcb.gov.br/estabilidadefinanceira/pix
75
- * https://gerencianet.com.br/blog/qr-code-estatico-qr-code-dinamico-no-pix
76
- * https://blog.juno.com.br/pix-qr-code-estatico-x-qr-code-dinamico
77
- * https://github.com/entria/awesome-pix
63
+ pix = QrcodePixRuby::Payload.new
64
+ pix.url = 'https://example.com'
65
+ pix.merchant_name = 'Fulano de Tal'
66
+ pix.merchant_city = 'SAO PAULO'
67
+ pix.amount = '100.00'
68
+ pix.transaction_id = 'TID12345'
69
+ pix.repeatable = false
70
+
71
+ # QRCode copia-e-cola
72
+ puts pix.payload
73
+
74
+ # QRCode para uso em imagens
75
+ puts pix.base64
76
+ ```
77
+
78
+ 🚨 Important note: BACEN (Banco Central do Brasil) sets a variety of rules for each field in QRCode Payload (maximum number of characters, invalid values, mandatory and optional fields, and so on). So, pay attention that a QRCode payload+base64 generated by the gem can be valid, theorically, but may not be accepted in banking apps because of these restrictions (that are out of scope of gem).
78
79
 
79
80
  ## Execute tests/specs
80
81
 
@@ -93,12 +94,38 @@ docker run -v $(pwd):/app/ -it qrcode_pix_ruby_specs
93
94
 
94
95
  ## Demo
95
96
 
96
- It's provided a simple demo app, in Heroku, that uses the gem always in latest stable. You can check and test your QRCodes here:
97
+ It's provided a simple demo app, in Heroku, that uses the gem always in latest commit. You can check and test your QRCodes here:
97
98
 
98
99
  https://qrcode-pix-ruby.herokuapp.com
99
100
 
100
101
  🚨 Important note: The first page load can be slow, because of Heroku free tier. But don't worry, the demo works well 🤓
101
102
 
103
+ ## Useful links
104
+
105
+ * https://github.com/joseviniciusnunes/qrcode-pix
106
+ * https://www.bcb.gov.br/content/estabilidadefinanceira/forumpireunioes/AnexoI-PadroesParaIniciacaodoPix.pdf
107
+ * https://github.com/renatomb/php_qrcode_pix
108
+ * https://www.gerarpix.com.br
109
+ * https://github.com/fbbergamo/gerador-pix
110
+ * https://pix.ae
111
+ * https://pix.nascent.com.br/tools/pix-qr-decoder
112
+ * https://openpix.com.br/qrcode/scanner
113
+ * https://openpix.com.br/qrcode/debug
114
+ * https://github.com/william-costa/wdev-qrcode-pix-estatico-php
115
+ * https://github.com/william-costa/wdev-qrcode-pix-php
116
+ * https://www.youtube.com/watch?v=eO11iFgrdCA
117
+ * https://qrcodepix.dinheiro.tech
118
+ * http://decoder.qrcodepix.dinheiro.tech
119
+ * https://www.bcb.gov.br/estabilidadefinanceira/pix
120
+ * https://gerencianet.com.br/blog/qr-code-estatico-qr-code-dinamico-no-pix
121
+ * https://blog.juno.com.br/pix-qr-code-estatico-x-qr-code-dinamico
122
+ * https://github.com/entria/awesome-pix
123
+ * https://zxing.org/w/decode.jspx
124
+ * https://github.com/hiagodotme/gpix
125
+ * https://github.com/EnssureIT/faz-um-pix
126
+ * https://github.com/jesobreira/pixkey
127
+ * https://github.com/pedrinholemes/pix-br
128
+
102
129
  ## Contributing
103
130
 
104
131
  Bug reports and pull requests are welcome on GitHub at https://github.com/pedrofurtado/qrcode_pix_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pedrofurtado/qrcode_pix_ruby/blob/master/CODE_OF_CONDUCT.md).
data/demo/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  source 'https://rubygems.org'
4
- gem 'qrcode_pix_ruby'
4
+ gem 'qrcode_pix_ruby', github: 'pedrofurtado/qrcode_pix_ruby', branch: 'master'
5
5
  gem 'rack'
data/demo/config.ru CHANGED
@@ -10,6 +10,7 @@ def generate_html_with(env)
10
10
 
11
11
  unless qrcode_data.empty?
12
12
  pix.pix_key = qrcode_data['pix_key'] unless qrcode_data['pix_key'].nil?
13
+ pix.url = qrcode_data['url'] unless qrcode_data['url'].nil?
13
14
  pix.description = qrcode_data['description'] unless qrcode_data['description'].nil?
14
15
  pix.merchant_name = qrcode_data['merchant_name'] unless qrcode_data['merchant_name'].nil?
15
16
  pix.merchant_city = qrcode_data['merchant_city'] unless qrcode_data['merchant_city'].nil?
@@ -63,7 +64,11 @@ def generate_html_with(env)
63
64
  <form action='https://qrcode-pix-ruby.herokuapp.com' method='post'>
64
65
  <div class='mb-3'>
65
66
  <label for='pix_key'>Pix key</label>
66
- <input required type='text' class='form-control' id='pix_key' value='#{qrcode_data["pix_key"]}' name='pix_key'>
67
+ <input type='text' class='form-control' id='pix_key' value='#{qrcode_data["pix_key"]}' name='pix_key'>
68
+ </div>
69
+ <div class='mb-3'>
70
+ <label for='url'>URL</label>
71
+ <input type='text' class='form-control' id='url' value='#{qrcode_data["url"]}' name='url'>
67
72
  </div>
68
73
  <div class='mb-3'>
69
74
  <label for='description'>Description</label>
@@ -99,7 +104,7 @@ def generate_html_with(env)
99
104
  </div>
100
105
  <div class='mb-3'>
101
106
  <label for='postal_code'>Postal code</label>
102
- <input required type='text' class='form-control' id='postal_code' value='#{qrcode_data["postal_code"]}' name='postal_code'>
107
+ <input type='text' class='form-control' id='postal_code' value='#{qrcode_data["postal_code"]}' name='postal_code'>
103
108
  </div>
104
109
  <div class='mb-3'>
105
110
  <label for='repeatable'>Repeatable?</label>
@@ -127,8 +132,7 @@ def generate_html_with(env)
127
132
  </div>
128
133
  <script>
129
134
  new ClipboardJS('.btn-clipboard');
130
-
131
- Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]')).forEach(function (tooltipTriggerEl) {
135
+ Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]')).forEach(function(tooltipTriggerEl) {
132
136
  new bootstrap.Tooltip(tooltipTriggerEl);
133
137
  });
134
138
  </script>
@@ -10,6 +10,7 @@ module QrcodePixRuby
10
10
  ID_MERCHANT_ACCOUNT_INFORMATION_GUI = '00'
11
11
  ID_MERCHANT_ACCOUNT_INFORMATION_KEY = '01'
12
12
  ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = '02'
13
+ ID_MERCHANT_ACCOUNT_INFORMATION_URL = '25'
13
14
  ID_MERCHANT_CATEGORY_CODE = '52'
14
15
  ID_TRANSACTION_CURRENCY = '53'
15
16
  ID_TRANSACTION_AMOUNT = '54'
@@ -22,6 +23,7 @@ module QrcodePixRuby
22
23
  ID_CRC16 = '63'
23
24
 
24
25
  attr_accessor :pix_key,
26
+ :url,
25
27
  :repeatable,
26
28
  :currency,
27
29
  :country_code,
@@ -77,9 +79,10 @@ module QrcodePixRuby
77
79
 
78
80
  def emv_merchant
79
81
  merchant_gui = emv(ID_MERCHANT_ACCOUNT_INFORMATION_GUI, 'BR.GOV.BCB.PIX')
80
- merchant_pix_key = emv(ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key)
82
+ merchant_pix_key = emv(ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key) if pix_key
81
83
  merchant_description = emv(ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION, description) if description
82
- emv(ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}")
84
+ merchant_url = emv(ID_MERCHANT_ACCOUNT_INFORMATION_URL, url.gsub(/https?:\/\//, '')) if url
85
+ emv(ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}#{merchant_url}")
83
86
  end
84
87
 
85
88
  def emv_additional_data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QrcodePixRuby
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrcode_pix_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Furtado
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-06-29 00:00:00.000000000 Z
14
+ date: 2021-07-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rqrcode
@@ -96,7 +96,6 @@ files:
96
96
  - bin/console
97
97
  - bin/setup
98
98
  - demo/Gemfile
99
- - demo/Gemfile.lock
100
99
  - demo/config.ru
101
100
  - lib/qrcode_pix_ruby.rb
102
101
  - lib/qrcode_pix_ruby/payload.rb
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  - !ruby/object:Gem::Version
126
125
  version: '0'
127
126
  requirements: []
128
- rubygems_version: 3.2.15
127
+ rubygems_version: 3.2.22
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro -
data/demo/Gemfile.lock DELETED
@@ -1,21 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- chunky_png (1.4.0)
5
- qrcode_pix_ruby (0.3.3)
6
- rqrcode
7
- rack (2.2.3)
8
- rqrcode (2.0.0)
9
- chunky_png (~> 1.0)
10
- rqrcode_core (~> 1.0)
11
- rqrcode_core (1.0.0)
12
-
13
- PLATFORMS
14
- x86_64-linux
15
-
16
- DEPENDENCIES
17
- qrcode_pix_ruby
18
- rack
19
-
20
- BUNDLED WITH
21
- 2.2.21