Blog
/
Guides

Billing Integrations Explained: Types, Architecture & Examples

See how billing integrations keep payments, credits, entitlements, and product state aligned, and how to prevent failures before they reach customers.

Sara NelissenSara Nelissen
Written by
Sara Nelissen
Last updated
August 28, 2026
read time
14
minutes
Billing Integrations Explained: Types, Architecture & Examples

Table of contents

We’ve found that billing integrations rarely become painful during the happy path. The trouble starts with failed webhooks, duplicate events, refunds, mid-cycle upgrades, and customers who somehow end up with different states across three systems.

A billing integration is the infrastructure that keeps those systems aligned. For AI products, getting that right can directly affect credits, access, spend limits, and whether the next request is allowed to run.

What is a billing integration?

A billing integration connects a billing or payment system with another application, so customer, subscription, usage, payment, or financial state can move between them without someone manually reconciling spreadsheets at the end of the month.

That "another application" could be several different things:

  • Billing to product
  • Billing to payment processor
  • Billing to CRM
  • Billing to accounting or ERP
  • Billing to a data warehouse
  • Billing to entitlement or usage infrastructure

For AI products specifically, that last one is where things get interesting. The integration often determines whether a financial event, a payment, a refund, or a plan change also affects credits, entitlements, limits, or what the product will actually allow a customer to do next.

How billing integrations work

Billing integrations move commercial state between systems and make sure each system reacts correctly to the same event. Most rely on APIs, webhooks, event streams, or queues to keep payments, subscriptions, credits, entitlements, and customer records in sync.

1. An event happens in one system

The flow starts when something changes. A customer might complete checkout, upgrade a plan, purchase more credits, receive a refund, or sign a new enterprise contract.

That event triggers a state change that other parts of the stack may need to be aware of.

2. The source system sends the event

The billing or payment provider usually exposes the change through a webhook, API response, or event stream.

For example:

Payment succeeds → payment_succeeded event is emitted

The receiving system should validate the event before acting on it, including its event ID, customer ID, event type, timestamp, and payload.

3. The integration maps the event to the product state

This is where the real application logic begins.

A successful credit purchase might trigger:

Payment succeeds → credit grant created → wallet balance updated → ledger entry recorded

A plan upgrade could update entitlements and usage limits instead. A refund might require revoking unused credits or adjusting the customer's balance.

From there, the integration updates whatever product state depends on that event, whether that is a credit balance, entitlement, or usage limit.

4. The update propagates to other systems

One billing event can affect several services. A plan change might need to reach the product, CRM, data warehouse, accounting system, and customer dashboard.

These updates do not always need to happen at the same speed. Accounting can usually tolerate an asynchronous sync. A credit balance that determines whether an AI agent can continue running may need to be updated much more frequently.

5. Failures, retries, and reconciliation keep the systems aligned

Production integrations also need a recovery path when synchronization fails. The goal is to keep downstream state consistent even when an event is delayed, or a step in the workflow does not complete.

That makes idempotency, retries, durable event storage, and reconciliation core parts of the architecture. 

The goal is a consistent state across the stack, even when the happy path breaks.

The main types of billing integrations

Billing integrations differ mainly in what crosses the system boundary and how quickly the receiving side needs to react. A payment event, contract update, and warehouse sync may all involve billing data, but they have very different latency and reliability requirements.

1. Payment processor integrations

Payment processor integrations connect your billing layer to providers such as Stripe or Adyen. They carry events around payments, refunds, failed charges, invoice settlement, and payment method changes.

Payment status should remain anchored to the processor, while downstream systems react to those financial events. That boundary becomes especially important for refunds, failed payments, and asynchronous settlement, where product state may need to change later.

2. Product and entitlement integrations

Let’s say a customer upgrades their plan, and their payment succeeds. What should change inside the product?

That may include access to new features, a larger credit balance, higher usage limits, access to premium models, or a larger agent budget. Product and entitlement integrations carry those commercial changes into the application itself.

