---
id: payment.completed
name: payment.completed
version: 1.0.0
summary: Emitted when a payment settles successfully.
schemaPath: schema.json
---
Generated from `cbd-payments-service/contracts/events/payment.completed.json`.
## Payload contract
This JSON Schema validates the event payload after a transport adapter removes any broker envelope. The same payload can travel through Kafka, NATS, SQS/SNS, RabbitMQ, EventBridge, Redis Streams, or the local NDJSON adapter.
## Transport contract
Topics, subjects, queues, routing keys, message attributes, retries, and acknowledgement policies belong to the transport contract. AsyncAPI can publish those channel and protocol details alongside this payload schema.
## Raw Schema:schema.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "payment.completed"
},
"payment": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"amount": {
"type": "number",
"exclusiveMinimum": 0
},
"currency": {
"type": "string",
"enum": [
"GBP",
"USD",
"EUR"
]
},
"status": {
"type": "string",
"enum": [
"processing",
"completed",
"failed"
]
},
"createdAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
}
},
"required": [
"id",
"amount",
"currency",
"status",
"createdAt"
],
"additionalProperties": false
},
"settledAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
}
},
"required": [
"type",
"payment",
"settledAt"
],
"additionalProperties": false,
"x-eventcatalog": {
"id": "payment.completed",
"version": "1.0.0",
"summary": "Emitted when a payment settles successfully.",
"producers": [
"payments-service"
],
"consumers": [
"reporter"
]
}
}
---
id: payment.failed
name: payment.failed
version: 1.0.0
summary: Emitted when a payment is declined or errors.
schemaPath: schema.json
---
Generated from `cbd-payments-service/contracts/events/payment.failed.json`.
## Payload contract
This JSON Schema validates the event payload after a transport adapter removes any broker envelope. The same payload can travel through Kafka, NATS, SQS/SNS, RabbitMQ, EventBridge, Redis Streams, or the local NDJSON adapter.
## Transport contract
Topics, subjects, queues, routing keys, message attributes, retries, and acknowledgement policies belong to the transport contract. AsyncAPI can publish those channel and protocol details alongside this payload schema.
## Raw Schema:schema.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "payment.failed"
},
"paymentId": {
"type": "string"
},
"reason": {
"type": "string"
},
"failedAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
}
},
"required": [
"type",
"paymentId",
"reason",
"failedAt"
],
"additionalProperties": false,
"x-eventcatalog": {
"id": "payment.failed",
"version": "1.0.0",
"summary": "Emitted when a payment is declined or errors.",
"producers": [
"payments-service"
],
"consumers": [
"reporter"
]
}
}
---
id: payments-service
name: payments-service
version: 1.0.0
summary: Publishes 2 contracted events.
sends:
- id: payment.completed
version: 1.0.0
- id: payment.failed
version: 1.0.0
---
Publishes 2 contracted events. Its runtime schemas generate committed payload artifacts before a transport adapter delivers each event.
---
id: reporter
name: reporter
version: 1.0.0
summary: Consumes 2 contracted events.
receives:
- id: payment.completed
version: 1.0.0
- id: payment.failed
version: 1.0.0
---
Consumes 2 contracted events. It reads committed payload artifacts and validates each event after a transport adapter removes the broker envelope.
---
id: payments
name: Payments
version: 1.0.0
summary: >-
HTTP and event contracts shared across repositories, languages, and
transports.
services:
- id: payments-service
version: latest
- id: reporter
version: latest
---
The dashboard generates a typed frontend client from the payments OpenAPI artifact.
Event consumers validate the committed JSON Schema payloads after their transport adapter removes any Kafka, NATS, SQS, RabbitMQ, EventBridge, or NDJSON envelope.
Payload schemas stay stable when delivery infrastructure changes. Topics, subjects, queues, routing, retries, and acknowledgements belong to the transport contract.