Skip to content
Technology for businesses since 2008

Blog

How to integrate your system with the ERP and bank (Pix, boleto)

To integrate your business system with the bank and the ERP, the system starts requesting each charge from the bank through an API or a CNAB file, stores its identifier and receives the payment notice from the bank, by webhook or return file. With that notice, the invoice is settled on its own and the entry goes on to the ERP, which handles accounts receivable, invoicing and accounting. What makes the integration work is not the technology chosen, but three decisions: who creates the charge, which system is the source of truth for each piece of data and what to do when the notice does not arrive.

This guide is about Brazil, where Pix (the Central Bank’s instant payment system) and boleto (a registered bank slip) are common ways to get paid. It shows how money moves between systems, what changes between Pix and boleto and what to check before hiring the integration.

What it means to integrate your system with the ERP and the bank

Bank integration is making your business system talk to the bank without anyone copying and pasting. Instead of creating the boleto in online banking, emailing it and then looking for the payment in the statement, the system does all three.

Three systems are usually involved:

  • Operations system: where the sale, the contract or the monthly fee happens. It can be custom software, an online store or a customer portal.
  • Bank or payment provider: creates the Pix and the boleto, receives the money and reports when the payment comes in.
  • ERP: short for enterprise resource planning, the business management system. It brings together accounts receivable, invoicing, inventory and accounting.

Not every company has all three. Sometimes the operations system itself plays the role of the ERP in finance.

How a payment moves between the system, the bank and the ERP

  1. The charge is born in the system. A sale, an invoice or an installment creates a record with amount, due date, customer and a unique identifier.
  2. The system requests the charge from the bank. It sends the data through an API or in a remittance file and gets back the Pix QR Code, the boleto number or both.
  3. The customer receives it and pays. By email, WhatsApp, customer portal or on the payment screen.
  4. The bank reports the payment. By webhook, which is a message the bank sends to an address in the system as soon as something happens, or by the return file.
  5. The system settles the invoice. It finds the invoice by the identifier, marks it as paid and releases whatever depends on the payment: the order, the access, the service.
  6. The ERP receives the entry. The item in accounts receivable is settled, and invoicing and accounting follow the company’s process.

The weak point is the first step. If someone creates a charge by hand outside the system, it arrives with no identifier, and settlement goes back to being manual.

Pix and boleto: what changes in the integration

Pix with dynamic QR Code Registered boleto Pix Automático
What it is for One-off sale or invoice, with or without a due date Invoice with a due date, for those who prefer paying by boleto Monthly fees and other recurring charges
How the system requests it The bank’s Pix API The bank’s API or a CNAB remittance file Pix API or standard file, depending on the bank
How it knows it was paid Webhook or query of received Pix Webhook, query or return file Webhook or query, depending on the bank
Who can receive Those with a Pix-enabled account at the chosen bank Those with a billing agreement with the bank Only those with a CNPJ, including MEI (individual microentrepreneur)
Watch out for Each QR Code must be tied to an invoice Payment of a boleto already written off at the bank and overdue boletos The payer authorizes first and can cancel

Pix: immediate charges and charges with a due date

The Central Bank of Brazil publishes a single specification for charging by Pix, the Pix API. It covers immediate charges, to be paid right away, and charges with a due date, which accept late fees, interest, rebates and discounts. It also covers queries of received Pix, refunds and webhook registration.

Each charge has an identifier, the txid, which the system defines or receives from the bank. It is what links the payment to the invoice. Under the specification, the bank can group several payments in the same notice and sets its own timing for sending the webhook. The system has to be ready for both.

The specification is standardized, but access is not. Each bank decides which parts it offers in each contract, and the same call may work at one bank and be denied at another.

Boleto: API or CNAB file

