I already made a post explaining it, but it's in portuguese (feel free to translate it): https://lemmy.eco.br/post/18293426
I totally don't work with it and shill it every time.
Edit: the translation:
I believe this isn't talked about much, so I wanted to give a more technical explanation of how PIX (Instant Payments ~~Twitter~~, I think the X is just there to make the name look cool) works, explaining some of the main messages, the roles of each component, and everything else.
PIX is a messaging system between banks, using Bacen (Central Bank) as a router and system manager. In this system, there's the main part, in my view, which is the ICOM (communication interfaces), through which messages travel.
To send a message to another bank, it's necessary, using rfsn (Bacen's internal network), to connect to the server and send:
POST /api/v1/in/{ispb}/msgs
This way, Bacen sends the message to other banks, which through long polling, using multiparts (to retrieve multiple messages at the same time), pulls the messages for their bank by initializing the polling:
GET /api/v1/out/{ispb}/stream/start
and the actual retrieval:
GET /api/v1/out/{ispb}/stream/{PI-Pull-Next}
This way, any bank can send PIX messages to any other bank. But there are also two channels in PIX: the primary one, which handles instant payments, has administrative messages, etc., and the secondary one, which is used for payment batches, such as income tax refunds, social benefits, etc., which is primarily used during the early morning hours. These two channels are separated so one doesn't affect the other, so your weed PIX doesn't affect someone else's salary payment PIX and vice versa.
In this system, it can also happen that one bank communicates with Bacen (direct participant), while there are other banks registered under that bank (indirect participants). So when you send a payment to a fintech without a direct connection to Bacen, you send that payment to the direct participant who then sends it to that fintech.
But what messages are sent?
There are several, such as payment requests (pacs.008), acceptance or rejection due to business errors (pacs.002), refunds of payment amounts (pacs.004), PIX Automático messages (automatic debit and billing system through PIX), administrative messages (adding new banks, changing a bank's CNPJ/ISPB), etc. All messages are in XML format.
There are also validations that all banks need to perform with the messages (through the XSDs in that zip file), message hashes, verifications with public keys, signing sent messages. All of this to ensure the security that whoever is sending is really the bank that's sending.
There are also catalog changes for additions of new messages, changes to messages, alphanumeric CNPJ exchanges, those kinds of things, which happen according to a Bacen schedule and are made available on the website.
In this regard, there are some statistics about PIX for anyone who wants to see them too.
And how do PIX keys work (DICT)?
Basically, banks register people's accounts with the central bank, with the keys you know, making it so that instead of sending a manual PIX (if you enter the account, branch, bank, CPF, etc., at the time of sending, you can send a payment without a DICT key, the person doesn't even need to have a key for you to send them a PIX), there's a call to Bacen to verify which account belongs to that key, in order to actually send the PIX, it's that little window that opens after you enter the account key in the app.
So that's it, a more technical but basic explanation of how our payment system works, if there are any questions I can answer, let me know!