Skip to content

Fix/recommand webhook notification#9

Merged
pritambiswal merged 2 commits intodevelopfrom
fix/recommand-webhook-notification
Feb 4, 2026
Merged

Fix/recommand webhook notification#9
pritambiswal merged 2 commits intodevelopfrom
fix/recommand-webhook-notification

Conversation

@pritambiswal
Copy link
Contributor

Problem

The webhook endpoint was treating all incoming data as raw XML. However, Recommand sends a
JSON notification when a document is received:

{
"eventType": "document.received",
"documentId": "doc_01KGC4QAPY9YWVRN03P9TAPV55",
"teamId": "team_01K8N25DE9T5A72FZMPJCBQQJH",
"companyId": "c_01K8N2P5YEMVJXSHRQQP60TSSE"
}

This notification was being saved as the XML content, instead of being used as a trigger to
fetch the actual document.

Solution

The webhook now:

  1. Detects Recommand notifications by checking for eventType: "document.received" in JSON
  2. Looks up integration settings using teamId (stored as account_id)
  3. Fetches actual XML from Recommand API using GET /api/peppol/{teamId}/documents/{documentId}
  4. Prevents duplicates by checking EDocument.reference before creating
  5. Falls back to raw XML for other providers (B2B Router, direct XML) - preserving existing
    behavior

Backward Compatibility

  • Existing webhook URL remains unchanged: /api/method/edocument_integration.api.webhook
  • Raw XML webhooks continue to work as before
  • Only Recommand JSON notifications trigger the new fetch logic

@pritambiswal pritambiswal force-pushed the fix/recommand-webhook-notification branch 3 times, most recently from 0a01b2a to 0da7fbc Compare February 4, 2026 22:16
Webhook now detects Recommand notifications (eventType: document.received)
and fetches actual XML from Recommand API using documentId.

- Parse incoming data as JSON first
- If Recommand notification, fetch XML via get_document_status API
- Check for duplicates using EDocument.reference field
- Fall back to raw XML for other providers (existing behavior)
@pritambiswal pritambiswal force-pushed the fix/recommand-webhook-notification branch from 0da7fbc to 4ed0106 Compare February 4, 2026 22:17
@pritambiswal pritambiswal merged commit 1ee1afe into develop Feb 4, 2026
4 checks passed
@pritambiswal pritambiswal deleted the fix/recommand-webhook-notification branch February 4, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant