torque-webhooks
v0.1.0
Published
Torque webhook helpers — verify inbound signatures and push order status updates
Downloads
71
Maintainers
Readme
torque-webhooks
Merchant webhook helpers for Torque Checkout integrations.
Install
yarn add torque-webhooksVerify inbound webhooks (Torque → your server)
import { verifyWebhookSignature } from 'torque-webhooks'
const ok = verifyWebhookSignature(rawBody, request.headers.get('x-torque-signature'), secret)Push order status (your server → Torque)
import { createTorqueWebhooksFromEnv } from 'torque-webhooks'
const webhooks = createTorqueWebhooksFromEnv()
await webhooks.pushOrderUpdate({
orderId: 'ord_123',
status: 'shipped',
metadata: { trackingNumber: '1Z999' },
})Uses POST /api/webhooks/order-update with header x-order-webhook-secret.
Env: TORQUE_WEBHOOK_SECRET or ORDER_WEBHOOK_SECRET, optional TORQUE_BASE_URL.
Next.js inbound handler
// app/api/webhooks/torque/route.ts
import { handleWebhook } from 'torque-webhooks/nextjs'
export const POST = handleWebhook({
secret: process.env.TORQUE_WEBHOOK_SECRET,
onOrderCompleted: async (event) => {
await fulfillOrder(event.orderId!)
},
})License
MIT
