service

CNA Pay

Payments platform of the CNA network (recipients, their subaccounts at the payment vendor, bank accounts and gateway configurations). Records the facts of its objects in an outbox and publishes them through a separate process. Consumes no topic of another application.

Service

Overview

cna-pay is the payments platform of the CNA network, a Go API (api/) that client systems command through GraphQL. It does not share the TypeScript event framework of the other applications: each contract it owns is an events.Definition in api/internal/platform/events/pay/<entity>/<event_name>.go, with the same envelope (api/docs/EVENTS.md).

Outbox, then publisher. A service records the payload of each fact in events.outbox_messages, in the transaction of the change, byte for byte as it will be sent; the publisher wraps it in a new envelope at each round. A separate process, cmd/publisher, sends the outbox to Kafka in rounds, keyed by the routing key and in the recording order of each object, and marks a message published only once the brokers confirm it. Delivery is at least once, so every payload of a PAY contract opens with eventId and objectVersion for the consumer to deduplicate and order.

Envelope. cna-pay sets metadata.owner from the definition, always sends producedBy: PAY and also sends the contract version in metadata, as cna-one does.

Nothing is published yet. cna-pay keeps its facts in the outbox and publishes none until its message is in this catalog (cna-pay-docs, Eventos, “Caminho dos eventos até o CNA Event Catalog”): the deployed cna-pay runs the API alone, without the publisher. The topic is the aggregate root today (events.Topic); a topic per client system waits for the catalog team (cna-br/cna-pay#104).

Messages

Messages for this service

Sends messages (7)

Quickly find the message you need by searching for the name, type, or summary.
NameVersionTypeSummary
Recipient Created
v1.0.0eventThe platform recorded a new recipient: its public state at its birth, ACTIVE and neither transacting nor withdrawing while the vendor creates its subaccount. Recorded by cna-pay in its outbox in the transaction of the creation. No consumer yet.
Recipient State Changed
v1.0.0eventThe registry state of a recipient changed, such as ACTIVE to REFUSED when the vendor refuses its creation, or back to ACTIVE on a new attempt: its public state after the change, the state it left and the refused fields. Recorded by cna-pay in its outbox in the transaction of the change. No consumer yet.
Recipient Eligibility Changed
v1.0.0eventAn answer of what a recipient may do changed, transacting or withdrawing, such as when the vendor creates its subaccount and it may transact: its public state after the change. Recorded by cna-pay in its outbox in the transaction of the change. No consumer yet.
Recipient Verification Changed
v1.0.0eventThe verification (KYC) status of a recipient changed as the payment vendor reflects it: its public state after the change and the status it left. Recorded by cna-pay in its outbox in the transaction of the change. No consumer yet.
Recipient Bank Account Replaced
v1.0.0eventThe vendor confirmed the change of the bank account of a recipient, and the new account became current: the public state of the recipient, the new account masked, since when it is current and the account it replaced. Recorded by cna-pay in its outbox in the transaction of the confirmation. No consumer yet.
Recipient Bank Account Replacement Refused
v1.0.0eventThe vendor refused the change of the bank account of a recipient, and the current account stays: the public state of the recipient, the refused account masked, why and which fields. Recorded by cna-pay in its outbox in the transaction of the refusal. No consumer yet.
Gateway Configuration Activated
v1.0.0eventA gateway configuration of a recipient became active, born active or activated once the vendor returned the subaccount: the configuration with its recipient, capture channel and vendor. Recorded by cna-pay in its outbox in the transaction of the activation. No consumer yet.

Receives messages (0)

Quickly find the message you need by searching for the name, type, or summary.
NameVersionTypeSummary
No messages found

Kafka consumers

Consumers run in their own process, one per domain: cmd/consumer <domain>.

Consumer groupTopicsHandler
recipients-subaccount-reportspay.internal.Subaccount (internal, outside the model)api/internal/domains/recipients/subaccount/consumers/subaccount_reports_consumer.go

The group is prefixed with KAFKA_CONSUMER_GROUP_NAMESPACE when it is set (staging-recipients-subaccount-reports). It reads only the internal facts its own payment gateway records, which no client system receives (see Outside the model on PayPayDomainv1.0.0Payments platform bounded context of the CNA network. Owns the PAY message contracts for the recipients that receive mon...Ownercna-platformMapView docs).

Custom properties

PropertyValue
Runtimex-runtimeGo 1.27 + gqlgen (GraphQL) + Ent/PostgreSQL + franz-go
Events Pathx-events-pathapi/internal/platform/events/<owner>/<entity>/<event_name>.go