-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
49 lines (35 loc) · 1.4 KB
/
server.js
File metadata and controls
49 lines (35 loc) · 1.4 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
const express = require('express');
const bodyParser = require('body-parser');
const axios = require('axios');
const app = express();
const PORT = 3000;
app.use(bodyParser.json());
let pendingOrders = {}; // Store pending orders
// API to create order (QR Code generation)
app.post("/create-order", (req, res) => {
let { prints, amount } = req.body;
let orderId = Date.now().toString(); // Unique order ID (timestamp-based)
pendingOrders[orderId] = { prints, amount, paid: false };
console.log(`✅ Order Created: ${orderId}, Prints: ${prints}, Amount: ₹${amount}`);
res.json({ orderId });
});
// API to confirm payment (Called by Android SMS listener)
app.post('/confirm-payment', (req, res) => {
const { amount } = req.body;
console.log(`Payment of ₹${amount} confirmed!`);
// Logic to trigger printing after confirmation
if (amount >= 50) {
console.log("Triggering print...");
// Add the command to trigger DSLRBooth print
}
res.json({ success: true, message: "Payment confirmed" });
});
// Function to trigger DSLRBooth printing (Modify this as per your setup)
function printPhotos(prints) {
console.log(`🖨️ Sending print command for ${prints} photos...`);
// You can call a system command to trigger DSLRBooth printing
}
// Start server
app.listen(PORT, () => {
console.log(`🚀 Server running on http://localhost:${PORT}`);
});