> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unibee.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# External Gateway Invoices

> Use external gateways to process payments outside of UniBee while keeping invoices and revenue records consistent in UniBee.

## Overview

In some cases, you may want to process payments **outside of UniBee** using your own gateway or a third‑party checkout, while still using UniBee to:

* Generate invoices
* Track payment status
* Keep subscription and revenue data consistent

For this scenario, UniBee supports **External Gateway Invoices**:

* UniBee issues and manages the invoice
* The actual payment happens in an external system
* Your backend calls UniBee payment-level APIs to **update the external payment link** and report **payment/refund results** after external processing

This is useful for:

* Integrating with an in‑house payment system or legacy gateway
* Using a regional payment aggregator not directly supported as a UniBee gateway
* Migrating gradually from an existing billing system to UniBee

***

## Typical Workflow

1. **Create an invoice in UniBee** (via the normal invoice creation flow / API).
2. **Redirect the customer to your external checkout** using your own payment link.
3. **Update the Payment link in UniBee** so invoice and hosted entry points can redirect to your latest external checkout URL.
4. **Mark the Payment as paid** in UniBee after your gateway confirms success.
5. (Optional) **Create/handle refund flow** and report refund success/failed via External Gateway refund APIs.

UniBee will then:

* Update invoice status (`Paid`, `Refunded`, etc.)
* Trigger the appropriate subscription behavior (e.g., activate or renew a subscription when an invoice is paid)
* Emit [webhook events](/documentation/webhooks/webhook-events.mdx) such as `payment.created`, `refund.created`, `invoice.paid`, or `refund.success`

***

> For a **full integration guide** (security, webhooks, and common patterns), see\
> [External Gateway Integration Guide](/documentation/business-integration/external-gateway-integration).
