# 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? pix.pix_key = qrcode_data['pix_key'] unless qrcode_data['pix_key'].nil? pix.url = qrcode_data['url'] unless qrcode_data['url'].nil? pix.description = qrcode_data['description'] unless qrcode_data['description'].nil? pix.merchant_name = qrcode_data['merchant_name'] unless qrcode_data['merchant_name'].nil? pix.merchant_city = qrcode_data['merchant_city'] unless qrcode_data['merchant_city'].nil? pix.transaction_id = qrcode_data['transaction_id'] unless qrcode_data['transaction_id'].nil? pix.amount = qrcode_data['amount'] unless qrcode_data['amount'].nil? pix.currency = qrcode_data['currency'] unless qrcode_data['currency'].nil? pix.country_code = qrcode_data['country_code'] unless qrcode_data['country_code'].nil? pix.postal_code = qrcode_data['postal_code'] unless qrcode_data['postal_code'].nil? pix.repeatable = qrcode_data['repeatable'] == 't' unless qrcode_data['repeatable'].nil? 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

Preview

#{payload}

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