← 데모 허브
Webhook
HMAC 검증기
SoftPay → 가맹점 웹훅의 X-SoftPay-Signature를 브라우저에서 검증합니다. 서버에서는 verifyWebhookSignature (@softpay/agent-sdk)를 쓰세요.
import { verifyWebhookSignature } from "@softpay/agent-sdk";
app.post("/hooks/softpay", express.raw({ type: "application/json" }), (req, res) => {
const raw = req.body.toString("utf8");
const ok = verifyWebhookSignature(raw, req.header("x-softpay-signature"), process.env.WEBHOOK_SECRET!);
if (!ok) return res.status(401).json({ error: "bad signature" });
// fulfill order…
res.json({ ok: true });
});