inital impl using qrcoder
This commit is contained in:
+76
-3
@@ -1,7 +1,80 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
@using QRCoder
|
||||||
|
@using SixLabors.ImageSharp.Formats
|
||||||
<PageTitle>Home</PageTitle>
|
<PageTitle>Home</PageTitle>
|
||||||
|
|
||||||
<h1>Hello, world!</h1>
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Create QR payment barcode</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="input0">Name</label>
|
||||||
|
<input type="text" class="form-control" id="input0" @bind="Name" placeholder="Enter beneficiary name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="input1">IBAN</label>
|
||||||
|
<input type="text" class="form-control" id="input1" @bind="IBAN" placeholder="Enter IBAN">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="input2">Amount</label>
|
||||||
|
<input type="text" class="form-control" id="input2" placeholder="Enter amount in EUR" @bind="Amount">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="input3">Remark</label>
|
||||||
|
<input type="text" class="form-control" id="input3" placeholder="Enter optional remark" @bind="Remark">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" @onclick="@GenerateQRCode">Generate</button>
|
||||||
|
</div>
|
||||||
|
@if (_show)
|
||||||
|
{
|
||||||
|
<div class="text-center">
|
||||||
|
<img src="@QRCodeStr" style="width:200px;height:200px" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
Welcome to your new app.
|
|
||||||
|
@code {
|
||||||
|
string IBAN { get; set; } = string.Empty;
|
||||||
|
decimal Amount { get; set; } = 0;
|
||||||
|
string Remark { get; set; } = string.Empty;
|
||||||
|
string QRCodeStr { get; set; } = string.Empty;
|
||||||
|
string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
bool _show = false;
|
||||||
|
|
||||||
|
public void GenerateQRCode()
|
||||||
|
{
|
||||||
|
QRCodeStr = string.Empty;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(IBAN))
|
||||||
|
{
|
||||||
|
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
QRCodeGenerator qRCodeGenerator = new QRCodeGenerator();
|
||||||
|
|
||||||
|
var payment = new PayBySquareTextGenerator.Payment(IBAN.Replace(" ", ""), Amount, "EUR", "1", Remark);
|
||||||
|
payment.ConstantSymbol = "0308";
|
||||||
|
payment.BeneficiaryName = Name;
|
||||||
|
|
||||||
|
var a = new PayBySquareTextGenerator.PayBySquareOverkill(payment);
|
||||||
|
var stringData = a.GeneratePayBySquareOverkillString();
|
||||||
|
|
||||||
|
// Generate QR code data
|
||||||
|
using var qrCodeData = QRCodeGenerator.GenerateQrCode(stringData, QRCodeGenerator.ECCLevel.Q);
|
||||||
|
using var qrCode = new PngByteQRCode(qrCodeData);
|
||||||
|
byte[] qrCodeImage = qrCode.GetGraphic(20);
|
||||||
|
|
||||||
|
QRCodeStr = $"data:image/png;base64,{Convert.ToBase64String(qrCodeImage)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
_show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user