Exports & Developer API
These functions are declared in fxmanifest.lua under server_exports and are meant to be called from other server-side resources (for example finals_banking when Config.UsingFinalsBankingInvoice is true).
Replace finals_billingsystem with your resource folder name if it differs.
local BILLING = 'finals_billingsystem'Prerequisites
- oxmysql must be running (
GetResourceState('oxmysql') == 'started'). - Pending rows must exist in
finals_billing_invoiceswithstatus = 'pending'andremaining_amount > 0(created by this resource’s pay-later flow or compatible inserts).
GetPendingInvoices(citizenid)
Returns all pending invoices for a single character, ordered by due date (soonest first).
Arguments
| Name | Type | Description |
|---|---|---|
citizenid | string | number | Character identifier used in the database. Must match how this resource stores citizenid for your framework (see below). If nil, returns {}. |
Framework note (BillingFW.GetCharId):
- QBCore / QBX:
citizenidfrom player data - ESX:
identifier - ox_core:
charIdas a string (e.g."123")
Return value
A table (array) of invoice objects. Empty {} if none, invalid id, or database unavailable.
Each element:
| Field | Type | Description |
|---|---|---|
id | number | Invoice row id (primary key) |
entryId | number | Index into Config.Billing |
label | string | Entry Lable or 'Invoice' |
logo | string | nil | Entry logo URL if configured |
original | number | Original invoice amount |
remaining | number | Amount still owed |
reason | string | Reason text |
dueUnix | number | Due time (Unix seconds) |
billerName | string | nil | Stored biller display name |
Example
local cid = '12345' -- must be the same id this resource uses for that character
local invoices = exports['finals_billingsystem']:GetPendingInvoices(cid)
for _, inv in ipairs(invoices) do
print(inv.id, inv.label, inv.remaining, inv.dueUnix)
endPayInvoice(source, invoiceId, amount, method)
The player at source pays toward a pending invoice. Money is deducted in this resource from bank or cash (using framework + BillingFW.RemoveMoneyForced rules for that billing entry).
Arguments
| Name | Type | Description |
|---|---|---|
source | number | Player server id |
invoiceId | number | id from GetPendingInvoices / database |
amount | number | Amount to pay (integer dollars after floor; capped to remaining balance internally) |
method | string | 'bank' or 'cash' (anything other than 'cash' is treated as bank) |
Return values
| Success | Failure |
|---|---|
true | false, err (string) |
Possible err values
| Code / message | Meaning |
|---|---|
invalid_args | Missing/invalid source, invoiceId, or amount < 1 |
database_unavailable | oxmysql not started |
invalid_player | No framework player for source |
invoice_not_found | No matching pending invoice for this player |
Invalid invoice type. | Config.Billing[entry_id] missing |
Not your invoice. | Character id does not match row |
Invalid amount. | After clamping, nothing to pay |
Insufficient funds. | Could not deduct the payment |
Partial payments are supported: remaining balance is updated until fully paid (status → paid).
Example
local ok, err = exports['finals_billingsystem']:PayInvoice(src, invoiceId, 500, 'bank')
if not ok then
print('Pay failed:', err)
endConfirmInvoicePayment(source, invoiceId, amount, method)
Same as PayInvoice, but does not remove money from the player. Use this when another resource has already taken the funds (e.g. a savings/extra account in finals_banking). This export only runs distribution (biller / society / receipts / webhook) and updates the invoice row.
Arguments
Same as PayInvoice: source, invoiceId, amount, method ('bank' or 'cash' — used for bookkeeping / metadata, not for a second deduction).
Return values
Same pattern as PayInvoice: true or false, err.
Typical errors overlap with PayInvoice, except you will not get Insufficient funds. from this path (no deduction step).
Example
-- After your banking script has already removed $500 from the player:
local ok, err = exports['finals_billingsystem']:ConfirmInvoicePayment(src, invoiceId, 500, 'bank')Summary
| Export | Deducts money? | Use when |
|---|---|---|
GetPendingInvoices | — | Building a UI or list of dues for a character id |
PayInvoice | Yes | Player pays from cash/bank inside this resource |
ConfirmInvoicePayment | No (already done elsewhere) | Integrating external banking after funds are taken |
For configuration that disables the in-world invoice clerk and relies on another resource for the UI, see Config.UsingFinalsBankingInvoice in config.lua.