qr-bills 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qr-bills/qr-generator.rb +109 -44
- data/lib/qr-bills/qr-html-layout.rb +60 -42
- data/lib/qr-bills/qr-params.rb +4 -7
- data/lib/qr-bills.rb +5 -7
- data/web/assets/images/swiss_cross.svg +1 -0
- metadata +35 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ebe1c2b95ed95343f6c469423a8f1771a242f363363b3e15f3057976e1a14c0
|
4
|
+
data.tar.gz: 05c5cad9f08d3a835b73b650fba6226822030287be05880319f9f0d94c3994b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa143fa2bd2f6acca9796f15e99464d704292ceae9381805e34c2d07a1378c212fb5453c5efc15293bcb47de32f9e7391755024cfda3e9fbcb65fe3534136bed
|
7
|
+
data.tar.gz: f1297545bb6d81b73c96722a968c5ff78bfacee70b3b507b27432491808e224f3d63e5beb2d57b465f0fa59595fb18c7bab4499cf13c48f0a33afb3dc5fb360f
|
@@ -1,6 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rqrcode'
|
2
4
|
|
3
5
|
module QRGenerator
|
6
|
+
def self.create(params, qrcode_path = nil)
|
7
|
+
format = params[:qrcode_format] || 'qrcode_png'
|
8
|
+
|
9
|
+
case format
|
10
|
+
when 'qrcode_png'
|
11
|
+
build_qrcode_png(params[:bill_params], qrcode_path)
|
12
|
+
when 'png'
|
13
|
+
build_png(params[:bill_params])
|
14
|
+
when 'svg'
|
15
|
+
build_svg(params[:bill_params])
|
16
|
+
else
|
17
|
+
raise ArgumentError, "#{QRExceptions::NOT_SUPPORTED}: #{format} is not yet supported"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.build_qrcode_png(bill_params, qrcode_path)
|
22
|
+
warn('DEPRECATION WARNING: The qrcode_png format and qrcode_filepath parameter are deprecated and will be removed from qr-bills 1.1 (use png or svg instead)')
|
23
|
+
|
24
|
+
final_qr = build_png(bill_params)
|
25
|
+
final_qr.save(qrcode_path)
|
26
|
+
final_qr
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.build_png(bill_params)
|
30
|
+
payload = build_payload(bill_params)
|
31
|
+
qrcode = RQRCode::QRCode.new(payload, level: 'm')
|
32
|
+
|
33
|
+
png = qrcode.as_png(
|
34
|
+
bit_depth: 1,
|
35
|
+
border_modules: 0,
|
36
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
37
|
+
color: 'black',
|
38
|
+
file: nil,
|
39
|
+
fill: 'white',
|
40
|
+
module_px_size: 10,
|
41
|
+
resize_exactly_to: false,
|
42
|
+
resize_gte_to: false,
|
43
|
+
size: 1024
|
44
|
+
)
|
45
|
+
|
46
|
+
swiss_cross = ChunkyPNG::Image.from_file(File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/images/swiss_cross.png"))
|
47
|
+
png.compose!(swiss_cross, (png.width - swiss_cross.width) / 2, (png.height - swiss_cross.height) / 2)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.build_svg(bill_params)
|
51
|
+
payload = build_payload(bill_params)
|
52
|
+
qrcode = RQRCode::QRCode.new(payload, level: 'm')
|
53
|
+
|
54
|
+
# Generate qr code
|
55
|
+
svg_code = qrcode.as_svg(
|
56
|
+
standalone: true, # return a svg wrapper
|
57
|
+
viewbox: true, # return a viewBox so we can extract it
|
58
|
+
module_size: 10,
|
59
|
+
use_path: true
|
60
|
+
)
|
61
|
+
|
62
|
+
# Parse viewBox and calculate relative swiss cross size / center
|
63
|
+
viewbox = svg_code.match(/viewBox="([\s\d]*)"/)[1]
|
64
|
+
viewbox_size = viewbox.split(' ')[2].to_f
|
65
|
+
swiss_cross_size = viewbox_size / (46.0 / 7.0)
|
66
|
+
swiss_cross_center = (viewbox_size / 2.0) - (swiss_cross_size / 2.0)
|
67
|
+
|
68
|
+
# Parse swiss cross and update size and coordinates
|
69
|
+
svg_swiss_cross = File.open(File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/images/swiss_cross.svg")).read
|
70
|
+
svg_swiss_cross.gsub!('SWISS_CROSS_SIZE', swiss_cross_size.to_s)
|
71
|
+
svg_swiss_cross.gsub!('SWISS_CROSS_CENTER', swiss_cross_center.to_s)
|
72
|
+
|
73
|
+
# Assemble svg
|
74
|
+
svg_code.gsub!(/<path/, '<g>\0')
|
75
|
+
svg_code.gsub!(/<\/svg>/, "#{svg_swiss_cross}</g></svg>")
|
76
|
+
|
77
|
+
# Optimize SVG for being URI-escaped
|
78
|
+
# Stolen from Sprockets: https://github.com/rails/sprockets/blob/master/lib/sprockets/context.rb#L277-L293
|
79
|
+
#
|
80
|
+
# This only performs these basic but crucial optimizations:
|
81
|
+
# * Removes comments, meta, doctype, and newlines.
|
82
|
+
# * Replaces " with ', because ' does not need escaping.
|
83
|
+
svg_code.gsub!(/<!--.*?-->|<\?.*?\?>|<!.*?>/m, '')
|
84
|
+
svg_code.gsub!(/([\w:])="(.*?)"/, "\\1='\\2'")
|
85
|
+
|
86
|
+
svg_code
|
87
|
+
end
|
88
|
+
|
4
89
|
# payload:
|
5
90
|
# "SPC\r\n" + # indicator for swiss qr code: SPC (swiss payments code)
|
6
91
|
# "0200\r\n" + # version of the specifications, 0200 = v2.0
|
@@ -35,19 +120,18 @@ module QRGenerator
|
|
35
120
|
# "EPD\r\n" + # fixed indicator for EPD (end payment data)
|
36
121
|
# "//S1/10/10201409/11/181105/40/0:30\r\n" + # bill information coded for automated booking of payment, data is not forwarded with the payment
|
37
122
|
# "eBill/B/41010560425610173"; # alternative scheme paramaters, max 100 chars
|
38
|
-
|
39
|
-
def self.create(params, qrcode_path)
|
123
|
+
def self.build_payload(bill_params)
|
40
124
|
payload = "SPC\r\n"
|
41
125
|
payload += "0200\r\n"
|
42
126
|
payload += "1\r\n"
|
43
|
-
payload += "#{
|
44
|
-
payload += "#{
|
45
|
-
payload += "#{
|
46
|
-
payload += "#{
|
47
|
-
payload += "#{
|
48
|
-
payload += "#{
|
49
|
-
payload += "#{
|
50
|
-
payload += "#{
|
127
|
+
payload += "#{bill_params[:creditor][:iban].delete(' ')}\r\n"
|
128
|
+
payload += "#{bill_params[:creditor][:address][:type]}\r\n"
|
129
|
+
payload += "#{bill_params[:creditor][:address][:name]}\r\n"
|
130
|
+
payload += "#{bill_params[:creditor][:address][:line1]}\r\n"
|
131
|
+
payload += "#{bill_params[:creditor][:address][:line2]}\r\n"
|
132
|
+
payload += "#{bill_params[:creditor][:address][:postal_code]}\r\n"
|
133
|
+
payload += "#{bill_params[:creditor][:address][:town]}\r\n"
|
134
|
+
payload += "#{bill_params[:creditor][:address][:country]}\r\n"
|
51
135
|
payload += "\r\n"
|
52
136
|
payload += "\r\n"
|
53
137
|
payload += "\r\n"
|
@@ -55,39 +139,20 @@ module QRGenerator
|
|
55
139
|
payload += "\r\n"
|
56
140
|
payload += "\r\n"
|
57
141
|
payload += "\r\n"
|
58
|
-
payload += "#{format('%.2f',
|
59
|
-
payload += "#{
|
60
|
-
payload += "#{
|
61
|
-
payload += "#{
|
62
|
-
payload += "#{
|
63
|
-
payload += "#{
|
64
|
-
payload += "#{
|
65
|
-
payload += "#{
|
66
|
-
payload += "#{
|
67
|
-
payload += "#{
|
68
|
-
payload += "#{
|
69
|
-
payload += "#{
|
142
|
+
payload += "#{format('%.2f', bill_params[:amount])}\r\n"
|
143
|
+
payload += "#{bill_params[:currency]}\r\n"
|
144
|
+
payload += "#{bill_params[:debtor][:address][:type]}\r\n"
|
145
|
+
payload += "#{bill_params[:debtor][:address][:name]}\r\n"
|
146
|
+
payload += "#{bill_params[:debtor][:address][:line1]}\r\n"
|
147
|
+
payload += "#{bill_params[:debtor][:address][:line2]}\r\n"
|
148
|
+
payload += "#{bill_params[:debtor][:address][:postal_code]}\r\n"
|
149
|
+
payload += "#{bill_params[:debtor][:address][:town]}\r\n"
|
150
|
+
payload += "#{bill_params[:debtor][:address][:country]}\r\n"
|
151
|
+
payload += "#{bill_params[:reference_type]}\r\n"
|
152
|
+
payload += "#{bill_params[:reference].delete(' ')}\r\n"
|
153
|
+
payload += "#{bill_params[:additionally_information]}\r\n"
|
70
154
|
payload += "EPD\r\n"
|
71
|
-
payload += "#{
|
72
|
-
payload += "#{
|
73
|
-
|
74
|
-
qrcode = RQRCode::QRCode.new(payload, level: 'm')
|
75
|
-
|
76
|
-
png = qrcode.as_png(
|
77
|
-
bit_depth: 1,
|
78
|
-
border_modules: 0,
|
79
|
-
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
80
|
-
color: 'black',
|
81
|
-
file: nil,
|
82
|
-
fill: 'white',
|
83
|
-
module_px_size: 10,
|
84
|
-
resize_exactly_to: false,
|
85
|
-
resize_gte_to: false,
|
86
|
-
size: 1024,
|
87
|
-
)
|
88
|
-
|
89
|
-
swiss_cross = ChunkyPNG::Image.from_file(File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/images/swiss_cross.png"))
|
90
|
-
final_qr = png.compose!(swiss_cross, (png.width - swiss_cross.width) / 2, (png.height - swiss_cross.height) / 2)
|
91
|
-
final_qr.save(qrcode_path)
|
155
|
+
payload += "#{bill_params[:bill_information_coded]}\r\n"
|
156
|
+
payload += "#{bill_params[:alternative_scheme_parameters]}\r\n"
|
92
157
|
end
|
93
|
-
end
|
158
|
+
end
|
@@ -1,10 +1,28 @@
|
|
1
1
|
require 'qr-bills/qr-generator'
|
2
2
|
|
3
3
|
module QRHTMLLayout
|
4
|
-
|
5
4
|
def self.create(params)
|
6
|
-
QRGenerator.create(params, params[:qrcode_filepath])
|
7
|
-
|
5
|
+
qrcode = QRGenerator.create(params, params[:qrcode_filepath])
|
6
|
+
params[:qrcode_filepath] = convert_qrcode_to_data_url(qrcode)
|
7
|
+
html_layout(params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.convert_qrcode_to_data_url(qrcode)
|
11
|
+
case qrcode
|
12
|
+
when ChunkyPNG::Image
|
13
|
+
qrcode.to_data_url
|
14
|
+
else
|
15
|
+
# Stolen from sprockets
|
16
|
+
# https://github.com/rails/sprockets/blob/0f3e0e93dabafa8f3027e8036e40fd08902688c8/lib/sprockets/context.rb#L295-L303
|
17
|
+
data = CGI.escape(qrcode)
|
18
|
+
data.gsub!('%3D', '=')
|
19
|
+
data.gsub!('%3A', ':')
|
20
|
+
data.gsub!('%2F', '/')
|
21
|
+
data.gsub!('%27', "'")
|
22
|
+
data.tr!('+', ' ')
|
23
|
+
|
24
|
+
"data:image/svg+xml;charset=utf-8,#{data}"
|
25
|
+
end
|
8
26
|
end
|
9
27
|
|
10
28
|
def self.html_layout(params)
|
@@ -22,11 +40,11 @@ module QRHTMLLayout
|
|
22
40
|
layout += " <div><br/></div>\n"
|
23
41
|
|
24
42
|
if !params[:bill_params][:reference].nil? && !params[:bill_params][:reference].empty?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
43
|
+
layout += " <div class=\"subtitle reference\">#{I18n.t("qrbills.reference").capitalize}</div>\n"
|
44
|
+
layout += " <div class=\"reference\">\n"
|
45
|
+
layout += " #{params[:bill_params][:reference]}<br/>\n"
|
46
|
+
layout += " </div>\n"
|
47
|
+
layout += " <div><br/></div>\n"
|
30
48
|
end
|
31
49
|
|
32
50
|
layout += " <div class=\"subtitle payable_by\">#{I18n.t("qrbills.payable_by").capitalize}</div>\n"
|
@@ -47,11 +65,11 @@ module QRHTMLLayout
|
|
47
65
|
layout += " #{format('%.2f', params[:bill_params][:amount])}<br/>\n"
|
48
66
|
layout += " </div>\n"
|
49
67
|
layout += " </div>\n"
|
50
|
-
|
68
|
+
|
51
69
|
layout += " <div class=\"acceptance_point\">\n"
|
52
70
|
layout += " #{I18n.t("qrbills.acceptance_point").capitalize}<br/>\n"
|
53
71
|
layout += " </div>\n"
|
54
|
-
|
72
|
+
|
55
73
|
layout += " </div>\n"
|
56
74
|
layout += " <div class=\"payment_section\">\n"
|
57
75
|
layout += " <div class=\"left_column\">\n"
|
@@ -62,21 +80,21 @@ module QRHTMLLayout
|
|
62
80
|
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.currency").capitalize}</span><br/>\n"
|
63
81
|
layout += " #{params[:bill_params][:currency]}<br/>\n"
|
64
82
|
layout += " </div>\n"
|
65
|
-
|
83
|
+
|
66
84
|
layout += " <div class=\"amount_value\">\n"
|
67
85
|
layout += " <span class=\"amount_header subtitle\">#{I18n.t("qrbills.amount").capitalize}</span><br/>\n"
|
68
86
|
layout += " #{format('%.2f',params[:bill_params][:amount])}<br/>\n"
|
69
87
|
layout += " </div>\n"
|
70
88
|
layout += " </div>\n"
|
71
|
-
|
89
|
+
|
72
90
|
layout += " <div class=\"further_information\">\n"
|
73
91
|
|
74
92
|
if !params[:bill_params][:bill_information_coded].nil? && !params[:bill_params][:bill_information_coded].empty?
|
75
|
-
|
93
|
+
layout += " <span class=\"finfo_header\">#{I18n.t("qrbills.name").capitalize} AV1:</span> #{params[:bill_params][:bill_information_coded]}\n"
|
76
94
|
end
|
77
|
-
|
95
|
+
|
78
96
|
if !params[:bill_params][:alternative_scheme_parameters].nil? && !params[:bill_params][:alternative_scheme_parameters].empty?
|
79
|
-
|
97
|
+
layout += " <span class=\"finfo_header\">#{I18n.t("qrbills.name").capitalize} AV2:</span> #{params[:bill_params][:alternative_scheme_parameters]}\n"
|
80
98
|
end
|
81
99
|
|
82
100
|
layout += " </div>\n"
|
@@ -92,19 +110,19 @@ module QRHTMLLayout
|
|
92
110
|
layout += " <div><br/></div>\n"
|
93
111
|
|
94
112
|
if !params[:bill_params][:reference].nil? && !params[:bill_params][:reference].empty?
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
113
|
+
layout += " <div class=\"subtitle reference\">#{I18n.t("qrbills.reference").capitalize}</div>\n"
|
114
|
+
layout += " <div class=\"reference\">\n"
|
115
|
+
layout += " #{params[:bill_params][:reference]}<br/>\n"
|
116
|
+
layout += " </div>\n"
|
117
|
+
layout += " <div><br/></div>\n"
|
100
118
|
end
|
101
119
|
|
102
120
|
if !params[:bill_params][:additionally_information].nil? && !params[:bill_params][:additionally_information].empty?
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
121
|
+
layout += " <div class=\"subtitle additional_information\">#{I18n.t("qrbills.additional_information").capitalize}</div>\n"
|
122
|
+
layout += " <div class=\"additional_information\">\n"
|
123
|
+
layout += " #{params[:bill_params][:additionally_information]}<br/>\n"
|
124
|
+
layout += " </div>\n"
|
125
|
+
layout += " <div><br/></div>\n"
|
108
126
|
end
|
109
127
|
|
110
128
|
layout += " <div class=\"subtitle payable_by\">#{I18n.t("qrbills.payable_by").capitalize}</div>\n"
|
@@ -116,7 +134,7 @@ module QRHTMLLayout
|
|
116
134
|
layout += " </div>\n"
|
117
135
|
layout += " </div>\n"
|
118
136
|
layout += "</div>\n"
|
119
|
-
|
137
|
+
|
120
138
|
layout += "<style>\n"
|
121
139
|
layout += " @font-face{ \n"
|
122
140
|
layout += " font-family: \"liberation_sansregular\";\n"
|
@@ -135,13 +153,13 @@ module QRHTMLLayout
|
|
135
153
|
layout += " font-family: \"liberation_sansregular\";\n"
|
136
154
|
layout += " border: 1px solid #ccc;\n"
|
137
155
|
layout += " }\n"
|
138
|
-
|
156
|
+
|
139
157
|
layout += " .bill_container:after {\n"
|
140
158
|
layout += " content: \"\";\n"
|
141
159
|
layout += " display: table;\n"
|
142
160
|
layout += " clear: both;\n"
|
143
161
|
layout += " }\n"
|
144
|
-
|
162
|
+
|
145
163
|
layout += " .receipt_section {\n"
|
146
164
|
layout += " width: 52mm;\n"
|
147
165
|
layout += " height: 95mm;\n"
|
@@ -150,7 +168,7 @@ module QRHTMLLayout
|
|
150
168
|
layout += " font-size: 8pt;\n"
|
151
169
|
layout += " border-right: 1px dotted #ccc;\n"
|
152
170
|
layout += " }\n"
|
153
|
-
|
171
|
+
|
154
172
|
layout += " .payment_section {\n"
|
155
173
|
layout += " width: 137mm;\n"
|
156
174
|
layout += " height: 95mm;\n"
|
@@ -158,51 +176,51 @@ module QRHTMLLayout
|
|
158
176
|
layout += " padding: 5mm;\n"
|
159
177
|
layout += " font-size: 10pt;\n"
|
160
178
|
layout += " }\n"
|
161
|
-
|
179
|
+
|
162
180
|
layout += " .payment_section .left_column {\n"
|
163
181
|
layout += " height: 95mm;\n"
|
164
182
|
layout += " width: 46mm;\n"
|
165
183
|
layout += " float: left;\n"
|
166
184
|
layout += " margin-right: 5mm;\n"
|
167
185
|
layout += " }\n"
|
168
|
-
|
186
|
+
|
169
187
|
layout += " .payment_section .right_column {\n"
|
170
188
|
layout += " height: 95mm;\n"
|
171
189
|
layout += " width: 86mm;\n"
|
172
190
|
layout += " float: left;\n"
|
173
191
|
layout += " }\n"
|
174
|
-
|
192
|
+
|
175
193
|
layout += " .qr_code {\n"
|
176
194
|
layout += " padding: 5mm 0mm 5mm 0mm;\n"
|
177
195
|
layout += " height: 46mm;\n"
|
178
196
|
layout += " width: 46mm;\n"
|
179
197
|
layout += " }\n"
|
180
|
-
|
198
|
+
|
181
199
|
layout += " .qr_code img {\n"
|
182
200
|
layout += " height: 46mm;\n"
|
183
201
|
layout += " width: 46mm;\n"
|
184
202
|
layout += " }\n"
|
185
|
-
|
203
|
+
|
186
204
|
layout += " .amount {\n"
|
187
205
|
layout += " margin-top: 15px;\n"
|
188
206
|
layout += " }\n"
|
189
|
-
|
207
|
+
|
190
208
|
layout += " .amount .currency {\n"
|
191
209
|
layout += " float: left;\n"
|
192
210
|
layout += " margin-right: 15px;\n"
|
193
211
|
layout += " }\n"
|
194
|
-
|
212
|
+
|
195
213
|
layout += " .title {\n"
|
196
214
|
layout += " font-weight: bold;\n"
|
197
215
|
layout += " font-size: 11pt;\n"
|
198
216
|
layout += " }\n"
|
199
|
-
|
217
|
+
|
200
218
|
layout += " .receipt_section .subtitle {\n"
|
201
219
|
layout += " font-weight: bold;\n"
|
202
220
|
layout += " font-size: 6pt;\n"
|
203
221
|
layout += " line-height: 9pt;\n"
|
204
222
|
layout += " }\n"
|
205
|
-
|
223
|
+
|
206
224
|
layout += " .receipt_section .acceptance_point {\n"
|
207
225
|
layout += " font-weight: bold;\n"
|
208
226
|
layout += " text-align: right;\n"
|
@@ -210,13 +228,13 @@ module QRHTMLLayout
|
|
210
228
|
layout += " line-height: 8pt;\n"
|
211
229
|
layout += " padding-top: 5mm;\n"
|
212
230
|
layout += " }\n"
|
213
|
-
|
231
|
+
|
214
232
|
layout += " .payment_section .subtitle {\n"
|
215
233
|
layout += " font-weight: bold;\n"
|
216
234
|
layout += " font-size: 8pt;\n"
|
217
235
|
layout += " line-height: 11pt;\n"
|
218
236
|
layout += " }\n"
|
219
|
-
|
237
|
+
|
220
238
|
layout += " .payment_section .amount {\n"
|
221
239
|
layout += " height: 22mm;\n"
|
222
240
|
layout += " margin-top: 40px;\n"
|
@@ -225,13 +243,13 @@ module QRHTMLLayout
|
|
225
243
|
layout += " .payment_section .further_information {\n"
|
226
244
|
layout += " font-size: 7pt;\n"
|
227
245
|
layout += " }\n"
|
228
|
-
|
246
|
+
|
229
247
|
layout += " .payment_section .finfo_header {\n"
|
230
248
|
layout += " font-weight: bold;\n"
|
231
249
|
layout += " } \n"
|
232
250
|
layout += "</style>\n"
|
233
251
|
|
234
|
-
|
252
|
+
layout
|
235
253
|
end
|
236
254
|
end
|
237
255
|
end
|
data/lib/qr-bills/qr-params.rb
CHANGED
@@ -6,7 +6,8 @@ module QRParams
|
|
6
6
|
def self.get_qr_params
|
7
7
|
{
|
8
8
|
bill_type: "", # see global variables / README
|
9
|
-
|
9
|
+
qrcode_format: nil, # png or svg, overwrites qrcode_filepath
|
10
|
+
qrcode_filepath: "", # deprecated, where to store the qrcode, i.e. : /tmp/qrcode_1234.png
|
10
11
|
fonts: {
|
11
12
|
eot: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.eot"),
|
12
13
|
woff: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.woff"),
|
@@ -67,7 +68,7 @@ module QRParams
|
|
67
68
|
when QRParams::QR_BILL_WITHOUT_REFERENCE
|
68
69
|
QRParams.qr_bill_without_reference_valid?(params)
|
69
70
|
else
|
70
|
-
|
71
|
+
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: bill type is not supported"
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -76,11 +77,7 @@ module QRParams
|
|
76
77
|
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: bill type cannot be blank"
|
77
78
|
end
|
78
79
|
|
79
|
-
if params
|
80
|
-
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: qrcode_filepath cannot be blank"
|
81
|
-
end
|
82
|
-
|
83
|
-
if params[:bill_params][:currency] == "" || params[:bill_params][:currency] == nil
|
80
|
+
if params.dig(:bill_params, :currency) == "" || params.dig(:bill_params, :currency) == nil
|
84
81
|
raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: currency cannot be blank"
|
85
82
|
end
|
86
83
|
|
data/lib/qr-bills.rb
CHANGED
@@ -17,13 +17,11 @@ module QRBills
|
|
17
17
|
end
|
18
18
|
|
19
19
|
output = case qr_params[:output_params][:format]
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
raise ArgumentError, "#{QRExceptions::NOT_SUPPORTED}: #{qr_params[:output_params][:format]} is not yet supported"
|
26
|
-
end
|
20
|
+
when 'html'
|
21
|
+
QRHTMLLayout.create(qr_params)
|
22
|
+
else
|
23
|
+
QRGenerator.create(qr_params, qr_params[:qrcode_filepath])
|
24
|
+
end
|
27
25
|
|
28
26
|
{ params: qr_params, output: output }
|
29
27
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='SWISS_CROSS_CENTER' y='SWISS_CROSS_CENTER' width='SWISS_CROSS_SIZE' height='SWISS_CROSS_SIZE' viewBox='0 0 19.8 19.8' style='enable-background:new 0 0 19.8 19.8;' xml:space='preserve'><style type='text/css'>.st0{fill:#FFFFFF;}.st1{fill:none;stroke:#FFFFFF;stroke-width:1.4357;stroke-miterlimit:10;}</style><polygon points='18.3,0.7 1.6,0.7 0.7,0.7 0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7'/><rect x='8.3' y='4' class='st0' width='3.3' height='11'/><rect x='4.4' y='7.9' class='st0' width='11' height='3.3'/><polygon class='st1' points='0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 18.3,0.7 1.6,0.7 0.7,0.7'/></svg>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qr-bills
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damiano Radice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -36,20 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: '2.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '3'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: '2.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '3'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rspec
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +78,34 @@ dependencies:
|
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '13.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: pry
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: byebug
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
81
109
|
description: 'QR-bills support for swiss payments, for full documentation please refer
|
82
110
|
to github repo: https://github.com/damoiser/qr-bills'
|
83
111
|
email: dam.radice@gmail.com
|
@@ -103,6 +131,7 @@ files:
|
|
103
131
|
- web/assets/images/payable_by_65x25mm.png
|
104
132
|
- web/assets/images/scissors_symbol.png
|
105
133
|
- web/assets/images/swiss_cross.png
|
134
|
+
- web/assets/images/swiss_cross.svg
|
106
135
|
homepage: https://github.com/damoiser/qr-bills
|
107
136
|
licenses:
|
108
137
|
- MIT
|