# g-j4mb/payment-orchestrator architecture

> Architecture diagram of the GitHub repository g-j4mb/payment-orchestrator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/g-j4mb/payment-orchestrator
- Repository: https://github.com/g-j4mb/payment-orchestrator

## Overview

Payment Orchestrator provides a unified REST payment lifecycle while routing provider-specific work through a gateway abstraction. The main flow accepts an idempotent request, applies payment-domain rules, calls a selected provider, and returns payment state; webhook processing and scheduled reconciliation resolve uncertain outcomes. The README documents persistence, audit logging, and three provider adapters. Sampled controllers and services confirm key calls, but adapter internals and several use-case implementations were not sampled, so those relationships are documented rather than inferred from names.

Main entry points: [`src/main/java/com/j4mb/payment_orchestrator/payments/application/service/PaymentGatewayResolver.java`](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/PaymentGatewayResolver.java) (Gateway resolver), [`src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java) (Payment REST API), [`src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/PaymentPersistenceAdapter.java`](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/PaymentPersistenceAdapter.java) (Payment persistence), [`src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java`](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java) (Authorization service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Inbound API"]
  node_payment_api["Payment REST API"]
  node_webhook_api["Webhook endpoint"]
  node_scheduler["Reconciliation job"]
end

subgraph group_app["Application orchestration"]
  node_authorize["Authorization service"]
  node_capture["Capture service"]
  node_refund["Refund service"]
  node_void["Void service"]
  node_status["Status service"]
  node_webhook["Webhook processor"]
  node_reconcile["Pending reconciler"]
  node_idem["Idempotency checks"]
  node_resolver["Gateway resolver"]
end

subgraph group_domain["Payment domain"]
  node_payment["Payment aggregate<br/>[Payment.java]"]
  node_refund_policy["Refund policy<br/>[RefundPolicy.java]"]
end

subgraph group_adapters["Provider and storage adapters"]
  node_payment_store[("Payment persistence")]
  node_idem_store[("Idempotency store")]
  node_audit[("Audit logging")]
  node_stripe["Stripe adapter"]
  node_adyen["Adyen adapter"]
  node_checkout["Checkout adapter"]
end

node_client(("Client"))
node_providers(("Payment providers"))

node_client -->|"submits requests"| node_payment_api
node_payment_api -->|"authorizes"| node_authorize
node_payment_api -->|"captures"| node_capture
node_payment_api -->|"refunds"| node_refund
node_payment_api -->|"voids"| node_void
node_payment_api -->|"reads status"| node_status
node_webhook_api -->|"processes event"| node_webhook
node_scheduler -->|"runs reconciliation"| node_reconcile
node_authorize -->|"checks replay"| node_idem
node_authorize -->|"selects gateway"| node_resolver
node_authorize -->|"updates lifecycle"| node_payment
node_refund -->|"applies policy"| node_refund_policy
node_refund -->|"selects gateway"| node_resolver
node_webhook -->|"selects gateway"| node_resolver
node_webhook -->|"resolves state"| node_payment
node_reconcile -->|"selects gateway"| node_resolver
node_idem -->|"claims keys"| node_idem_store
node_resolver -.->|"resolves provider"| node_stripe
node_resolver -.->|"resolves provider"| node_adyen
node_resolver -.->|"resolves provider"| node_checkout
node_stripe -.->|"calls provider"| node_providers
node_adyen -.->|"provider stub"| node_providers
node_checkout -.->|"provider stub"| node_providers
node_authorize -.->|"persists payment"| node_payment_store
node_capture -.->|"persists payment"| node_payment_store
node_refund -.->|"persists payment"| node_payment_store
node_void -.->|"persists payment"| node_payment_store
node_status -.->|"loads payment"| node_payment_store
node_webhook -.->|"updates payment"| node_payment_store
node_reconcile -.->|"loads pending"| node_payment_store
node_payment -.->|"publishes events"| node_audit

click node_payment_api "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java"
click node_webhook_api "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/WebhookController.java"
click node_scheduler "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/scheduled/PendingPaymentReconciliationJob.java"
click node_authorize "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java"
click node_capture "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/CapturePaymentService.java"
click node_refund "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/RefundPaymentService.java"
click node_void "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/VoidPaymentService.java"
click node_status "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/GetPaymentStatusService.java"
click node_webhook "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ProcessWebhookService.java"
click node_reconcile "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ReconcilePendingPaymentsService.java"
click node_idem "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/IdempotencyCheckService.java"
click node_resolver "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/PaymentGatewayResolver.java"
click node_payment "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/domain/model/Payment.java"
click node_refund_policy "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/domain/service/RefundPolicy.java"
click node_payment_store "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/PaymentPersistenceAdapter.java"
click node_idem_store "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/idempotency/IdempotencyStoreAdapter.java"
click node_audit "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/audit/PaymentAuditLogEventListener.java"
click node_stripe "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/stripe/StripePaymentGatewayAdapter.java"
click node_adyen "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/adyen/AdyenPaymentGatewayAdapter.java"
click node_checkout "https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/checkout/CheckoutPaymentGatewayAdapter.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_payment_api,node_webhook_api,node_scheduler,node_client toneBlue
class node_authorize,node_capture,node_refund,node_void,node_status,node_webhook,node_reconcile,node_idem,node_resolver toneAmber
class node_payment,node_refund_policy toneMint
class node_payment_store,node_idem_store,node_audit,node_stripe,node_adyen,node_checkout toneRose
class node_providers toneIndigo
```

## Components

### Inbound API

- [Payment REST API](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`
- [Webhook endpoint](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/WebhookController.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/WebhookController.java`
- [Reconciliation job](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/scheduled/PendingPaymentReconciliationJob.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/scheduled/PendingPaymentReconciliationJob.java`

### Application orchestration

- [Authorization service](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java`
- [Capture service](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/CapturePaymentService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/CapturePaymentService.java`
- [Refund service](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/RefundPaymentService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/RefundPaymentService.java`
- [Void service](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/VoidPaymentService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/VoidPaymentService.java`
- [Status service](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/GetPaymentStatusService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/GetPaymentStatusService.java`
- [Webhook processor](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ProcessWebhookService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ProcessWebhookService.java`
- [Pending reconciler](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ReconcilePendingPaymentsService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ReconcilePendingPaymentsService.java`
- [Idempotency checks](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/IdempotencyCheckService.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/IdempotencyCheckService.java`
- [Gateway resolver](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/application/service/PaymentGatewayResolver.java): `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/PaymentGatewayResolver.java`

### Payment domain

- [Payment aggregate](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/domain/model/Payment.java): `src/main/java/com/j4mb/payment_orchestrator/payments/domain/model/Payment.java`
- [Refund policy](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/domain/service/RefundPolicy.java): `src/main/java/com/j4mb/payment_orchestrator/payments/domain/service/RefundPolicy.java`

### Provider and storage adapters

- [Payment persistence](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/PaymentPersistenceAdapter.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/PaymentPersistenceAdapter.java`
- [Idempotency store](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/idempotency/IdempotencyStoreAdapter.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/persistence/idempotency/IdempotencyStoreAdapter.java`
- [Audit logging](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/audit/PaymentAuditLogEventListener.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/audit/PaymentAuditLogEventListener.java`
- [Stripe adapter](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/stripe/StripePaymentGatewayAdapter.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/stripe/StripePaymentGatewayAdapter.java`
- [Adyen adapter](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/adyen/AdyenPaymentGatewayAdapter.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/adyen/AdyenPaymentGatewayAdapter.java`
- [Checkout adapter](https://github.com/g-j4mb/payment-orchestrator/blob/main/src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/checkout/CheckoutPaymentGatewayAdapter.java): `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/out/gateway/checkout/CheckoutPaymentGatewayAdapter.java`

### Other components

- **Client**
- **Payment providers**

## Connections

- Client → Payment REST API: submits requests (evidence: `README.md`)
- Payment REST API → Authorization service: authorizes (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`)
- Payment REST API → Capture service: captures (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`)
- Payment REST API → Refund service: refunds (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`)
- Payment REST API → Void service: voids (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`)
- Payment REST API → Status service: reads status (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/PaymentController.java`)
- Webhook endpoint → Webhook processor: processes event (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/infrastructure/adapter/in/web/WebhookController.java`)
- Reconciliation job → Pending reconciler: runs reconciliation (evidence: `README.md`)
- Authorization service → Idempotency checks: checks replay (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java`)
- Authorization service → Gateway resolver: selects gateway (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java`)
- Authorization service → Payment aggregate: updates lifecycle (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/AuthorizePaymentService.java`)
- Refund service → Refund policy: applies policy (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/RefundPaymentService.java`)
- Refund service → Gateway resolver: selects gateway (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/RefundPaymentService.java`)
- Webhook processor → Gateway resolver: selects gateway (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ProcessWebhookService.java`)
- Webhook processor → Payment aggregate: resolves state (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ProcessWebhookService.java`)
- Pending reconciler → Gateway resolver: selects gateway (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/ReconcilePendingPaymentsService.java`)
- Idempotency checks → Idempotency store: claims keys (evidence: `src/main/java/com/j4mb/payment_orchestrator/payments/application/service/IdempotencyCheckService.java`)
- Gateway resolver → Stripe adapter: resolves provider (evidence: `README.md`)
- Gateway resolver → Adyen adapter: resolves provider (evidence: `README.md`)
- Gateway resolver → Checkout adapter: resolves provider (evidence: `README.md`)
- Stripe adapter → Payment providers: calls provider (evidence: `README.md`)
- Adyen adapter → Payment providers: provider stub (evidence: `README.md`)
- Checkout adapter → Payment providers: provider stub (evidence: `README.md`)
- Authorization service → Payment persistence: persists payment (evidence: `README.md`)
- Capture service → Payment persistence: persists payment (evidence: `README.md`)
- Refund service → Payment persistence: persists payment (evidence: `README.md`)
- Void service → Payment persistence: persists payment (evidence: `README.md`)
- Status service → Payment persistence: loads payment (evidence: `README.md`)
- Webhook processor → Payment persistence: updates payment (evidence: `README.md`)
- Pending reconciler → Payment persistence: loads pending (evidence: `README.md`)
- Payment aggregate → Audit logging: publishes events (evidence: `README.md`)
