Skip to content
All posts

How We Built Raseed Pro’s FBR Integration on Django

When FBR made digital invoicing mandatory, Raseed Pro had to keep up without slowing down a single checkout. Here’s how we built a fast, secure, and failure-proof Django FBR integration using Celery, encrypted tokens, and smart retry logic, plus the lessons we learned along the way.

Muhammad ArslanCo-FounderPublished

When Pakistan’s Federal Board of Revenue (FBR) made digital invoicing mandatory for sales tax registered businesses, our clients came to us with one question: “Will Raseed Pro handle this?” The answer had to be yes, and it had to be yes without slowing down billing counters, disrupting daily operations, or turning tax compliance into a constant headache.

In this post, we share how our team at ThunderMind Tech approached Raseed Pro’s Django FBR integration: the thinking behind our decisions, the challenges we faced, and the lessons that apply to any business planning to connect its software with FBR.

Why FBR Integration Matters?

Under FBR’s digital invoicing system, registered businesses must report every sales invoice to FBR in real time. Once FBR accepts an invoice, it issues a unique FBR invoice number, which must appear on the customer’s receipt along with a QR code. Customers can scan that code to confirm the invoice is genuine and properly reported.

For businesses, this changes everything about billing. Every sale now depends on a connection to a government system. If that connection is slow, checkout is slow. If it fails without anyone noticing, the business falls out of compliance. If the invoice details are incorrect, FBR rejects them, and someone has to sort out the problem by hand.

Raseed Pro is an invoicing and point-of-sale platform used by retailers, distributors, and service businesses across Pakistan. For our clients, FBR compliance couldn’t be a bolt-on feature. It had to be a dependable, built-in part of how they bill customers every day.

Setting Clear Goals From Day One:

Before our developers started building, we sat down and defined what success would look like. We settled on four goals.

Billing should never be held up. A cashier with a queue of customers should never be stuck waiting for FBR’s servers to respond.

No invoice should ever be lost. Every single invoice must eventually reach FBR, even if the internet drops or FBR’s system is temporarily unavailable.

Problems should be easy to understand. When something goes wrong, the business owner should see a clear explanation and know exactly what to fix, not a confusing technical error.

Every business should be handled separately. Raseed Pro serves many businesses, each with its own NTN, its own FBR credentials, and its own stage of setup. The integration had to keep all of this neatly separated and secure.

These four goals guided every decision that followed.

Why We Chose Django?

Raseed Pro was already built on Django, and that turned out to be a major advantage. Django is a mature, stable, and secure web framework trusted by organizations around the world. It encourages clean, organized code, has strong built-in security features, and works well with the background processing tools we needed for this project.

Rather than mixing FBR logic throughout the entire application, we built the integration as its own self-contained module. The rest of Raseed Pro simply hands over an invoice once it’s finalized, and the FBR module takes care of everything else. This separation means that when FBR updates its requirements, which government systems often do, we can adapt quickly without risking the rest of the platform.

Keeping a Complete Record of Every Submission:

One of the most valuable decisions we made was to keep a detailed history of every invoice sent to FBR. For each submission, Raseed Pro records its current status, the FBR invoice number once issued, how many attempts were made, and exactly what was sent and what FBR replied.

This may sound like a small detail, but it has saved countless hours. When a client calls asking why a particular invoice was rejected, our support team can see the full story in seconds. There’s no guesswork and no back-and-forth trying to recreate what happened.

We also keep a local copy of FBR’s reference information, such as provinces, product classification codes, units of measure, and applicable tax rates, and refresh it regularly. This allows Raseed Pro to check invoices for common mistakes before they’re even sent, and it makes setting up products much easier for users.

Protecting Sensitive Credentials:

Each business connected to FBR receives its own security token. This token is essentially a key that allows invoices to be submitted on that business’s behalf, so protecting it is critical.

In Raseed Pro, these tokens are always encrypted and never stored in readable form. They’re only unlocked at the exact moment an invoice is being sent, and they never appear in logs, reports, or error messages. We also allow each business to start in FBR’s testing environment, so new clients can try everything safely before going live.

