qrcode_pix_ruby 0.2.0 → 0.3.4

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: 35b4d652b206592b48976ae27f1c3e461d53b9b90ba6d7d3845e8578ff38d2d5
4
- data.tar.gz: 3718c9e90ca609015f5eec3531ff3c35fd0945be24f5e06430e2e3b1278fb4d7
3
+ metadata.gz: 52e5a20fafc6b73338560780df06dd35cd0a458e29fe8e3a2a401b723a59a301
4
+ data.tar.gz: 8a3307288998e027a9aec36113a7b8dd4d543e97663c60ffd9fda0b6ba99e880
5
5
  SHA512:
6
- metadata.gz: bf822ee3996b5d30ad39068e3e20d5b7114556defb15d3265a5e30bb6f076f6b0018fdf4cbc7eafac1d91ceea927a92891ea9649402d4663e713a83fcfe8c441
7
- data.tar.gz: 7771a3304e461bf393b38841ed4d14c18b83c55e69399245e92502d459fbbe55ff96447383579504a7c765fd7f89c17ccf818b544cce8a4d994429f0dc4d5823
6
+ metadata.gz: 6131ff1fabc61f1f3c51fae3ffdf93e6297eddefc98341e25b36bb8de84ca64f7570d62219eaf2ad21a83ac37b4bd762acd93624031e0b835e5faa84b8fe1aa1
7
+ data.tar.gz: 9bf41ca90b8a2213264cf7e2ec89f83c959a0ad6c98052624f16ec94ddc6b477b61160f545c7b9243d138ab5e07061f51aa80068f2a5205d7c31b8b1322627a9
@@ -3,11 +3,13 @@ name: CI
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- ci:
6
+ tests:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: [2.7, 3.0]
10
+ ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
11
+ env:
12
+ CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
11
13
  steps:
12
14
  - uses: actions/checkout@v2
13
15
 
@@ -0,0 +1,44 @@
1
+ name: Publish to Heroku
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+
13
+ - name: Install Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 3.0
17
+
18
+ - name: Install dependencies
19
+ run: |
20
+ cd demo/
21
+ bundle update qrcode_pix_ruby
22
+ cd ../
23
+
24
+ - name: Define Heroku credentials
25
+ run: |
26
+ cat > ~/.netrc <<EOF
27
+ machine api.heroku.com
28
+ login $HEROKU_EMAIL
29
+ password $HEROKU_API_KEY
30
+ machine git.heroku.com
31
+ login $HEROKU_EMAIL
32
+ password $HEROKU_API_KEY
33
+ EOF
34
+ env:
35
+ HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
36
+ HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
37
+
38
+ - name: Define Heroku git remote
39
+ run: heroku git:remote --app $HEROKU_APP_NAME
40
+ env:
41
+ HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }}
42
+
43
+ - name: Publish to Heroku
44
+ run: git push heroku `git subtree split --prefix demo master`:master --force
@@ -5,7 +5,7 @@ on:
5
5
  types: [created]
6
6
 
7
7
  jobs:
8
- publish-to-rubygems:
8
+ deploy:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
11
  - uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  .rspec_status
2
2
  *.lock
3
3
  *.gem