Product and entitlement integrations sit closer to application behavior, since a commercial change can alter what features, models, or capacity the customer has access to.

3. CRM and CPQ integrations

Enterprise pricing often starts outside the billing system. Sales may negotiate custom rates, commitments, contract dates, or account-specific limits in a CRM or CPQ tool.

A billing integration carries those negotiated terms into the systems responsible for charging and provisioning the customer. Effective dates and pricing versions matter here, especially when a contract changes mid-billing period.

4. Accounting and ERP integrations

These integrations move financial records into systems used for accounting, reconciliation, and reporting.

Common records include invoices, payments, refunds, credits, and adjustments.

They usually do not need the same response time as a product-facing integration. Accuracy matters more. A delayed accounting update can be reconciled later. A duplicated refund or missing credit creates a much harder financial cleanup.

5. Data warehouse integrations

Billing data becomes much more useful when it is joined with product usage data.

An AI company might combine revenue data with:

  • Token consumption
  • Model usage
  • GPU cost
  • Agent runs
  • Tool calls
  • Credit burn
  • Customer-level margins

That makes it possible to see whether a $5,000 account is actually profitable, which models are driving cost, or where customers consistently burn through their allowance.

For AI products, that analysis often tells you more than billing totals alone.

6. Marketplace integrations

Selling through a cloud or software marketplace adds another system of record to the stack. The marketplace may have its own customer IDs, usage-reporting requirements, contracts, and settlement process.

Identity gets messy quickly. One enterprise account can have a marketplace identifier, an internal account ID, a CRM record, and a separate billing customer ID. Those records need to resolve to the same customer before usage, payments, and entitlements can stay aligned.

What changes between these integrations is the tolerance for delay and failure. A warehouse sync might recover minutes later without consequence, whereas a credit or entitlement update can affect an AI request already waiting to run.

API, webhook, or native integration?

Billing integrations usually rely on more than one connection method. A native integration might handle the standard flow, while webhooks push state changes and APIs handle edge cases that require custom logic.

Integration method Best for Main advantage Main engineering concern
Native integration Common billing workflows Fastest path to production Limited control over custom behavior
API Custom reads, writes, and workflows Precise control over how systems interact Timeouts, retries, validation, and error recovery
Webhook Reacting to billing events as they happen Event-driven updates without constant polling Duplicate, delayed, or out-of-order delivery
Queue or event stream High-volume or multi-service architectures Durable processing and easier replay More infrastructure to operate and observe
Middleware or iPaaS Connecting several business systems Less integration code to maintain internally Complex domain logic can become difficult to express

Most teams start simple, then add structure as the edge cases pile up. A webhook may be enough at first, until retries, duplicate events, or outages start causing state drift.

APIs and queues give you more control over those failures, which is why mature billing stacks usually use more than one integration pattern.

Billing integration architecture for an AI product

AI billing gets more interesting once money and product behavior start changing each other in real time. Instead of one clean handoff from product to billing, you end up with two connected flows that have to stay in sync.

Commercial state → product state

Customer → checkout or billing provider → payment_succeeded → billing integration → credit or entitlement state → usage runtime → AI request

A payment might grant credits, but an upgrade can grant access to a model or raise a usage limit.

Product usage → commercial state

AI request → usage event → metering → billing → invoice or reporting

The product creates the usage. An agent runs, credits are consumed, the balance changes, and any overage may become billable.

Both flows can hit the same account within seconds. A customer might buy more credits while several agents are still running, or downgrade while usage events are still arriving.

The integration must keep the commercial and product states aligned across overlaps without double-counting, stale balances, or conflicting updates.

5 billing integration examples for AI products

The easiest way to understand billing integrations is to look at where state can drift. In AI products, interesting cases usually involve money changing in one system while credits, limits, or entitlements change in another.

1. Purchasing AI credits

A customer buys 10,000 AI credits. The payment clears, the grant is created, the wallet updates, and the ledger records the source of that balance.

Payment → grant → wallet → ledger