Translating Invoices Into FBR’s Format:

Raseed Pro supports discounts, product bundles, mixed tax rates, returns, and many other real-world billing scenarios. FBR, on the other hand, expects invoice information in a very specific structure.

A large part of our work was building a reliable translation step between the two. Every product on an invoice is matched to the correct classification code, unit of measure, sale type, and tax rate. All amounts are calculated with precise financial accuracy, because even tiny rounding differences can cause FBR to reject an invoice. In fact, rounding mismatches were the most common issue we ran into during testing, so we invested heavily in getting them right.

Before an invoice is officially submitted, Raseed Pro first checks it against FBR’s validation service. This catches problems early, such as a missing customer registration number or an incorrect product code, and shows the user a clear message straight away.

Making Sure Checkout Stays Fast:

This is where our first goal came to life. When a cashier completes a sale, Raseed Pro saves the invoice and immediately shows the receipt screen. The FBR submission happens quietly in the background, usually completing within a second or two.

If FBR is slow or temporarily unreachable, the system doesn’t give up. It automatically tries again after a short pause, then waits a little longer before each following attempt. This approach avoids overwhelming FBR’s servers while making sure the invoice gets through as soon as possible.

We were also careful to make sure an invoice can never be submitted twice by accident, even if a retry happens at an unexpected moment. And we distinguish between temporary issues, like a network timeout, which are retried automatically, and genuine data problems, like an invalid product code, which are flagged for a person to review.

Some businesses need the FBR invoice number printed on the receipt before the customer leaves. For them, Raseed Pro offers a mode that waits briefly for FBR’s response. If it arrives in time, it prints. If not, the invoice continues in the background and the receipt can be reprinted once the number is ready.

Planning for the Unexpected:

No connection to an external system is perfect. Government services occasionally go down, and internet connections drop. We built three safety nets to make sure nothing slips through the cracks.

An automatic check runs every few minutes, finds any invoices still waiting or stuck, and tries them again. A simple dashboard shows each business how many invoices are submitted, pending, or need attention, so owners always know where they stand. And our team receives alerts if failures suddenly increase across multiple clients, which usually signals an issue on FBR’s side rather than a client’s data.

We also rewrote FBR’s error messages into plain, friendly language. A shop owner gets far more value from “This product’s tax category doesn’t match its sale type” than from a cryptic error code.

QR Codes and Professional Invoices:

Once FBR accepts an invoice, Raseed Pro automatically adds the FBR invoice number, the required logo, and a scannable QR code to the receipt. This works across thermal printer receipts, full-page invoices, and downloadable PDFs, so businesses stay compliant no matter how they share invoices with customers.

Thorough Testing Before Going Live:

FBR provides a testing environment with specific scenarios that every integration must pass before it can be used for real invoices. We automated these tests so we could run them quickly and repeatedly. Combined with our own internal quality checks, this gives us the confidence to release updates to Raseed Pro without putting any client’s compliance at risk.

What We Learned?

Building this integration taught us several lessons that apply to any business connecting with FBR. Keep the integration separate from the rest of your system so changes are easy to manage. Record everything, because a clear history makes support fast and painless. Be extremely careful with calculations and rounding. Never make customers wait on an outside system when the work can happen in the background. And above all, plan for things to go wrong, because automatic retries, regular checks, and clear visibility are what turn a fragile connection into a reliable one.

Need FBR Integration for Your Business?

Our experience building Raseed Pro’s FBR integration means we know exactly where the challenges lie and how to solve them. Whether you need FBR digital invoicing added to your existing Django application, a custom ERP or POS system, or a complete billing platform built from scratch, ThunderMind Tech is ready to help.

Contact us today to talk about your project, or hire our expert Django team to make your business FBR-compliant quickly, securely, and reliably.


The SEO keywords, description, tags, and excerpt from earlier still fit this version, since none of them referenced code.

 
Written byMuhammad ArslanCo-Founder
// Keep reading

More from the blog

Have a project in mind?

Tell us what you're building. A co-founder replies within one business day.