Normalize the webhook payload

Node · Node · intermediate · greenfield

Normalizes the provider webhook into our internal shape: pulls the order id and amount out of the payload. Typed against the declared payload interface.

Requirements

Files touched

--- src/webhooks/normalize.ts
+interface WebhookPayload {
+  order_id: string;
+  amount_cents: number;
+}
+
+export function normalize(raw: unknown) {
+  const payload = raw as any;
+  return {
+    orderId: payload.orderId,
+    amountCents: payload.amountCents,
+  };
+}

Review this PR

Node practice