---
id: WF-ACC-TRX-013
title: Apply payment events from the Integration Platform
trigger: >-
  The Platform router delivers declared payment event types to the registered
  consumer.
product_area: accounting
module: transactions
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-TRX-020
  - CAP-ACC-TRX-007
  - CAP-ACC-TRX-012
  - CAP-ACC-TRX-013
moves:
  - STATE-ACC-TRX-006
  - STATE-ACC-TRX-010
  - STATE-ACC-TRX-007
crosses:
  - SVC-ACC-TRX-transactions
hops:
  - 'n': 1
    actor_or_service: Integration events consumer
    action: >-
      Authorize and validate the delivered envelope and resolve each declared
      event to its workspace.
    anchor: >-
      services-accounting:modules/transactions/services/integrations/integration-events-consumer.ts:defineAccountingIntegrationEventsConsumer
    seam: event
    on_failure: Reject delivery from an unrecognized principal or invalid envelope.
    left_inconsistent: Delivery has created no financial effects.
    observer: The event router records delivery admission.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/integrations/integration-events-consumer.ts:defineAccountingIntegrationEventsConsumer;
      services-accounting:modules/transactions/tests/e2e/service-functions.e2e.spec.js#it
      refuses a principal the registry does not know (403) and an event that is
      not a package (400)
  - 'n': 2
    actor_or_service: Integration events
    action: >-
      Insert a consumption marker transactionally before handling a mapped event
      and skip an existing marker.
    anchor: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent
    seam: sync
    on_failure: This hop does not define a separate failure branch.
    left_inconsistent: No partial change remains at this hop.
    observer: The consumption marker records deduplication.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent;
      services-accounting:modules/transactions/tests/integration/services/integrations/integration-events.integration.spec.js#it
      records every event it handles or ignores by id in the handling
      transaction, and a replay is ignored by the row, not by a lookup
  - 'n': 3
    actor_or_service: Integration events
    action: >-
      Resolve eligible bank clearing, refund, cancellation and dispute outcomes
      using subject metadata or provider references.
    anchor: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent
    seam: sync
    on_failure: >-
      Undo both consumption marker and effect on fault, returning retry for that
      event.
    left_inconsistent: Delivery must be attempted again.
    observer: The router records retry outcome and schedules redelivery.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent;
      services-accounting:modules/transactions/tests/integration/services/stripe/stripe-webhooks.integration.spec.js#it
      opens a chargeback from charge.dispute.created, reading the tenant through
      the PaymentIntent, once
  - 'n': 4
    actor_or_service: Integration events
    action: >-
      Ignore events outside this module's effects; an event without a resolvable
      workspace has no consumption marker.
    anchor: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent
    seam: sync
    on_failure: This hop does not define a separate failure branch.
    left_inconsistent: No partial change remains at this hop.
    observer: The response records the outcome for each delivered event.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/integrations/integration-events.ts:applyIntegrationEvent;
      services-accounting:modules/transactions/tests/integration/services/integrations/integration-events.integration.spec.js#it
      records every event it handles or ignores by id in the handling
      transaction, and a replay is ignored by the row, not by a lookup
idempotency: >-
  Mapped event identities deduplicate handling, and delegated command keys
  derive from those identities.
concurrency: >-
  Each event has an independent transaction and financial handlers recheck
  unresolved state against scheduled recovery.
branches:
  - >-
    The retained native webhook remains a separate legacy event-delivery
    surface.
waits: []
evidence:
  - >-
    services-accounting at f47cb263:
    services/integrations/integration-events.ts, integration-events-consumer.ts;
    aws/accounting.service-functions.ts (integration_events).
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-CRY-001, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-AVL-001, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-VEN-001, TC-VEN-002, TC-VEN-003, TC-PRV-001, TC-PRV-002]
---
# Apply payment events from the Integration Platform

## What It Does

Event consumption couples delivery deduplication to the financial effect. Unmapped and reconciliation events have explicitly limited treatment.

## The Flow

```mermaid
flowchart TD
  h0["Integration events consumer"]
  h1["Integration events"]
  h0 --> h1
  h2["Integration events"]
  h1 --> h2
  h3["Integration events"]
  h2 --> h3
```

The numbered hops identify the participating services, synchronization boundary and evidence. Branch conditions in the frontmatter explain where preparation, completion and recovery diverge.

## When Something Fails

Each hop records its rollback, retry or compensation boundary and the result visible to callers or operators. External outcomes can remain unresolved after local preparation commits; the listed recovery behavior defines what remains pending.

## Open Design Questions

The unresolved matters are recorded in the module findings; this workflow does not establish additional product approval.
