Skip to content

fix(rest/nodejs): deliver the order object as the webhook body#146

Merged
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/nodejs-webhook-order-body
Jul 24, 2026
Merged

fix(rest/nodejs): deliver the order object as the webhook body#146
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:fix/nodejs-webhook-order-body

Conversation

@vishkaty

Copy link
Copy Markdown
Contributor

Mirrors #140 (now merged) on the Node.js side.

What

The orderEvent webhook body must be an order object (rest.openapi.json
{"$ref": "order"}), but the Node.js server posted a custom envelope
{ event_type, checkout_id, order } (rest/nodejs/src/api/checkout.ts), and
posted it even when there was no order.

This posts the order object as the JSON body, carries the event type in an
X-Event-Type header, and skips delivery when there is no order — identical to
the fix merged for the Python server in #140.

Test

Adds rest/nodejs/test/webhook.test.ts (node:test, no new deps): stubs the
outbound fetch to capture the delivered request and asserts the body is the
bare order (all required order fields, no event_type/nested-order envelope
keys), the event type is in X-Event-Type, and there is no delivery when the
checkout has no order. Fails on the old envelope, passes on the fix.

Verification

  • npm ci clean, npm run build (tsc) 0 errors, npm test 7 passed (5
    existing + 2 new), pre-commit clean.

Mirrors Universal-Commerce-Protocol#140 (the Python fix): the orderEvent webhook body must be an order
object (rest.openapi.json $ref: order), but the Node.js server posted a custom
{event_type, checkout_id, order} envelope, and posted it even with no order.

Post the order object as the body, carry the event type in an X-Event-Type
header, and skip delivery when there is no order. Adds a test that captures the
delivered webhook request and asserts the body is the bare order with the event
type in the header.
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Jul 24, 2026

@damaz91 damaz91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good and align the Node.js implementation with the Python fix in #140 by delivering the bare order object as the webhook body and carrying the event type in the X-Event-Type header. Tests look good and pass.

Note: The current UCP specification requires Webhook-Timestamp and Webhook-Id headers for the orderEvent webhook. Neither the Python nor this Node.js implementation currently sends these headers. Opened a separate issue to track adding these spec-mandated headers to both implementations (#147).

@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Jul 24, 2026
@damaz91
damaz91 merged commit 93602b4 into Universal-Commerce-Protocol:main Jul 24, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants