Checkout SDK
Integrate onchain payments
Integrate onchain payments into your e-commerce site with minimal code. Accept crypto payments through our Checkout SDK with support for multiple tokens & chains.
Installation
npm install torque-checkoutBasic Usage
checkout.tsx
import { TorqueCheckout } from 'torque-checkout'
const checkout = new TorqueCheckout({
businessId: 'your-business-id',
apiKey: process.env.TORQUE_API_KEY,
})
const session = await checkout.createSession({
amount: 99.99,
currency: 'USD',
items: [
{ name: 'Pro Plan', quantity: 1, price: 99.99 }
],
successUrl: 'https://yoursite.com/success',
cancelUrl: 'https://yoursite.com/cancel',
})
window.location.href = session.urlConfiguration
Accepted Tokens
config.ts
const checkout = new TorqueCheckout({
businessId: 'your-business-id',
apiKey: process.env.TORQUE_API_KEY,
acceptedTokens: ['ETH', 'USDC', 'USDT'],
acceptedChains: [1, 8453, 42161],
theme: {
primaryColor: '#aa5bff',
borderRadius: 'full',
},
webhookUrl: 'https://yoursite.com/api/webhooks/torque',
})Webhooks
Receive real-time notifications when payments complete:
api/webhooks/torque/route.ts
import { NextRequest, NextResponse } from 'next/server'
import { verifyWebhookSignature } from 'torque-checkout'
export async function POST(req: NextRequest) {
const body = await req.text()
const signature = req.headers.get('x-torque-signature')
const isValid = verifyWebhookSignature(
body, signature, process.env.TORQUE_WEBHOOK_SECRET
)
if (!isValid) {
return NextResponse.json({ error: 'Invalid' }, { status: 401 })
}
const event = JSON.parse(body)
switch (event.type) {
case 'payment.completed':
await fulfillOrder(event.data.orderId)
break
case 'payment.failed':
await notifyCustomer(event.data.customerId)
break
}
return NextResponse.json({ received: true })
}Payment Flow
[01]Customer clicks 'Pay with Crypto'
[02]Redirected to Torque Checkout
[03]Connects wallet & selects token
[04]Payment processed & webhook sent
[✓]Redirected to success page
Was this helpful?Yes No