Description
When an expense settlement transaction transitions from pending to confirmed on-chain, external applications or notification handlers need to be informed. We need to implement a webhook notification service that dispatches signed HTTP payloads upon settlement state changes.
Context & Requirements
Background settlement processing occurs asynchronously in src/worker/. Once a Stellar payment XDR containing the MP:<code> memo is validated and confirmed on the Stellar ledger, subscribers or configured group webhook endpoints should receive a notification.
Requirements:
- Implement
src/services/webhook.ts to construct and send HTTP POST webhook payloads for events (e.g., settlement.confirmed, settlement.failed).
- Sign every outgoing webhook request payload using HMAC-SHA256 signature passed in the
X-Mergepay-Signature header.
- Dispatch webhooks asynchronously from the background settlement worker (
src/worker/).
- Ensure delivery timeouts (5 seconds) and handle HTTP errors gracefully without blocking the background worker execution.
Acceptance Criteria
Implementation Guidance
- Create
src/services/webhook.ts using node-fetch (or global fetch) to dispatch payloads.
- Integrate webhook calls into background worker processing logic in
src/worker/ after database status updates.
- Store signing secret in environment config.
Testing & Validation
- Add unit tests in
tests/services/webhook.test.ts using HTTP mocking to verify request headers and payload content.
- Verify HMAC signature calculation against test keys.
- Run existing test suites via
npm test.
Submission Guidelines
- Include "Closes #" in the PR description.
- Wait for assignment by maintainers prior to working on the issue.
- Follow standard codebase formatting and TypeScript rules.
Wave complexity: Medium
Description
When an expense settlement transaction transitions from pending to confirmed on-chain, external applications or notification handlers need to be informed. We need to implement a webhook notification service that dispatches signed HTTP payloads upon settlement state changes.
Context & Requirements
Background settlement processing occurs asynchronously in
src/worker/. Once a Stellar payment XDR containing theMP:<code>memo is validated and confirmed on the Stellar ledger, subscribers or configured group webhook endpoints should receive a notification.Requirements:
src/services/webhook.tsto construct and send HTTP POST webhook payloads for events (e.g.,settlement.confirmed,settlement.failed).X-Mergepay-Signatureheader.src/worker/).Acceptance Criteria
X-Mergepay-Signatureheader for payload authenticity verification.Implementation Guidance
src/services/webhook.tsusingnode-fetch(or globalfetch) to dispatch payloads.src/worker/after database status updates.Testing & Validation
tests/services/webhook.test.tsusing HTTP mocking to verify request headers and payload content.npm test.Submission Guidelines
Wave complexity: Medium