A boleto can be registered in two ways:

  • CNAB file: a file standard from Febraban, the federation of Brazilian banks. In the CNAB 240 billing layout, the company sends a remittance file with new boletos, instructions and changes. The bank sends back a return file with the confirmation or rejection of each boleto, payments and write-offs. Each bank publishes its own manual based on the standard, with fields and rules that vary.
  • Bank API: the system registers the boleto right away and gets the boleto number in the response. The payment notice arrives by webhook or by query, depending on the bank.

Some banks offer a boleto with a Pix QR Code, which the customer can pay either way. In that case, the integration has to recognize the payment through both paths and not settle the invoice twice.

One case the system has to handle: the CNAB layout has its own code for a payment received after the boleto was already written off. Without handling it, the money comes in and the invoice stays open, or the customer receives a charge they already paid.

Pix Automático: recurring charges

Pix Automático is the Pix option for recurring charges. According to the Central Bank implementation guide, the payer authorizes once, in their own bank’s app, and the following charges are debited on the scheduled date, with no further action. The guide also says that:

  • only those with a CNPJ can receive through Pix Automático, including sole proprietors and MEI;
  • offering the option for receiving is optional for banks, and those that offer it must accept at least the Pix API or the standard file;
  • the receiver’s bank may charge the receiver a fee, and the payer pays no fee;
  • each charge must be sent between two and ten calendar days before the debit date.

For the system, this changes the routine: the month’s charge goes out in advance, and the integration has to track canceled authorizations and debits that did not happen for lack of funds.

API or CNAB file: which to use

API CNAB file
When the charge is registered Right away, with each request When the file is sent and processed
How the payment arrives Webhook or query Return file, fetched or received
Fits Online sales, Pix, immediate release Batch billing, an ERP that already works with files
What it requires Credentials, certificate, public address for the webhook Billing agreement, file exchange with the bank
Variation between banks Their own endpoints and rules, less so for Pix, which has a Central Bank specification Each bank’s own manual based on the Febraban standard

There is no single answer. The same integration can use an API for Pix and files for boleto, if that is what the bank offers. Ask your bank what is available in your contract before designing the integration.

How to integrate your system with the ERP

The bank is only half the work. The other half is getting the payment to the ERP with no typing.

  • Define the source of truth. Decide where the invoice is born and where it is settled. If the ERP and the operations system both create charges, one of them will settle an invoice the other does not know about.
  • Check how the ERP integrates. Some offer an API, others only file import, and some only enable integration on specific plans. Ask the vendor for the documentation.
  • Use the same identifier on both sides. The invoice or item number has to be the same in the system, the bank and the ERP.
  • Send what is not a payment too. Discounts, late fees, interest, cancellations and Pix refunds have to reach the ERP with the right amount, or reconciliation will not close.
  • Tie invoicing to the flow. If the tax invoice is issued after payment, settlement can trigger it. If it is issued before, the charge carries the invoice number.

Automatic settlement and bank reconciliation: what can go wrong

Bank reconciliation is checking whether what the system says it received matches what came into the account. With the integration, it stops being done line by line, but it still exists. These are the cases the integration has to plan for:

  • Notice that does not arrive. The webhook fails or the return file is not processed. The system should check with the bank from time to time and compare with what is still open.
  • Repeated notice. The same payment arrives twice. Settlement must happen only once.
  • Payment with a different amount. Interest, late fees, discounts or rebates change the final amount. The system has to know what to accept and what to send for review.
  • Payment of an invoice already paid or canceled. The money comes in, but the invoice was already closed.
  • Pix refund. The amount leaves the account and the invoice has to go back to open or to the agreed state.
  • Pix with no charge. The customer pays to the Pix key, with no QR Code, and the payment arrives with no identifier.

For each case, agree on who is notified and what to do. Whatever the system cannot resolve on its own goes to a review queue instead of disappearing.

