# frozen_string_literal: true require 'qrcode_pix_ruby' def generate_html_with(env) qrcode_data = Rack::Request.new(env).params payload = '' data_uri = '' pix = QrcodePixRuby::Payload.new unless qrcode_data.empty? qrcode_data.keys.each do |key| v = qrcode_data[key] pix.public_send("#{key}=", key == 'repeatable' ? v == 't' : v) unless v.empty? || v.nil? end payload = <<-HTML
HTML data_uri = "" end StringIO.new <<-HTML QRCode Pix Ruby - Demo App

QRCode Pix Ruby - Demo App



For more details check the official repo: https://github.com/pedrofurtado/qrcode_pix_ruby



QRCode informations

For static Pix, please fill the 'Pix key' field.
For dynamic Pix, fill the 'URL' field.
Do not fill both fields.
Formats of Pix keys:
CPF: 12345678910 (only numbers)
Phone: +5511912345678 (+55 + DDD + phone, only numbers)
Email: example@mail.com
Random: a6hf7jdk3nc8iK (generated by bank)
or

Only numbers and simple characters, without whitespaces.
Only numbers with 2 decimal places.
Only numbers.
Preview

#{payload} #{data_uri}
HTML end run lambda { |env| [ 200, { 'Content-Type' => 'text/html' }, generate_html_with(env) ] }