-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
62 lines (59 loc) · 1.7 KB
/
Copy pathtest.js
File metadata and controls
62 lines (59 loc) · 1.7 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Example JavaScript code to send a POST request to the PrintInvoice endpoint with dummy invoice data
// NODE_TLS_REJECT_UNAUTHORIZED=0 node test.js
const { readFileSync } = require('fs');
const https = require('https'); // Add this for SSL bypass
const dummyInvoice = {
Status: 1,
PrinterName: 'receipt',
TemplateName: 'receipt',
GlobalPrinter: true,
Company: 'Sample Company',
Cashier: 'John Doe',
Branch: 'Main Branch',
BranchDesc: 'Head Office',
Date: '2023-10-01',
Time: '12:00:00',
ShiftNo: '1',
InvoiceNo: 'INV-001',
InvoiceType: 'Sale',
DeliveryName: 'Express Delivery',
SectionName: 'Section A',
ScheduleTime: '2023-10-01 14:00',
TableNo: 'T1',
Discount: '5.00',
Service: '2.00',
Delivery: '10.00',
Vat: '14.00',
Visa: '50.00',
VisaPer: '10',
Total: '100.00',
Note: 'Thank you for your business',
PrintingDate: '2023-10-01',
PrintingTime: '12:00:00',
FooterNote1: 'Note 1',
FooterNote2: 'Note 2',
FooterNote3: 'Note 3',
ImageSrc: 'logo.png',
// Assuming Items is a list of objects, e.g., [{ Title: "Item1", Price: 10.00 }, ...]
Items: [
{ Title: 'Item1', Price: '10.0' },
{ Title: 'Item2', Price: '20.0' },
{ Title: 'Item2', Price: '20.0' },
{ Title: 'Item2', Price: '20.0' },
{ Title: 'Item2', Price: '20.0' },
],
};
fetch('https://localhost:7229/PrintingData', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(dummyInvoice),
agent: new https.Agent({ rejectUnauthorized: false }), // Bypass SSL verification for self-signed cert
tls: {
// ca: readFileSync('./cert.pem'),
rejectUnauthorized: false,
},
})
.then(() => console.log('Success posting to PrintInvoice endpoint ✅'))
.catch(error => console.error('❌ Error:', error));