TorqueTorque

Search docs

Search Torque documentation pages and sections

Webhooks SDK

torque-webhooks helps merchants verify inbound Torque → merchant webhook signatures and push order status updates to Torque via POST /api/webhooks/order-update. Outbound payment webhooks from Torque to your server are not deployed on the hosted app yet.

Installation

yarn add torque-webhooks

Exports

ExportPurpose
verifyWebhookSignature()HMAC-SHA256 verify for inbound Torque → merchant webhooks
pushOrderUpdate()POST /api/webhooks/order-update with x-order-webhook-secret
createTorqueWebhooksFromEnv()Client from env vars
handleWebhook() — torque-webhooks/nextjsNext.js inbound webhook Route Handler

Push order status to Torque

After checkout, sync fulfillment status from your backend to Torque. Valid status values:

created | paid | shipped | delivered | cancelled | refunded

fulfillment.ts
import { createTorqueWebhooksFromEnv } from 'torque-webhooks'

await createTorqueWebhooksFromEnv().pushOrderUpdate({
  orderId: 'ord_123',
  status: 'shipped',
  customerData: { email: 'customer@example.com' },
  metadata: { carrier: 'ups', trackingId: '1Z…' },
})

Authenticates with x-order-webhook-secret and your business API credentials from env.

Verify inbound webhooks (when outbound ships)

When Torque sends outbound events to your server, verify the x-torque-signature header with HMAC-SHA256. The handler is ready in the SDK; the hosted sender is not live yet.

app/api/webhooks/torque/route.ts
import { handleWebhook } from 'torque-webhooks/nextjs'

export const POST = handleWebhook({
  secret: process.env.TORQUE_WEBHOOK_SECRET!,
  onEvent: async (event) => {
    switch (event.type) {
      case 'order.completed':
        await fulfillOrder(event.orderId)
        break
      // …
    }
  },
})

Related

Checkout integration: Checkout SDK. Merchant quickstart: Quickstart.

Was this helpful?