在 Express 中接受加密货币收款
为你的 Express 应用添加non-custodial加密货币结账:创建一张发票、把买家引导到托管结账页,并在一个签名 webhook 上履约。资金直接结算到你自己的wallet,$0 平台手续费。
安装
npm install @shieldz/sdk
创建一张发票并重定向到结账页
import Shieldz, { constructEvent } from "@shieldz/sdk";
const shieldz = new Shieldz(process.env.SHIELDZ_API_KEY);
app.post("/checkout", async (req, res) => {
const invoice = await shieldz.invoices.create({ amount_usd_cents: 5000 });
res.redirect(303, invoice.pay_url);
});
验证 webhook
app.post("/webhooks/shieldz", express.raw({ type: "application/json" }), async (req, res) => {
try {
const event = await constructEvent(req.body, req.header("x-shieldz-signature") ?? "", process.env.SHIELDZ_WEBHOOK_SECRET);
if (event.type === "invoice.paid") { /* fulfill */ }
res.sendStatus(200);
} catch { res.sendStatus(400); }
});
探索 Shieldz
接受某种币: Bitcoin, USDC, USDT, Zcash.
对比: 对比 Coinbase Commerce, 对比 BTCPay Server, 对比 CryptAPI, 对比 NOWPayments.
使用场景: 面向自由职业者, 面向创作者, 面向开源项目, 面向网店.
构建: SDK, API 参考, 快速上手. 了解: 概览, 博客, 工作原理, 支持的币种, 定价, 是否安全, 自行验证.