The important boundary is between the financial transaction and the product grant. The ledger should make it possible to trace those 10,000 credits back to the purchase that created them and to explain every subsequent debit or adjustment to that balance.

2. Automatic credit top-ups

Top-ups are one of those features that look easy in a product spec and get interesting fast in production.

Suppose an agent burns through the last few credits while several requests are running concurrently. Two requests may see the balance below the threshold at nearly the same time. If both trigger a purchase, the customer gets charged twice.

The system needs a reliable way to coordinate the top-up, confirm payment, create the grant once, and cleanly recover if any step fails midway.

3. Enterprise invoice to credit allocation

An enterprise contract might include 1 million credits per year, but very few companies want every team drawing from a single, unrestricted pool.

Engineering may get 400,000 credits, while support gets 300,000 and sales gets 200,000. The remaining 100,000 stay at the organization level.

Now the integration is doing more than just provision a balance. It has to translate a commercial agreement into a hierarchy of grants and limits while preserving the underlying account-level commitment. This is where tenancy design begins to directly affect billing architecture.

4. Refund to credit revocation

Refunds quickly reveal whether your billing integration can correctly handle changes in credit state.

Say a customer buys credits, uses 60% of them, and then receives a partial refund. The system needs to determine how many credits to revoke, which grant to adjust, and how to preserve the original purchase and usage history.

A safer approach is to record the refund as a new adjustment or revocation in the ledger. You keep a clear history of the original grant, what the customer consumed, and what changed after the refund.

5. Mid-cycle plan change

This is the one I would test early.

A customer upgrades while three agents are still running. The new plan includes more credits, higher limits, and access to a premium model. Billing may also need to prorate the plan change.

Several clocks are now running at once:

  • When does the new price take effect?
  • When do the new entitlements become active?
  • Do in-flight agent runs use the old or new limits?
  • What happens to unused credits from the previous plan?
  • Which system owns each decision?

Mid-cycle changes expose weak boundaries quickly because billing state, entitlement state, and active usage can all change within seconds of each other.

What these flows have in common is overlap. Payments, credits, entitlements, and active usage can all change within the same window, so the integration must maintain a coherent account state while those updates are in flight.

How to define the source of truth in billing integrations

A surprising number of integration bugs start with two systems believing they own the same piece of state. The code can be working exactly as written while Stripe, your product catalog, and your internal database all disagree about which value is current.

A clean billing integration starts by assigning one source of truth to each state:

State Likely source of truth
Payment status Payment processor
Invoice Billing system
Price Product catalog or billing system
Credit balance Credit infrastructure
Entitlement Usage runtime
Usage Metering system
Contract metadata CRM or CPQ

Bidirectional writes make that ownership boundary much harder to preserve. If two systems can independently update the same balance, entitlement, or contract state, retries and delayed events can turn a small sync issue into conflicting records.

A safer pattern is to let one system own each state and have the rest subscribe to, reference, or react to changes in that state. That makes failures easier to reason about and gives engineering teams a clear answer when two systems disagree.

What can go wrong with a billing integration?

A billing integration can fail when events are duplicated, delayed, lost, processed out of order, or applied to the wrong customer or state.

In billing, those familiar distributed-systems problems have very concrete consequences: duplicate credits, blocked paying customers, incorrect entitlements, and financial records that quietly drift away from what the product believes to be true.

Duplicate events

Webhook retries are normal. If the same payment_succeeded event arrives twice, the handler should still create one credit grant, one entitlement update, and one ledger entry.

That is why idempotency has to be designed into the flow from the start. Relying on a handler to "probably only run once" is how duplicate credits and double-applied plan changes happen.

Events arrive out of order

A refund can arrive while the original purchase is still processing. A downgrade event can land before an earlier upgrade finishes propagating.

Once that happens, the arrival order can no longer be treated as a business order. Versioned state, timestamps, and reconciliation logic give the system enough context to work out what should actually be true.

Events disappear

Missing events are easy to overlook because the billing provider can look perfectly healthy while your product state falls behind.

A payment succeeded, but your webhook endpoint is unavailable. The provider records the transaction, while your application never receives the event needed to update access, credits, or account state.

