createWebhookHandler()
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / createWebhookHandler
Function: createWebhookHandler()
Section titled “Function: createWebhookHandler()”createWebhookHandler(
config):WebhookHandler
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:16227
Create a webhook handler for processing Helius webhook payloads
Parameters
Section titled “Parameters”config
Section titled “config”Handler configuration
Returns
Section titled “Returns”Handler function to process webhook payloads
Examples
Section titled “Examples”const handler = createWebhookHandler({ viewingPrivateKey: recipientKeys.viewingPrivateKey, spendingPublicKey: recipientKeys.spendingPublicKey, onPaymentFound: async (payment) => { await db.savePayment(payment) },})
app.post('/webhook', async (req, res) => { const results = await handler(req.body) res.json({ processed: results.length })})const handler = createWebhookHandler({ viewingPrivateKey: recipientKeys.viewingPrivateKey, spendingPublicKey: recipientKeys.spendingPublicKey, webhookSecret: process.env.HELIUS_WEBHOOK_SECRET!, onPaymentFound: async (payment) => { await db.savePayment(payment) },})
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => { try { const results = await handler.processRequest({ rawBody: req.body.toString(), payload: JSON.parse(req.body.toString()), headers: { signature: req.headers['x-helius-signature'] as string, authorization: req.headers['authorization'] as string, }, }) res.json({ processed: results.length }) } catch (error) { if (error instanceof SecurityError) { res.status(401).json({ error: error.message }) } else { res.status(500).json({ error: 'Internal error' }) } }})