4
+ coverage/
5
+ *.log
data/.rubocop.yml ADDED
@@ -0,0 +1,35 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ Exclude:
5
+ - spec/*
6
+ - demo/*
7
+
8
+ Layout/LineLength:
9
+ Max: 120
10
+ Exclude:
11
+ - qrcode_pix_ruby.gemspec
12
+
13
+ Metrics/MethodLength:
14
+ Max: 20
15
+
16
+ Gemspec/RequiredRubyVersion:
17
+ Enabled: false
18
+
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Metrics/AbcSize:
23
+ Enabled: false
24
+
25
+ Metrics/BlockNesting:
26
+ Enabled: false
27
+
28
+ Style/IfUnlessModifier:
29
+ Enabled: false
30
+
31
+ Metrics/CyclomaticComplexity:
32
+ Enabled: false
33
+
34
+ Metrics/PerceivedComplexity:
35
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2021-06-23
3
+ ## [0.3.4] - 2021-06-28
4
+
5
+ - Fix behavior of EMV field 'repeatable' (the logic was inversed)
6
+
7
+ ## [0.3.3] - 2021-06-25
8
+
9
+ - Rubocop setup
10
+ - Add rubies 2.3, 2.4, 2.5 and 2.6 to support of gem
11
+
12
+ ## [0.3.2] - 2021-06-24
13
+
14
+ - Setup for run tests/specs locally with Docker
15
+
16
+ ## [0.3.1] - 2021-06-24
17
+
18
+ - More documentation
19
+
20
+ ## [0.1.0...0.3.0] - 2021-06-24
4
21
 
5
22
  - Initial release
23
+ - Setup of CI and integrations
24
+ - Skeleton of gem
data/Dockerfile ADDED
@@ -0,0 +1,8 @@
1
+ FROM ruby:3.0.0-alpine
2
+ RUN apk update && apk add git
3
+ RUN mkdir -p /app/
4
+ WORKDIR /app/
5
+ VOLUME /app/
6
+ COPY . /app/
7
+ RUN bundle install
8
+ CMD bundle exec rake
data/Gemfile CHANGED
@@ -2,3 +2,4 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
  gemspec
5
+ gem 'codecov', require: false, group: :test
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 TODO: Write your name
3
+ Copyright (c)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,11 +1,17 @@
1
1
  # QRCode Pix Ruby
2
2
 
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/ff1952ca066c27953773/maintainability)](https://codeclimate.com/github/pedrofurtado/qrcode_pix_ruby/maintainability)
4
+ [![codecov](https://codecov.io/gh/pedrofurtado/qrcode_pix_ruby/branch/master/graph/badge.svg?token=OK3S19R5CG)](https://codecov.io/gh/pedrofurtado/qrcode_pix_ruby)
3
5
  [![CI](https://github.com/pedrofurtado/qrcode_pix_ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/pedrofurtado/qrcode_pix_ruby/actions/workflows/ci.yml)
4
6
  [![Gem Version](https://badge.fury.io/rb/qrcode_pix_ruby.svg)](https://badge.fury.io/rb/qrcode_pix_ruby)
5
7
  [![Gem](https://img.shields.io/gem/dt/qrcode_pix_ruby.svg)]()
6
8
  [![license](https://img.shields.io/github/license/pedrofurtado/qrcode_pix_ruby.svg)]()
9
+ [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pedrofurtado/qrcode_pix_ruby)
10
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
11
 
8
- Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)
12
+ Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil).
13
+
14
+ <img style="max-width: 100%;" src="https://github.com/pedrofurtado/qrcode_pix_ruby/blob/master/pix_logo.png?raw=true" height="100px" />
9
15
 
10
16
  ## Installation
11
17
 
@@ -30,21 +36,31 @@ require 'qrcode_pix_ruby'
30
36
 
31
37
  pix = QrcodePixRuby::Payload.new
32
38
 
33
- pix.pix_key = '12345678900'
39
+ pix.pix_key = 'minhachavedopix'
34
40
  pix.description = 'Pagamento do pedido 123456'
35
- pix.merchant_name = 'William Costa'
41
+ pix.merchant_name = 'Fulano de Tal'
36
42
  pix.merchant_city = 'SAO PAULO'
37
- pix.transaction_id = 'WDEV1234'
43
+ pix.transaction_id = 'TID12345'
38
44
  pix.amount = '100.00'
45
+ pix.currency = '986'
46
+ pix.country_code = 'BR'
47
+ pix.postal_code = '01131010'
39
48
  pix.repeatable = false
40
49
 
50
+ # QRCode copia-e-cola
41
51
  puts pix.payload
52
+
53
+ # QRCode estático
42
54
  puts pix.base64
43
55
  ```
44
56
 
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
+
45
59
  ## Useful links
46
60
 
47
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
48
64
  * https://www.gerarpix.com.br
49
65
  * https://github.com/fbbergamo/gerador-pix
50
66
  * https://pix.ae
@@ -53,6 +69,35 @@ puts pix.base64
53
69
  * https://openpix.com.br/qrcode/debug
54
70
  * https://github.com/william-costa/wdev-qrcode-pix-estatico-php
55
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
78
+
79
+ ## Execute tests/specs
80
+
81
+ To execute gem tests locally, use Docker with the commands below:
82
+
83
+ ```bash
84
+ git clone https://github.com/pedrofurtado/qrcode_pix_ruby
85
+ cd qrcode_pix_ruby/
86
+ docker build -t qrcode_pix_ruby_specs .
87
+
88
+ # Then, run this command how many times you want,
89
+ # after editing local files, and so on, to get
90
+ # feedback from test suite of gem.
91
+ docker run -v $(pwd):/app/ -it qrcode_pix_ruby_specs
92
+ ```
93
+
94
+ ## Demo
95
+
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
+
98
+ https://qrcode-pix-ruby.herokuapp.com
99
+
100
+ 🚨 Important note: The first page load can be slow, because of Heroku free tier. But don't worry, the demo works well 🤓
56
101
 
57
102
  ## Contributing
58
103
 
data/Rakefile CHANGED
@@ -2,5 +2,7 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
5
6
  RSpec::Core::RakeTask.new(:spec)
6
- task default: %i[spec]
7
+ RuboCop::RakeTask.new
8
+ task default: %i[spec rubocop]
data/demo/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gem 'qrcode_pix_ruby'
5
+ gem 'rack'
data/demo/config.ru ADDED
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'qrcode_pix_ruby'
4
+
5
+ def generate_html_with(env)
6
+ qrcode_data = Rack::Request.new(env).params
7
+ payload = ''
8
+ data_uri = ''
9
+ pix = QrcodePixRuby::Payload.new
10
+
11
+ unless qrcode_data.empty?
12
+ pix.pix_key = qrcode_data['pix_key'] unless qrcode_data['pix_key'].nil?
13
+ pix.description = qrcode_data['description'] unless qrcode_data['description'].nil?
14
+ pix.merchant_name = qrcode_data['merchant_name'] unless qrcode_data['merchant_name'].nil?
15
+ pix.merchant_city = qrcode_data['merchant_city'] unless qrcode_data['merchant_city'].nil?
16
+ pix.transaction_id = qrcode_data['transaction_id'] unless qrcode_data['transaction_id'].nil?
17
+ pix.amount = qrcode_data['amount'] unless qrcode_data['amount'].nil?
18
+ pix.currency = qrcode_data['currency'] unless qrcode_data['currency'].nil?
19
+ pix.country_code = qrcode_data['country_code'] unless qrcode_data['country_code'].nil?
20
+ pix.postal_code = qrcode_data['postal_code'] unless qrcode_data['postal_code'].nil?
21
+ pix.repeatable = qrcode_data['repeatable'] == 't' unless qrcode_data['repeatable'].nil?
22
+
23
+ payload = <<-HTML
24
+ <label for='payload'>Payload</label>
25
+ <div class='input-group mb-3'>
26
+ <input class='form-control' id='payload' value='#{pix.payload}'>
27
+ <button class='btn btn-outline-success btn-clipboard' data-clipboard-target='#payload' data-bs-toggle='tooltip' data-bs-placement='top' title='Copied!' data-bs-trigger='click'>Copy</button>
28
+ </div>
29
+ HTML
30
+
31
+ data_uri = "<img style='max-width: 100%;' src='#{pix.base64}'>"
32
+ end
33
+
34
+ StringIO.new <<-HTML
35
+ <!DOCTYPE html>
36
+ <html>
37
+ <head>
38
+ <meta charset='utf-8'>
39
+ <meta name='viewport' content='width=device-width, initial-scale=1'>
40
+ <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css' rel='stylesheet'>
41
+ <script src='https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js'></script>
42
+ <script src='https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js'></script>
43
+ <title>QRCode Pix Ruby - Demo App</title>
44
+ </head>
45
+ <body>
46
+ <div class='container' style='margin-top: 50px;'>
47
+ <div class='row'>
48
+ <div class='col-md-12'>
49
+ <h1 class='text-center'>QRCode Pix Ruby - Demo App</h1>
50
+ <br>
51
+ <img style='display: block; margin: 0 auto; max-width: 100%;' src="https://github.com/pedrofurtado/qrcode_pix_ruby/blob/master/pix_logo.png?raw=true" height="100px" />
52
+ <br>
53
+ <p style='word-break: break-all;' class='text-center'>For more details check the official repo: <a href="https://github.com/pedrofurtado/qrcode_pix_ruby">https://github.com/pedrofurtado/qrcode_pix_ruby</a></p>
54
+ <br>
55
+ <br>
56
+ </div>
57
+ </div>
58
+ <div class='row' style='padding-bottom: 50px;'>
59
+ <div class='col-sm-6'>
60
+ <strong>QRCode informations</strong>
61
+ <br>
62
+ <br>
63
+ <form action='https://qrcode-pix-ruby.herokuapp.com' method='post'>
64
+ <div class='mb-3'>
65
+ <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
+ </div>
68
+ <div class='mb-3'>
69
+ <label for='description'>Description</label>
70
+ <input required type='text' class='form-control' id='description' value='#{qrcode_data["description"]}' name='description'>
71
+ </div>
72
+ <div class='mb-3'>
73
+ <label for='merchant_name'>Merchant name</label>
74
+ <input required type='text' class='form-control' id='merchant_name' value='#{qrcode_data["merchant_name"]}' name='merchant_name'>
75
+ </div>
76
+ <div class='mb-3'>
77
+ <label for='merchant_city'>Merchant city</label>
78
+ <input required type='text' class='form-control' id='merchant_city' value='#{qrcode_data["merchant_city"]}' name='merchant_city'>
79
+ </div>
80
+ <div class='mb-3'>
81
+ <label for='transaction_id'>Transaction ID</label>
82
+ <input required type='text' class='form-control' id='transaction_id' value='#{qrcode_data["transaction_id"]}' name='transaction_id'>
83
+ </div>
84
+ <div class='mb-3'>
85
+ <label for='amount'>Amount</label>
86
+ <input required type='text' class='form-control' id='amount' value='#{qrcode_data["amount"]}' name='amount'>
87
+ </div>
88
+ <div class='mb-3'>
89
+ <label for='currency'>Currency</label>
90
+ <select required id='currency' name='currency' class='form-select'>
91
+ <option value='986' selected>Brazilian Real (R$)</option>
92
+ </select>
93
+ </div>
94
+ <div class='mb-3'>
95
+ <label for='country_code'>Country</label>
96
+ <select required id='country_code' name='country_code' class='form-select'>
97
+ <option value='BR' selected>Brazil</option>
98
+ </select>
99
+ </div>
100
+ <div class='mb-3'>
101
+ <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'>
103
+ </div>
104
+ <div class='mb-3'>
105
+ <label for='repeatable'>Repeatable?</label>
106
+ <select required id='repeatable' name='repeatable' class='form-select'>
107
+ <option selected></option>
108
+ <option value='t'>Yes</option>
109
+ <option value='f'>No</option>
110
+ </select>
111
+ </div>
112
+ <div class='d-grid gap-2'>
113
+ <button type='submit' class='btn btn-lg btn-primary'>Generate</button>
114
+ </div>
115
+ </form>
116
+ </div>
117
+ <div class='col-sm-6'>
118
+ <strong>Preview</strong>
119
+ <br>
120
+ <br>
121
+ #{payload}
122
+ <br>
123
+ <br>
124
+ #{data_uri}
125
+ </div>
126
+ </div>
127
+ </div>
128
+ <script>
129
+ new ClipboardJS('.btn-clipboard');
130
+
131
+ Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]')).forEach(function (tooltipTriggerEl) {
132
+ new bootstrap.Tooltip(tooltipTriggerEl);
133
+ });
134
+ </script>
135
+ </body>
136
+ </html>
137
+ HTML
138
+ end
139
+
140
+ run lambda { |env|
141
+ [
142
+ 200,
143
+ {
144
+ 'Content-Type' => 'text/html'
145
+ },
146
+ generate_html_with(env)
147
+ ]
148
+ }
@@ -4,22 +4,22 @@ require 'rqrcode'
4
4
 
5
5
  module QrcodePixRuby
6
6
  class Payload
7
- ID_PAYLOAD_FORMAT_INDICATOR = '00'.freeze
8
- ID_POINT_OF_INITIATION_METHOD = '01'.freeze
9
- ID_MERCHANT_ACCOUNT_INFORMATION = '26'.freeze
10
- ID_MERCHANT_ACCOUNT_INFORMATION_GUI = '00'.freeze
11
- ID_MERCHANT_ACCOUNT_INFORMATION_KEY = '01'.freeze
12
- ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = '02'.freeze
13
- ID_MERCHANT_CATEGORY_CODE = '52'.freeze
14
- ID_TRANSACTION_CURRENCY = '53'.freeze
15
- ID_TRANSACTION_AMOUNT = '54'.freeze
16
- ID_COUNTRY_CODE = '58'.freeze
17
- ID_MERCHANT_NAME = '59'.freeze
18
- ID_MERCHANT_CITY = '60'.freeze
19
- ID_POSTAL_CODE = '61'.freeze
20
- ID_ADDITIONAL_DATA_FIELD_TEMPLATE = '62'.freeze
21
- ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID = '05'.freeze
22
- ID_CRC16 = '63'.freeze
7
+ ID_PAYLOAD_FORMAT_INDICATOR = '00'
8
+ ID_POINT_OF_INITIATION_METHOD = '01'
9
+ ID_MERCHANT_ACCOUNT_INFORMATION = '26'
10
+ ID_MERCHANT_ACCOUNT_INFORMATION_GUI = '00'
11
+ ID_MERCHANT_ACCOUNT_INFORMATION_KEY = '01'
12
+ ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = '02'
13
+ ID_MERCHANT_CATEGORY_CODE = '52'
14
+ ID_TRANSACTION_CURRENCY = '53'
15
+ ID_TRANSACTION_AMOUNT = '54'
16
+ ID_COUNTRY_CODE = '58'
17
+ ID_MERCHANT_NAME = '59'
18
+ ID_MERCHANT_CITY = '60'
19
+ ID_POSTAL_CODE = '61'
20
+ ID_ADDITIONAL_DATA_FIELD_TEMPLATE = '62'
21
+ ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID = '05'
22
+ ID_CRC16 = '63'
23
23
 
24
24
  attr_accessor :pix_key,
25
25
  :repeatable,
@@ -33,7 +33,7 @@ module QrcodePixRuby
33
33
  :amount
34
34
 
35
35
  def payload
36
- p = ''
36
+ p = ''
37
37
 
38
38
  p += emv(ID_PAYLOAD_FORMAT_INDICATOR, '01')
39
39
  p += emv_repeatable
@@ -51,7 +51,17 @@ module QrcodePixRuby
51
51
  end
52
52
 
53
53
  def base64
54
- ::RQRCode::QRCode.new(payload).as_png(bit_depth: 1, border_modules: 0, color_mode: 0, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 200).to_data_url
54
+ ::RQRCode::QRCode.new(payload).as_png(
55
+ bit_depth: 1,
56
+ border_modules: 0,
57
+ color_mode: 0,
58
+ color: 'black',
59
+ file: nil,
60
+ fill: 'white',
61
+ module_px_size: 6,
62
+ resize_exactly_to: false,
63
+ resize_gte_to: false
64
+ ).to_data_url
55
65
  end
56
66
 
57
67
  private
@@ -62,45 +72,38 @@ module QrcodePixRuby
62
72
  end
63
73
 
64
74
  def emv_repeatable
65
- emv(ID_POINT_OF_INITIATION_METHOD, repeatable ? '12' : '11')
75
+ emv(ID_POINT_OF_INITIATION_METHOD, repeatable ? '11' : '12')
66
76
  end
67
77
 
68
78
  def emv_merchant
69
- merchant_gui = emv ID_MERCHANT_ACCOUNT_INFORMATION_GUI, 'BR.GOV.BCB.PIX'
70
- merchant_pix_key = emv ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key
79
+ merchant_gui = emv(ID_MERCHANT_ACCOUNT_INFORMATION_GUI, 'BR.GOV.BCB.PIX')
80
+ merchant_pix_key = emv(ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key)
71
81
  merchant_description = emv(ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION, description) if description
72
-
73
- emv ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}"
82
+ emv(ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}")
74
83
  end
75
84
 
76
85
  def emv_additional_data
77
86
  txid = emv(ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID, transaction_id || '***')
78
- emv ID_ADDITIONAL_DATA_FIELD_TEMPLATE, txid
87
+ emv(ID_ADDITIONAL_DATA_FIELD_TEMPLATE, txid)
79
88
  end
80
89
 
81
- def crc16(t)
82
- extended_payload = "#{t}#{ID_CRC16}04"
90
+ def crc16(text)
91
+ extended_payload = "#{text}#{ID_CRC16}04"
83
92
  extended_payload_length = extended_payload.length
84
93
  polynomial = 0x1021
85
94
  result = 0xFFFF
86
95
 
87
- if extended_payload_length > 0
96
+ if extended_payload_length.positive?
88
97
  offset = 0
89
98
 
90
99
  while offset < extended_payload_length
91
- result = result ^ (extended_payload[offset].bytes[0] << 8)
92
-
100
+ result ^= extended_payload[offset].bytes[0] << 8
93
101
  bitwise = 0
94
102
 
95
103
  while bitwise < 8
96
- result = result << 1
97
-
98
- if result & 0x10000 != 0
99
- result = result ^ polynomial
100
- end
101
-
102
- result = result & 0xFFFF
103
-
104
+ result <<= 1
105
+ result ^= polynomial if result & 0x10000 != 0
106
+ result &= 0xFFFF
104
107
  bitwise += 1
105
108
  end
106
109
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QrcodePixRuby
4
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.3.4'
5
5
  end
data/pix_logo.png ADDED
Binary file
@@ -5,15 +5,16 @@ require_relative 'lib/qrcode_pix_ruby/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'qrcode_pix_ruby'
7
7
  spec.version = QrcodePixRuby::VERSION
8
- spec.authors = ["Pedro Furtado"]
9
- spec.email = ["pedro.felipe.azevedo.furtado@gmail.com"]
10
- spec.summary = "Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)"
11
- spec.description = "Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)"
12
- spec.homepage = "https://github.com/pedrofurtado/qrcode_pix_ruby"
13
- spec.license = "MIT"
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = spec.homepage
16
- spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
8
+ spec.authors = ['Pedro Furtado', 'Marcio de Jesus', 'William Radi', 'Leonardo Comar']
9
+ spec.email = ['pedro.felipe.azevedo.furtado@gmail.com', 'marciodejesusrj@gmail.com', 'williamw@lbv.org.br', 'lfcomar@lbv.org.br']
10
+ spec.summary = 'Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)'
11
+ spec.description = 'Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)'
12
+ spec.homepage = 'https://github.com/pedrofurtado/qrcode_pix_ruby'
13
+ spec.license = 'MIT'
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
17
+ spec.required_ruby_version = '>= 2.3.0'
17
18
 
18
19
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
@@ -23,7 +24,8 @@ Gem::Specification.new do |spec|
23
24
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
25
  spec.require_paths = ['lib']
25
26
 
26
- spec.add_dependency 'rake', '~> 13.0'
27
- spec.add_dependency 'rspec', '~> 3.0'
28
- spec.add_dependency 'rqrcode', '~> 2.0'
27
+ spec.add_dependency 'rqrcode'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rubocop'
29
31
  end
metadata CHANGED
@@ -1,80 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrcode_pix_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Furtado
8
+ - Marcio de Jesus
9
+ - William Radi
10
+ - Leonardo Comar
8
11
  autorequire:
9
12
  bindir: exe
10
13
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
14
+ date: 2021-06-29 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
- name: rake
17
+ name: rqrcode
15
18
  requirement: !ruby/object:Gem::Requirement
16
19
  requirements:
17
- - - "~>"
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '13.0'
22
+ version: '0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '13.0'
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
27
44
  - !ruby/object:Gem::Dependency
28
45
  name: rspec
29
46
  requirement: !ruby/object:Gem::Requirement
30
47
  requirements:
31
- - - "~>"
48
+ - - ">="
32
49
  - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :runtime
50
+ version: '0'
51
+ type: :development
35
52
  prerelease: false
36
53
  version_requirements: !ruby/object:Gem::Requirement
37
54
  requirements:
38
- - - "~>"
55
+ - - ">="
39
56
  - !ruby/object:Gem::Version
40
- version: '3.0'
57
+ version: '0'
41
58
  - !ruby/object:Gem::Dependency
42
- name: rqrcode
59
+ name: rubocop
43
60
  requirement: !ruby/object:Gem::Requirement
44
61
  requirements:
45
- - - "~>"
62
+ - - ">="
46
63
  - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
64
+ version: '0'
65
+ type: :development
49
66
  prerelease: false
50
67
  version_requirements: !ruby/object:Gem::Requirement
51
68
  requirements:
52
- - - "~>"
69
+ - - ">="
53
70
  - !ruby/object:Gem::Version
54
- version: '2.0'
71
+ version: '0'
55
72
  description: Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro
56
73
  - Banco Central do Brasil)
57
74
  email:
58
75
  - pedro.felipe.azevedo.furtado@gmail.com
76
+ - marciodejesusrj@gmail.com
77
+ - williamw@lbv.org.br
78
+ - lfcomar@lbv.org.br
59
79
  executables: []
60
80
  extensions: []
61
81
  extra_rdoc_files: []
62
82
  files:
63
83
  - ".github/workflows/ci.yml"
84
+ - ".github/workflows/heroku.yml"
64
85
  - ".github/workflows/rubygems.yml"
65
86
  - ".gitignore"
66
87
  - ".rspec"
88
+ - ".rubocop.yml"
67
89
  - CHANGELOG.md
68
90
  - CODE_OF_CONDUCT.md
91
+ - Dockerfile
69
92
  - Gemfile
70
93
  - LICENSE.txt
71
94
  - README.md
72
95
  - Rakefile
73
96
  - bin/console
74
97
  - bin/setup
98
+ - demo/Gemfile
99
+ - demo/Gemfile.lock
100
+ - demo/config.ru
75
101
  - lib/qrcode_pix_ruby.rb
76
102
  - lib/qrcode_pix_ruby/payload.rb
77
103
  - lib/qrcode_pix_ruby/version.rb
104
+ - pix_logo.png
78
105
  - qrcode_pix_ruby.gemspec
79
106
  homepage: https://github.com/pedrofurtado/qrcode_pix_ruby
80
107
  licenses:
@@ -91,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
118
  requirements:
92
119
  - - ">="
93
120
  - !ruby/object:Gem::Version
94
- version: '0'
121
+ version: 2.3.0
95
122
  required_rubygems_version: !ruby/object:Gem::Requirement
96
123
  requirements:
97
124
  - - ">="