Skip to content

parseWebhookEvent

const parseWebhookEvent: <E>(event, rawBody) => ParsedHepsiburadaWebhookEvent<E> = parseHepsiburadaWebhookEvent

Defined in: sdks/hepsiburada/src/parse-webhook-event.ts:90

Short alias for parseHepsiburadaWebhookEvent. The Trendyol SDK exports the same name, so each SDK’s parseWebhookEvent is the canonical entry point when callers import the helper via the marketplace-specific package.

Use whichever name reads better. The two are referentially identical.

Parse a Hepsiburada webhook PUT body into a typed envelope.

E extends HepsiburadaWebhookEvent

E

The event name. Hepsiburada’s webhook model is endpoint-per-event — you already know the name from your route handler (e.g. app.put('/hb/createOrder', ...)). Must be one of HEPSIBURADA_WEBHOOK_EVENTS.

string | Record<string, unknown> | null | undefined

The raw request body — either a JSON string (Node’s req.body when no body parser is mounted) or an already-parsed object (after express.json() etc.).

ParsedHepsiburadaWebhookEvent<E>

{ event, body, raw }. Both body and raw are the same parsed object; raw is provided as the forward-compat accessor for undocumented fields.

when event isn’t a recognized event name, when rawBody is a string but not valid JSON, or when rawBody doesn’t parse to an object.

import express from 'express';
import { parseHepsiburadaWebhookEvent } from '@lonca/hepsiburada';
const app = express();
app.use(express.json());
app.put('/hb/createOrder', (req, res) => {
const { event, body } = parseHepsiburadaWebhookEvent('createOrder', req.body);
// process the order...
res.status(204).end();
});

Unofficial. Lonca is an independent, community-maintained project — not affiliated with, endorsed by, or supported by Trendyol, Hepsiburada, or any other marketplace. All marketplace names and trademarks belong to their respective owners.