Security: certificates, keys and who can do what

  • Credentials and certificate. The Pix API uses authorization by OAuth 2.0, an access token standard, with separate permissions to create charges, read payments and register webhooks. Under the specification, the webhook is protected by mutual authentication with a certificate, known as mTLS.
  • Least privilege. An integration that only issues charges does not need access to payments. At some banks, payments started through the API still require approval in the app.
  • Secrets outside the code. Keys and certificates stay in a protected place on the server, with renewal planned before the certificate expires.
  • Log everything. Each charge created, each notice received and each settlement is logged, with date and source.
  • Personal data. Payers’ name, CPF (Brazilian individual tax ID) and email are personal data. Brazil’s data protection law, the LGPD, requires security measures to protect them, in article 46.

What to check before you start

  1. List the payment methods. One-off Pix, Pix with a due date, boleto, boleto with QR Code, Pix Automático, card.
  2. Ask your bank what is in your contract. API or file, test environment, fees per charge and webhook.
  3. Ask for the ERP documentation. How to receive items and settlements, and whether integration costs extra.
  4. Map out the error cases. The six from the bank reconciliation section, with who resolves each one.
  5. Test with real cases. Payment on the due date, late, with a discount, partial, refunded and made after the boleto was written off.
  6. Agree on monitoring. Who is notified when the integration stops, and how soon someone looks into it.

If the current bank or ERP does not offer integration, the decision becomes a different one: change vendors or keep a manual process. The article off-the-shelf or custom software helps you think through that choice.

How MigraCloud can help

MigraCloud does systems integration and automation and develops custom web systems for businesses. We are based in Joinville, in the state of Santa Catarina, Brazil, and were founded in 2008. We connect the operations system, the ERP and payment methods through APIs and webhooks, document what is connected to what and monitor the integrations.

The systems we have developed include a service invoice (NFS-e) issuer, with an API for other systems to issue invoices, and a coworking management system with finance and a customer portal. The guide on coworking management software covers recurring billing in that segment.

The first step is to see which systems the company uses and where manual work repeats. If you want to evaluate your case, get in touch.

Frequently asked questions

How do you integrate a business system with the bank to create Pix and boleto charges?
The system connects to the billing API of the bank or payment provider, with credentials and a certificate supplied by them. Pix (instant transfer) and boleto (bank slip) are common payment methods in Brazil. When a sale or invoice is created, the system requests the charge, receives the QR Code or the boleto number and stores the identifier. When the payment comes in, the bank notifies the system by webhook or by return file, and the invoice is marked as paid on its own.
What is automatic settlement of boleto and Pix?
It is recording the payment in the system without anyone checking the bank statement. The bank reports that the charge was paid, the system finds the invoice by the charge identifier and marks it as received. For this to work, each charge has to be created in the system with a unique identifier, not by hand in online banking.
What is the difference between CNAB and an API for boleto?
CNAB is a file standard from Febraban, the Brazilian federation of banks: the company sends a remittance file with the boletos and the bank sends back a return file with confirmations, payments and write-offs. With an API, the system registers each boleto right away and can be notified of the payment by webhook. Both are still in use, and each bank defines what it offers and under what conditions.
Do I need an ERP to integrate my system with the bank?
No. The system itself can create the charges and record the payments. The ERP comes in when the company already uses one for accounts receivable, invoicing and accounting. In that case, define which of the two is the source of truth for each piece of information, so an invoice is not created or settled twice.
Can monthly fees be charged by Pix automatically?
Yes, through Pix Automático, in which the payer authorizes once and the following charges are debited on the scheduled date. Under the rules of the Central Bank of Brazil, only those with a CNPJ (Brazilian company tax ID) can receive through this option, and offering it for receiving is optional for banks. Check with your bank whether it offers it and through which channel: Pix API or file.
What happens if the bank's payment notice does not arrive?
The integration has to plan for it. The system should check with the bank from time to time, through the API or the return file, and compare with what is still open. That way, a lost notice becomes a delay of a few hours, not a paid invoice charged again to the customer.

Custom software development

Want to look at your case?

Tell us how your operation works today and what needs to change.