-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPix.html
More file actions
41 lines (38 loc) · 1.35 KB
/
Pix.html
File metadata and controls
41 lines (38 loc) · 1.35 KB
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
37
38
39
40
41
<!DOCTYPE html>
<html>
<head>
<title>PIX QR Code Generator</title>
</head>
<body>
<h1>Gerar QR Code PIX</h1>
<input type="text" id="chave" placeholder="Chave Pix">
<input type="text" id="nome" placeholder="Nome do Recebedor">
<input type="text" id="cidade" placeholder="Cidade">
<input type="number" id="valor" placeholder="Valor (ex: 10.00)">
<button onclick="gerarQRCode()">Gerar QR</button>
<br><br>
<img id="qrcode" src="" style="width:200px">
<p id="payload"></p>
<script>
async function gerarQRCode() {
const chave = document.getElementById('chave').value;
const nome = document.getElementById('nome').value;
const cidade = document.getElementById('cidade').value;
const valor = document.getElementById('valor').value;
const url = `https://apiutilities.vercel.app/pix?chave=${encodeURIComponent(chave)}&nome=${encodeURIComponent(nome)}&cidade=${encodeURIComponent(cidade)}&valor=${valor}`;
try {
const res = await fetch(url);
const data = await res.json();
if (data.qrcode) {
document.getElementById('qrcode').src = data.qrcode;
document.getElementById('payload').innerText = data.payload;
} else {
alert('Erro: ' + data.error);
}
} catch (err) {
alert('Erro ao chamar API: ' + err);
}
}
</script>
</body>
</html>