-
Notifications
You must be signed in to change notification settings - Fork 10
/
PixGenerateQRCode.cs
36 lines (30 loc) · 1.09 KB
/
PixGenerateQRCode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Drawing;
namespace Gerencianet.NETCore.SDK.Examples
{
class PixGenerateQRCode
{
public static void Execute()
{
dynamic endpoints = new Endpoints(JObject.Parse (File.ReadAllText ("credentials.json")));
var param = new {
id = 147
};
try {
var response = endpoints.PixGenerateQRCode(param);
Console.WriteLine(response);
// Generate QRCode Image to JPEG Format
JObject jsonResponse = JObject.Parse(response);
string img = (string)jsonResponse["imagemQrcode"];
img = img.Replace("data:image/png;base64,", "");
var qrCodeImage = Image.FromStream(new MemoryStream(Convert.FromBase64String(img)));
qrCodeImage.Save("QRCodeImage.jpg");
} catch (GnException e) {
Console.WriteLine(e.ErrorType);
Console.WriteLine(e.Message);
}
}
}
}