TorqueTorque

Search docs

Search Torque documentation pages and sections

Checkout SDK

Embed Torque payments on your site with catalog-backed product IDs, server-side pricing, and support for multiple assets and chains. Use the SDK on your server so API keys never reach the client.

Installation

yarn add torque-checkout
# React hooks: import from 'torque-checkout/react'
# Next.js route helper: import from 'torque-checkout/nextjs'

Credentials: Business ID + API key from Business settings → API Integration. Env: TORQUE_BUSINESS_ID, TORQUE_API_KEY; optional TORQUE_BASE_URL (default https://app.torque.fi).

Basic Usage

Recommended (secrets on server): expose a Route Handler that wraps handleCheckoutRequest — the SDK calls hosted POST /api/torque-checkout with your Bearer API key.

app/api/checkout-session/route.ts
import { handleCheckoutRequest } from 'torque-checkout/nextjs'

export const POST = handleCheckoutRequest()
// Request body includes items (productId + quantity) & customer; response includes checkoutUrl

React: useTorqueCheckout from torque-checkout/react — e.g. generateProductCheckout(productId, quantity, { email }) or cart helpers below.

server-or-script.ts
import { createTorqueCheckoutFromEnv } from 'torque-checkout'

// Reads TORQUE_BUSINESS_ID & TORQUE_API_KEY — use only in Node / server context
const torque = createTorqueCheckoutFromEnv()

const checkoutUrl = await torque.generateCartCheckoutUrl({
  items: [{ productId: 'your-torque-product-id', quantity: 1 }],
  customer: { email: 'customer@example.com' },
  options: { metadata: { orderId: 'ord_123' } },
})

Configuration

Accepted assets

ETH
config.ts
import { createTorqueCheckout } from 'torque-checkout'

// businessId + apiKey are both required. Use only on the server when passing apiKey.
const torque = createTorqueCheckout({
  businessId: process.env.TORQUE_BUSINESS_ID!,
  apiKey: process.env.TORQUE_API_KEY!,
  baseUrl: process.env.TORQUE_BASE_URL, // optional; default https://app.torque.fi
  acceptedTokens: ['USDC', 'ETH'],
  acceptedChains: [1, 8453, 42161],
  theme: { primaryColor: '#aa5bff', borderRadius: 'full' },
  webhookUrl: 'https://yoursite.com/api/webhooks/torque',
})

Webhooks & order sync

Push order status updates to Torque with torque-webhooks. Outbound payment webhooks from Torque to your server are not deployed on the hosted app yet — the verify handler is ready for when they ship. Full guide: Webhooks SDK.

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

await createTorqueWebhooksFromEnv().pushOrderUpdate({
  orderId: 'ord_123',
  status: 'shipped',
})

Payment Flow

[01]Customer starts Torque Checkout
[02]Redirected to Torque Checkout
[03]Connects wallet & selects asset
[04]Payment processed & webhook sent
[]Redirected to success page
Was this helpful?