Quickstart Guide
Follow this guide to subscribe to OrderInWhats webhooks and begin processing real-time events in your application.
Core Event Types
order.createdTriggered when an order is received and temporarily created in the DB. This handles cases where a user might reset or their session expires before final confirmation.
order.status.changedTriggered whenever an order moves through the status cycle (e.g., Pending to Confirmed, or Confirmed to NewOrder).
order.deletedTriggered when an order is permanently removed from the database.
Dashboard Configuration
- Go to the Developer section in your sidebar.
- Enter your server's endpoint URL and your Webhook Secret.
Example Implementation
import express from "express";
import crypto from "crypto";
const app = express();
app.use(express.json());
const PORT = 3002;
const WEBHOOK_SECRET = "YOUR_SECRET_HERE"; // Set this in your dashboard
// Verify Webhook Subscription
export const verifyWebhook = async (req, res) => {
const mode = req.query["hub.mode"];
const challenge = req.query["hub.challenge"];
const token = req.query["hub.verify_token"];
if (mode && token) {
if (mode === "subscribe" && token === WEBHOOK_SECRET) {
return res.status(200).send(challenge);
} else {
return res.status(403).send("forbidden: secret mismatch");
}
}
};
// Verify Signature helper
const verifySignature = (payload, signature, secret) => {
const expected = crypto
.createHmac("sha256", secret)
.update(typeof payload === "string" ? payload : JSON.stringify(payload))
.digest("hex");
try {
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
} catch(error) {
return false;
}
};
app.get("/webhook", verifyWebhook);
app.post("/webhook", async (req, res) => {
const signature = req.headers["x-webhook-signature"];
const payload = req.body;
if (!signature || !verifySignature(payload, signature, WEBHOOK_SECRET)) {
console.log("Signature verification failed");
return res.status(401).json({ error: "Unauthorized" });
}
console.log("Webhook received:", payload);
res.status(200).json({ status: "success" });
});
app.listen(PORT, () => console.log(`Server on ${PORT}`));Final Step: Testing
Use the "Send Test Webhook" button in your dashboard to verify your server is receiving payloads correctly.