> For the complete documentation index, see [llms.txt](https://nayzeee-dev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nayzeee-dev.gitbook.io/docs/nayzeee-scripts/nayzeee-billing/exports.md).

# Exports

***

### Client Exports

<details>

<summary>OpenBilling</summary>

Opens the billing UI for the player.

```lua
exports['nayzeee-billing']:OpenBilling()
```

</details>

<details>

<summary>OpenAdmin</summary>

Opens the admin billing panel.

```lua
exports['nayzeee-billing']:OpenAdmin()
```

</details>

<details>

<summary>SendInvoice</summary>

Opens the send invoice dialog.

```lua
exports['nayzeee-billing']:SendInvoice(targetId, presetAmount, presetReason)
```

**Parameters:**

| Parameter      | Type   | Description                       |
| -------------- | ------ | --------------------------------- |
| `targetId`     | number | (Optional) Pre-fill target player |
| `presetAmount` | number | (Optional) Pre-fill amount        |
| `presetReason` | string | (Optional) Pre-fill reason        |

</details>

<details>

<summary>PayInvoice</summary>

Opens payment dialog for an invoice.

```lua
exports['nayzeee-billing']:PayInvoice(invoiceId)
```

**Parameters:**

| Parameter   | Type   | Description       |
| ----------- | ------ | ----------------- |
| `invoiceId` | number | Invoice ID to pay |

</details>

<details>

<summary>CanCreateInvoice</summary>

Checks if player can create invoices.

```lua
local canCreate = exports['nayzeee-billing']:CanCreateInvoice()
```

**Returns:** `boolean`

</details>

***

### Server Exports

<details>

<summary>CreateInvoice</summary>

Creates an invoice programmatically.

```lua
local invoiceId = exports['nayzeee-billing']:CreateInvoice(sender, target, items, company)
```

**Parameters:**

| Parameter | Type   | Description             |
| --------- | ------ | ----------------------- |
| `sender`  | number | Sender player ID        |
| `target`  | number | Target player ID        |
| `items`   | table  | Array of invoice items  |
| `company` | string | (Optional) Company name |

**Items Structure:**

```lua
{
    { label = 'Service Fee', amount = 500 },
    { label = 'Parts', amount = 200 },
}
```

**Returns:** `number` - Invoice ID or `nil`

**Example:**

```lua
-- Create invoice from mechanic script
local invoiceId = exports['nayzeee-billing']:CreateInvoice(
    mechanicId,
    customerId,
    {
        { label = 'Engine Repair', amount = 2500 },
        { label = 'Parts', amount = 800 },
        { label = 'Labor', amount = 500 }
    },
    'Benny\'s Motorworks'
)
```

</details>

<details>

<summary>GetPlayerInvoices</summary>

Gets all invoices for a player.

```lua
local invoices = exports['nayzeee-billing']:GetPlayerInvoices(source)
```

**Parameters:**

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| `source`  | number | Player server ID |

**Returns:** `table` - Array of invoice objects

</details>

***

### Integration Examples

#### Mechanic Billing

```lua
-- After repair is complete
RegisterNetEvent('mechanic:repairComplete')
AddEventHandler('mechanic:repairComplete', function(customerId, repairType, cost)
    local mechanicId = source
    
    exports['nayzeee-billing']:CreateInvoice(
        mechanicId,
        customerId,
        {
            { label = repairType, amount = cost }
        },
        'Los Santos Customs'
    )
end)
```

#### Hospital Billing

```lua
-- Bill patient after treatment
function BillPatient(doctorId, patientId, treatment, cost)
    exports['nayzeee-billing']:CreateInvoice(
        doctorId,
        patientId,
        {
            { label = treatment, amount = cost },
            { label = 'Facility Fee', amount = 50 }
        },
        'Pillbox Medical'
    )
end
```

#### ox\_target Integration

```lua
-- Add billing option to NPC
exports.ox_target:addModel('s_m_m_doctor_01', {
    {
        name = 'pay_medical',
        label = 'Pay Medical Bill',
        icon = 'fas fa-file-invoice-dollar',
        onSelect = function()
            exports['nayzeee-billing']:OpenBilling()
        end
    }
})
```

#### Check Unpaid Bills

```lua
-- Restrict actions if player has unpaid bills
local invoices = exports['nayzeee-billing']:GetPlayerInvoices(source)
local unpaid = 0
for _, inv in pairs(invoices) do
    if not inv.paid then
        unpaid = unpaid + 1
    end
end

if unpaid > 5 then
    -- Too many unpaid bills
    return false
end
```