Retries cover short interruptions. Durable event storage and replay give you a reliable recovery path when outages last longer or delivery repeatedly fails.

Identity mapping breaks

A single customer may exist as:

  • a Stripe customer ID
  • an internal account ID
  • a CRM account
  • an enterprise organization
  • several workspaces underneath it

We have seen integrations go surprisingly far before anyone clearly defines how those identities map to each other. Once that mapping is ambiguous, usage, refunds, credits, and entitlements can be applied to the wrong account, even when every individual API call succeeds.

Partial failures

These are usually the incidents that hurt the most.

Payment succeeds → credit grant fails

Now the customer has paid, but the product still blocks them.

The integration needs to know how to retry safely, where failed events go, how an operator can inspect them, and how state gets reconciled later. Dead-letter handling and observability matter because some failures will need a human to understand what happened.

State drifts over time

Billing says Enterprise. The product says Pro. The CRM contains a custom contract.

Nobody necessarily made a bad update. One event may have failed months ago, and the systems moved on.

That is why mature billing integrations do not rely solely on event delivery. Periodic reconciliation compares the relevant states and surfaces disagreements before a customer finds them first.

Webhooks are delivery mechanisms, not sources of truth

Webhooks are useful for fast notification, but their delivery semantics are exactly why the failure modes above exist. Duplicate delivery, delayed events, and downstream failures all have to be handled outside the webhook itself.

Duplicate and out-of-order deliveries are normal problems in event-driven systems. Google Cloud Pub/Sub uses at-least-once delivery by default and does not guarantee ordering unless explicitly configured.

That distinction matters more than it sounds. A webhook endpoint returning 200 OK only proves that the request reached your handler. It says nothing about whether the credit grant was written, the entitlement changed, or the downstream service accepted the update.

For production billing, webhook handling usually needs:

  • Idempotent processing so retries are harmless
  • Persistent event storage so events can be inspected and replayed
  • Retry-safe handlers that recover cleanly from partial failures
  • Dead-letter handling for events that repeatedly fail
  • Monitoring around business outcomes, rather than HTTP status alone

Once access to money or products depends on the event, treating webhook processing as durable infrastructure no longer feels excessive.

Why AI billing integrations need real-time product state

A slight delay is often harmless on the financial side of the stack. A payment lands at 10:00, the CRM catches up at 10:01, and accounting syncs at 10:05. Nobody loses anything because the general ledger was four minutes behind.

But an AI workload can behave very differently in those same four minutes.

An agent may issue hundreds of model calls, invoke paid APIs, spin up compute, or trigger other agents while its credit balance or entitlement state is stale. By the time the financial systems catch up, the infrastructure cost has already been incurred.

That is why AI products usually need to separate two timing requirements:

  • Asynchronous financial integration works well for invoices, accounting, reporting, and other workflows that can tolerate lag.
  • Synchronous runtime decisioning is needed when the next request depends on a credit balance, entitlement, agent budget, usage limit, or spend rule.

The closer a state change gets to product execution, the less tolerance there is for stale data.

Billing integration vs. runtime enforcement

These two layers often exchange the same commercial data, but they solve different problems.

Billing integration Runtime enforcement
Primary job Keeps the commercial state synchronized Controls product behavior
Typical timing Often asynchronous Synchronous
Handles Payments, invoices, plans, refunds Credits, limits, entitlements, spend rules
Tolerance for delay Often seconds or minutes Usually sits directly in the request path
Core question What changed? Can this request run?

A missed billing update can often be reconciled later. Runtime enforcement must return a decision for the request arriving now, which places the two layers under very different timing requirements.

Most production AI architectures need both layers, with a clear boundary between them.

How to design a reliable billing integration

