Recipient Created
The 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.
Overview
Fact: the platform recorded a new RecipientRecipientEntityv1.0.0A recipient (recebedor) of CNA Pay - every CPF or CNPJ enabled to receive money on the platform - a school, the franchis...Ownercna-platformView docs. The payload is the public state of the recipient at its birth, after eventId and objectVersion.
When it is published. CNA PayCNA PayServicev1.0.0Payments platform of the CNA network (recipients, their subaccounts at the payment vendor, bank accounts and gateway con...PublishesRecipientCreated, RecipientStateChanged +5Ownercna-platformMapRepoView docs records it in its outbox in the first transaction of a creation, the one that stores the recipient, always, also when the creation answers the command of its master system (cna-pay-docs RN-EVT-110): createRecipient, by which the One creates a school or a supplier, and createPlatformRecipient, by which the platform administration creates the franchisor, with no externalReference. The publisher process then sends it to Recipient (Kafka topic)Recipient (Kafka topic)Channelv1.0.0Kafka topic for the Recipient aggregate of CNA Pay - every CPF or CNPJ enabled to receive money on the platform. Carries...Ownercna-platformView docs.
The recipient is recorded before the vendor is asked for its subaccount, so it is born ACTIVE at objectVersion 1 and not eligible: canTransact and canWithdraw are false, and both reason lists hold SUBACCOUNT_CREATING. verificationStatus and refusalReason are null. What follows is another fact: Recipient Eligibility ChangedRecipient Eligibility ChangedEventv1.0.0An answer of what a recipient may do changed, transacting or withdrawing, such as when the vendor creates its subaccount...Ownercna-platformSchemaMapView docs when the vendor creates the subaccount and the recipient may transact, or Recipient State ChangedRecipient State ChangedEventv1.0.0The registry state of a recipient changed, such as ACTIVE to REFUSED when the vendor refuses its creation, or back to AC...Ownercna-platformSchemaMapView docs when it refuses the creation. A subaccount the vendor returns already blocked changes no answer, so no fact follows the birth.
The payload carries neither the document (CPF or CNPJ) nor the name of the recipient, nor any data of its managing partner (guard-rail 9, data minimization): the master system correlates the recipient by id and externalReference.
No consumer yet. The One is the expected first consumer. Delivery is at least once: a consumer drops an event whose eventId it already applied and a state older than the objectVersion it holds. cna-pay publishes nothing until this message is in the catalog (see Recipient (Kafka topic)Recipient (Kafka topic)Channelv1.0.0Kafka topic for the Recipient aggregate of CNA Pay - every CPF or CNPJ enabled to receive money on the platform. Carries...Ownercna-platformView docs).
Kafka
Topic (AggregateRoot) | Recipient |
Message key (RoutingKey) | payload.id |
| Contract owner | PAY |
metadata.event | RecipientCreated |
| Consumer group | (none yet) |
Payload schema
Source of truth
State and Eligibility are declared in api/internal/platform/events/pay/recipient/state.go and shared by every event of a recipient; events.Fact is declared in api/internal/platform/events/event.go and embedded first in every payload of a PAY contract. Both are embedded without a JSON name, so encoding/json/v2 writes their fields inline, in the order declared. No field has omitempty or omitzero: a nil pointer is written as null, and the reason lists are built never nil, so they are always arrays.
type CreatedPayload struct { events.Fact State}
var RecipientCreated = events.Definition[CreatedPayload]{ Name: "RecipientCreated", Owner: events.OwnerPay, AggregateRoot: "Recipient", Version: "1.0.0", RoutingKey: func(p CreatedPayload) string { return p.ID.String() },}
// api/internal/platform/events/pay/recipient/state.gotype State struct { ID uuid.UUID `json:"id"` ExternalReference *string `json:"externalReference"` Role string `json:"role"` MasterSystem string `json:"masterSystem"` RegistryState string `json:"registryState"` RefusalReason *string `json:"refusalReason"` VerificationStatus *string `json:"verificationStatus"` Eligibility Eligibility `json:"eligibility"`}
type Eligibility struct { CanTransact bool `json:"canTransact"` TransactReasons []string `json:"transactReasons"` CanWithdraw bool `json:"canWithdraw"` WithdrawReasons []string `json:"withdrawReasons"`}
// api/internal/platform/events/event.gotype Fact struct { EventID uuid.UUID `json:"eventId"` ObjectVersion int64 `json:"objectVersion"`}The enums are strings in the payload; their values come from api/internal/domains/recipients/role.go (role), master_system.go (masterSystem), recipient/lifecycle/registry_state.go (registryState), recipient/lifecycle/verification_status.go (verificationStatus), refusal_reason.go (refusalReason) and ineligibility_reason.go (the reason lists). The definition exists only in cna-pay.
Custom properties
| Property | Value |
|---|---|
| Contract Ownerx-contract-owner | PAY |
| Kafka Topicx-kafka-topic | Recipient |
| Message Keyx-message-key | id |
| Sourcex-source | cna-pay api/internal/platform/events/pay/recipient/recipient_created.go |
Unique, immutable id of the event (events.Fact), the same in every resend of it. A consumer drops an event whose eventId it already applied.
Version of the recipient after the change the event reports, from 1 (events.Fact). The facts of one change share it, so a consumer applies a fact of the version it holds and drops one older than it.
1Id of the recipient in cna-pay. Kafka message key.
Id of the registry in the master system, which correlates the recipient with it; not unique, since after a change of ownership the old and the new recipient point to the same registry (RN-RCB-130). Always sent; null for a recipient the platform administration created, such as the franchisor.
1Role of the recipient in the network (cna-pay recipients.Role). The One creates a SCHOOL or a SUPPLIER, and the platform administration only the FRANCHISOR; no command creates a CNA_INSTITUTE yet (cna-br/cna-pay#262).
SCHOOL FRANCHISOR CNA_INSTITUTE SUPPLIERClient system that owns the registry and receives the facts of the recipient, RN-EVT-155 (cna-pay recipients.MasterSystem): CNA_ONE for a school, a supplier and the franchisor; CNA_INSTITUTE for the CNA Institute, which has no topic yet, so a change of such a recipient fails whole until its topic exists (cna-br/cna-pay#297).
CNA_ONE CNA_INSTITUTEState of the registry after the change (cna-pay lifecycle.RegistryState): ACTIVE, what it may do being in eligibility; REFUSED, the vendor refused its creation and refusalReason says why; SUSPENDED and DEREGISTERED (final) are not produced in this delivery.
ACTIVE SUSPENDED DEREGISTERED REFUSEDNormalized reason of a REFUSED recipient (cna-pay recipients.RefusalReason): VENDOR_REFUSED_DATA, the vendor refused fields of the creation; VENDOR_REFUSED, it refused it without naming a field; CREATION_RETAKE_EXHAUSTED, the creation got no answer of the vendor until its retakes ran out (not produced yet, cna-br/cna-pay#389). Always sent; null unless registryState is REFUSED.
VENDOR_REFUSED_DATA VENDOR_REFUSED CREATION_RETAKE_EXHAUSTED Verification (KYC) of the recipient as the vendor reflects it (cna-pay lifecycle.VerificationStatus): IN_REVIEW, AWAITING_RECIPIENT (the vendor waits for the recipient; the pending items stay in the query of the recipient), APPROVED, or REJECTED (final). Always sent; null until the vendor reflects the first result.
IN_REVIEW AWAITING_RECIPIENT APPROVED REJECTED What the recipient may do (RN-RCB-150): two answers, each with the reasons that deny it.