-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.html
More file actions
40 lines (33 loc) · 1.3 KB
/
Copy pathvalidate.html
File metadata and controls
40 lines (33 loc) · 1.3 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
<!DOCTYPE html>
<meta charset="utf-8">
<title>Validate ZUGFeRD with InvoiceXML API</title>
<!--
Get API key: https://www.invoicexml.com/account/authentication
Docs: https://www.invoicexml.com/docs/api/validate/zugferd
WARNING: do not ship API keys in production browser code. Proxy through
your own backend so the key stays server-side.
-->
<h1>Validate ZUGFeRD invoice</h1>
<input type="file" id="file" accept="application/pdf">
<button id="run">Validate</button>
<pre id="output"></pre>
<script>
// Raw key only, without the "Bearer " prefix (it is added below).
const apiKey = 'YOUR_API_KEY';
document.getElementById('run').addEventListener('click', async () => {
const file = document.getElementById('file').files[0];
if (!file) return alert('Choose a PDF first.');
const form = new FormData();
form.append('file', file);
form.append('version', '2.3.2');
form.append('profile', 'extended');
const response = await fetch('https://api.invoicexml.com/v1/validate/zugferd', {
method: 'POST',
headers: { Authorization: 'Bearer ' + apiKey },
body: form,
});
const report = await response.text();
document.getElementById('output').textContent =
response.ok ? report : `InvoiceXML API error ${response.status}: ${report}`;
});
</script>