fix : qr code generation to be dynamic
This commit is contained in:
@@ -213,33 +213,38 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
||||
end
|
||||
end
|
||||
|
||||
qr_str = "00020101021226480015com.mmqrpay.www0115223743000377032020600000052045814530310454075000.005802MM5908Code2LAB6006Yangon61051101062730125ORDER_1747826957_5ae9cb900523MMQR1075L175919500000010813PAY_BY_QRCODE64300002MY0109ကုဒ်တူလက်0207ရန်ကုန်6304AD40";
|
||||
@string_to_encode = qr_str
|
||||
@paymethod = PaymentMethodSetting.find_by(payment_method: "MMQR")
|
||||
|
||||
qrcode = RQRCode::QRCode.new(@string_to_encode)
|
||||
|
||||
@qr_svg = qrcode.as_svg(
|
||||
color: "000", # Hex color for the QR code modules (black)
|
||||
shape_rendering: "crispEdges", # Renders sharp edges
|
||||
module_size: 2, # Size of each module (dot/square)
|
||||
standalone: true, # Outputs a complete SVG document
|
||||
use_path: true # Modern SVG path rendering
|
||||
)
|
||||
@merchant = KbzMerchant.new(@paymethod)
|
||||
|
||||
png_data = qrcode.as_png(
|
||||
bit_depth: 1,
|
||||
border_modules: 4,
|
||||
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
||||
color: 'black',
|
||||
file: nil,
|
||||
fill: 'white',
|
||||
module_px_size: 8, # Pixel size of each module
|
||||
resize_exactly_to: false,
|
||||
resize_gte_to: false,
|
||||
size: 240 # Approximate size of the image in pixels (e.g., 240x240)
|
||||
).to_s
|
||||
@response = @merchant.create_order(amount: @sale_data.grand_total, merch_order_id: @sale_data.receipt_no)
|
||||
@qr_string = @response['qrCode']
|
||||
|
||||
ActionCable.server.broadcast('second_display_view_channel', { data: qr_str, qr_svg: @qr_svg })
|
||||
qrcode = RQRCode::QRCode.new(@qr_string)
|
||||
|
||||
@qr_svg = qrcode.as_svg(
|
||||
color: "000",
|
||||
shape_rendering: "crispEdges",
|
||||
module_size: 2,
|
||||
standalone: true,
|
||||
use_path: true
|
||||
)
|
||||
|
||||
# png_data = qrcode.as_png(
|
||||
# bit_depth: 1,
|
||||
# border_modules: 4,
|
||||
# color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
||||
# color: 'black',
|
||||
# file: nil,
|
||||
# fill: 'white',
|
||||
# module_px_size: 8, # Pixel size of each module
|
||||
# resize_exactly_to: false,
|
||||
# resize_gte_to: false,
|
||||
# size: 240 # Approximate size of the image in pixels (e.g., 240x240)
|
||||
# ).to_s
|
||||
|
||||
ActionCable.server.broadcast('second_display_view_channel', { data: @qr_string, qr_svg: @qr_svg })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user