Skip to content

Add webhook notification delivery system for on-chain settlement status updates #280

Description

@Cjay-Cyber-2

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

  • Confirmed and failed settlements trigger webhook dispatch events.
  • Webhook requests include X-Mergepay-Signature header for payload authenticity verification.
  • Webhook delivery failures log warnings without crashing worker execution loops.
  • Unit tests verify payload creation, HMAC signature calculation, and failed request handling.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programcomplexity: mediumDrips Wave — moderate scope, some designdrips-waveTracked in a Drips Wave programenhancementNew feature or requestworker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions