How to Add a SEPA Payment QR Code to PDF Invoices with .NET Core
How to Add a SEPA Payment QR Code to PDF Invoices with .NET Core A small change to an invoice can make paying it much easier. With an EPC QR code on a PDF invoice, a customer can scan the code with a compatible banking
How to Add a SEPA Payment QR Code to PDF Invoices with .NET Core
A small change to an invoice can make paying it much easier.
With an EPC QR code on a PDF invoice, a customer can scan the code with a compatible banking app and have the payment details filled in for them. They still review and authorize the transfer in their bank app, but they donβt need to type the IBAN, amount, or invoice reference by hand.
I recently worked on adding this to PDF invoices in a .NET Core application backed by SQL Server. Hereβs the general approach, without getting into application-specific code.
What is an EPC QR code?
An EPC QR codeβsometimes called a SEPA Credit Transfer QR codeβis a way to encode payment details in a format that compatible banking apps can read.
The European Payments Councilβs guidance defines the data format and QR code requirements. Itβs intended for situations such as printed invoices, where the payment details are also available in readable text. Support can vary between banks and payment apps, so itβs important to keep the normal payment instructions on the invoice too. EPC QR code guidelines
The encoded details typically include:
- The beneficiaryβs name and IBAN
- The payment amount, if it is fixed
- A remittance reference or invoice number
- Optional payment information, such as a BIC where applicable The basic flow The QR code should be generated from the same trusted invoice and company data used to create the PDF:
- Load the invoice and beneficiary details. Get the invoice amount, currency, number or payment reference, and the companyβs payment account details.
- Build the EPC payment payload. Put the values in the order and format required by the EPC specification. Optional fields still need to occupy their correct positions.
- Generate the QR image. Use a QR library that lets you control the encoding and output quality.
- Add it to the PDF. Place the QR image near the payment instructions, with enough space around it to scan reliably.
- Keep readable payment details nearby. Print the IBAN, amount, and reference as text as well. That helps customers whose bank app doesnβt support EPC QR codes, and gives them a way to check what theyβre paying. Where .NET Core and SQL Server fit In a typical .NET Core application, SQL Server stores the invoice and company data. The application layer retrieves the relevant values, prepares the EPC payload, generates a QR image, and includes it when rendering the PDF.
Keeping those responsibilities distinct makes the feature easier to reason about:
- SQL Server remains the source for invoice and account data.
- The application layer validates the data and builds the payment payload.
- The PDF generation step places the QR image and readable payment details on the invoice. The QR code doesnβt replace the invoice or payment workflow. Itβs a convenient way to prefill a transfer in a compatible banking app. Details that deserve attention Use the final invoice amount If the amount is included in the QR code, make sure it matches the final invoice total, including applicable taxes, discounts, and adjustments. If the amount can change, consider whether leaving it out is more appropriate for your workflow. Use a useful payment reference The reference should help match the incoming transfer to the invoice. An invoice number is often a good starting point, provided it fits the format and length rules and your accounting process can reconcile it. Validate before generating Check that required values are present and valid before creating the QR code. Pay particular attention to the IBAN, beneficiary name, currency, amount formatting, and reference length. A QR code can be technically readable while still containing incorrect payment details. Test the PDF, not just the QR image A QR image may scan perfectly on screen but fail after being placed in a PDF or printed. Test the final invoice at its intended size, on screen and on paper, with several compatible banking apps if possible.
Also check that:
- The code has enough contrast and a clear margin around it.
- It isnβt stretched or blurred by PDF image scaling.
- It doesnβt overlap other invoice content.
- The printed payment details match the data encoded in the QR code. A useful improvement to invoice workflows This feature is a good example of a small technical change that removes friction from a routine business process. The customer has fewer details to enter, while the business still has a reference that can help identify the payment later.
Tavalle works on invoicing and business software, including PDF invoices and payment workflows. You can read more about Tavalleβs invoicing features or custom software development.
Final thought
Adding an EPC QR code isnβt just about drawing a square barcode on a PDF. The important work is keeping the payment data accurate, following the EPC format, and making sure the final invoice remains easy to use for everyone.
For the exact field requirements and technical constraints, refer to the European Payments Councilβs QR code guidelines.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.