Before shipping a billing integration, I would want clear answers to six questions:

  • Are ownership boundaries encoded in the integration? Validate incoming events against the authoritative system instead of letting downstream copies silently become writable state.
  • Can every write be retried safely? Reprocessing an event should never create another charge, grant, or entitlement change.
  • Can failed events be replayed? Keep enough event history to recover without relying on the provider to resend the original payload.
  • What happens after a partial failure? Define what the system does when one side commits and the other side times out.
  • How will drift be detected? Reconciliation should compare the business state periodically instead of relying entirely on event delivery.
  • Are you monitoring the outcome? A 200 OK is transport telemetry. The useful signal is whether the expected credit grant, refund, or access change actually occurred.

A reliable integration is one you can recover, replay, inspect, and explain after something goes wrong.

Build billing integrations yourself or use native integrations?

A custom integration can be the right answer for a long time. If you have one billing provider, a small number of workflows, and product-specific logic, owning the integration gives engineering direct control.

The trade-off changes as the stack becomes more complex. You may start dealing with:

  • Multiple billing providers
  • Custom enterprise contracts
  • Refunds that affect credits or usage
  • Frequent migrations
  • Reconciliation requirements from finance
  • Webhook retries and version changes
  • Schema changes and identity mappings across systems

That is usually where native integrations become more useful.

Engineering teams can build all of this. The better question is which parts are strategic enough to keep owning and which parts have become infrastructure you would rather stop maintaining.

How Stigg works alongside your billing integrations

Your billing provider can keep handling the financial side. Stigg sits alongside it as the usage runtime, managing the product-facing state that must remain accurate during AI usage. That includes:

  • Credit grants tied to purchases: Turn successful payments into the correct credit balance without rebuilding payment logic inside the product.
  • Real-time credit consumption and synchronous enforcement: Check balances and usage limits in the request path before additional AI usage runs.
  • Refunds, revocations, and automatic top-ups: Keep credit state aligned when money is refunded, balances are adjusted, or more credits are purchased automatically.
  • Ledger-backed auditability: Maintain a traceable record of every grant, debit, expiration, and adjustment behind a customer’s balance.
  • Complex tenancy across accounts, teams, users, and agents: Apply separate balances, limits, and entitlements across multiple levels of the same organization.
  • BYOC and modular adoption: Deploy the runtime in your own cloud and adopt credits, entitlements, or metering independently without replacing your billing stack.
  • Low-latency enforcement at scale: With persistent caching, entitlement and credit checks resolve instantly from a local Redis cache on a cache hit. On a cache miss, the runtime falls back to Stigg's Edge API at around 100ms, with a configurable timeout so upstream latency never blocks the request path

Billing keeps the financial record. Stigg keeps credits, entitlements, limits, and spend governance in sync with what the product is allowed to do. The Stigg docs show how these billing integrations and runtime checks fit together in practice.

FAQs

1. Can one customer be connected to multiple billing providers?

Yes. One customer can connect to multiple billing providers during migrations or when different products use separate billing systems. A stable internal customer ID should map each provider back to the same account so credits, entitlements, and billing state stay aligned.

2. How should billing integrations handle API version changes?

Billing integrations should pin to a specific API version and treat upgrades as planned migrations. Test new payloads, deprecated fields, and webhook schemas before switching versions in production.

3. Do billing integrations need PCI compliance?

Billing integrations may need PCI compliance, but it depends on how payment data flows through your infrastructure.

Raw card data increases PCI compliance requirements, while tokenized payment methods from a payment processor keep most sensitive payment data out of your systems entirely.

4. How do you test billing integrations before production?

Test billing integrations in a sandbox or test environment, including failure scenarios as well as successful payments. Simulate duplicate webhooks, delayed events, declined payments, out-of-order delivery, timeouts, refunds, and partial failures before production traffic depends on the integration.

5. How should you migrate a billing integration without interrupting active customers?

To migrate a billing integration without interrupting active customers, run the old and new integrations in parallel during the migration and compare their outputs before switching traffic.

Dual-writing or shadowing events can surface differences in invoices, credits, entitlements, and customer state while the existing system remains authoritative.

Latest news.

One email per month.
From engineers, for engineers.

Thank you! Your submission has been received.
Oops! Something went wrong while submitting the form.