Recipient State Changed
The 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.
Overview
Fact: the registry state of a 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 changed. The payload is the public state of the recipient after the change, after eventId and objectVersion, plus previousRegistryState, the state it left, and refusedFields.
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 transaction of the change of the registry state (cna-pay-docs RN-EVT-110). 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. In this delivery the changes are:
ACTIVEtoREFUSED, when the vendor refuses the creation of the subaccount (RN-RCB-165).refusalReasonisVENDOR_REFUSED_DATAwhen the vendor refused fields of the creation, whose paths in the input of the command go inrefusedFields, never their values, orVENDOR_REFUSEDwhen it named no field the input has, withrefusedFieldsempty.REGISTRY_REFUSEDjoins both reason lists. The refusal turns no answer of the eligibility, so this fact alone reports it, its state carrying the eligibility too.REFUSEDtoACTIVE, when its master system, or the back office of the platform, starts a new attempt in the same recipient withretryRecipientCreation:refusalReasonis back tonull,refusedFieldsis empty, and the recipient waits for its subaccount again (SUBACCOUNT_CREATING). The outcome of the new attempt is another fact, as for the first one.
CREATION_RETAKE_EXHAUSTED, a creation left without an answer of the vendor until its retakes run out, is not produced yet (cna-br/cna-pay#389). The suspension and the deregistration are not in this delivery.
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).
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 | RecipientStateChanged |
| Consumer group | (none yet) |
Payload schema
Source of truth
events.Fact and State are embedded without a JSON name, so their fields are written inline, before the fields of this payload. Both are shown on Recipient CreatedRecipient CreatedEventv1.0.0The platform recorded a new recipient: its public state at its birth, ACTIVE and neither transacting nor withdrawing whi...Ownercna-platformSchemaMapView docs. RefusedFields is built never nil, so it is always an array.
type StateChangedPayload struct { events.Fact State PreviousRegistryState string `json:"previousRegistryState"` RefusedFields []string `json:"refusedFields"`}
var RecipientStateChanged = events.Definition[StateChangedPayload]{ Name: "RecipientStateChanged", Owner: events.OwnerPay, AggregateRoot: "Recipient", Version: "1.0.0", RoutingKey: func(p StateChangedPayload) string { return p.ID.String() },}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_state_changed.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.
Registry state the recipient left (cna-pay lifecycle.RegistryState).
ACTIVE SUSPENDED DEREGISTERED REFUSEDPaths of the fields the vendor refused, in the input of the command that created the recipient or started its new attempt (company.address.zipCode, bankAccount.agency), when the change is a refusal with refusalReason VENDOR_REFUSED_DATA, which lists at least one; an empty array, never null, otherwise. Never their values.