Skip to main content

Exports

Client and server exports available from wasabi_billing. These are useful for job menus, radial menus, and third-party billing integrations.

danger

The resource folder must be named wasabi_billing for these exports to resolve.

Client exports​

UI-opening exports take no parameters and return no value. They do nothing if the dashboard is already open.

isUIOpen​

Returns whether the billing UI (dashboard or invoice receipt) is currently open.

local uiOpen = exports.wasabi_billing:isUIOpen()

if uiOpen then
print('Billing UI is open')
end

There is no public CloseUI export. Use the client wasabi_billing:closeUI event instead; see Events.

openBillingMenu​

Opens the billing dashboard on Overview.

exports.wasabi_billing:openBillingMenu()

openCreateInvoice​

Opens Overview with the Create Invoice modal.

exports.wasabi_billing:openCreateInvoice()

openPayReference​

Opens Overview with Pay by Reference.

exports.wasabi_billing:openPayReference()

openInspectCitizen​

Opens the admin view with the inspection modal. Opening an admin view does not bypass server-side admin checks.

exports.wasabi_billing:openInspectCitizen()

Server exports​

CreateInvoice​

Creates an invoice and returns its reference string, or nil on validation failure.

local reference = exports.wasabi_billing:CreateInvoice(
authorSource, targetIdentifier, amount, reason,
invoiceType, targetType, referenceId
)
ParameterTypeDescription
authorSourcenumberOnline issuing player's server ID, not their character identifier.
targetIdentifierstringBilled character's persistent identifier/citizenid, or raw job name for a society target. Not a target server ID.
amountnumberPositive amount before VAT; floored to a whole unit.
reasonstringInvoice description. Keep within 200 characters.
invoiceTypestring?'personal' (default) or 'society'. Society issuer is resolved from the issuing player's job.
targetTypestring?'personal' (default) or 'society'. Independent of the issuer type.
referenceIdstring?Optional unique reference. Otherwise generated with Config.ReferenceIdPrefix.
local reference = exports.wasabi_billing:CreateInvoice(
officerSource, targetCharacterIdentifier, 250,
'Traffic fine', 'society', 'personal'
)

if reference then
print(('Created invoice %s'):format(reference))
end

The issuer should be a valid online player. The target can be an offline character by persistent identifier. Society targets must be on the receive allow-list and require a society banking backend.

warning

This export skips the UI's society send-grade check, Config.MaxCustomAmount, proximity checks, and preset validation. Validate callers on the server before invoking it. Do not expose it through an unrestricted network event.

GetInvoice​

Returns one invoice row by reference, or nil if no record exists.

local invoice = exports.wasabi_billing:GetInvoice(referenceId)

if invoice then
print(invoice.reference_id, invoice.status, invoice.daysRemaining)
end

status is adjusted to effective overdue status and daysRemaining is added. Other fields retain the database row shape; this is not the NUI camelCase DTO.

FieldDescription
idNumeric database row ID.
reference_idPublic reference string.
author_identifier, author_nameIssuing character or society identifier and display name.
receiver_identifier, receiver_nameBilled character or society identifier and display name.
invoicer_identifierIssuing employee identifier; may be null on imported records.
invoice_typeIssuer type: 'personal' or 'society'.
receiver_typeReceiver type: 'personal' or 'society'.
reasonInvoice description.
amountPre-VAT amount.
vat_amountStored VAT amount.
total_amountStored total.
status'unpaid', 'overdue', 'paid', or 'cancelled'.
payment_method'bank' or 'cash' when recorded.
sent_date, limit_pay_dateStored date strings, normally YYYY-MM-DD HH:MM:SS.
paid_datePayment date string, or null.
daysRemainingWhole days remaining, rounded up; zero after expiry.

GetInvoicesByIdentifier​

Returns invoices tied to a character identifier/citizenid or society job name. Same row shape as GetInvoice.

local invoices = exports.wasabi_billing:GetInvoicesByIdentifier(identifier)

for _, invoice in ipairs(invoices) do
print(invoice.reference_id, invoice.status)
end

Returns an array (empty when nothing matches), newest database IDs first, limited to 200 records. Matches receiver, author, or invoicer_identifier. These reads are not filtered by the calling player's visibility; apply your own authorization before sending results to clients.

PayInvoiceByReference​

Settles an invoice on a player's behalf.

local paid = exports.wasabi_billing:PayInvoiceByReference(
payerSource, referenceId, 'bank'
)
ParameterTypeDescription
payerSourcenumberOnline player initiating the payment.
referenceIdstringInvoice to settle.
paymentMethodstring?'bank' or 'cash'. Omitted uses Config.PreferredPaymentMethod for a personal receiver.

Returns true on success, false on normal rejection. Failure notifications are sent to the supplied player.

For a personal receiver, the supplied player pays from their own account even if the invoice is addressed to another character. For a society receiver, the billed society's account is debited; that requires an admin or a member of that job with its management grade. This is not an offline debtor-collection command.

CancelInvoice​

Cancels an unpaid invoice. Does not refund a paid invoice.

local cancelled = exports.wasabi_billing:CancelInvoice(actorSource, referenceId)
ParameterTypeDescription
actorSourcenumberActing player's server ID.
referenceIdstringInvoice reference to cancel.

Returns true on success, false on rejection. Allowed actors are administrators, the author, the stored issuing employee, or an appropriately ranked member of the issuing society. Rows stored as overdue cannot be cancelled through this path.

invoice​

Inventory protocol callback used by ox_inventory when Config.InvoiceItem is set. The export name follows the configured item name.

server = { export = 'wasabi_billing.invoice' }

ox_inventory calls the handler as (event, item, inv, slot). Billing responds only to event == 'usingItem' and opens the invoice matching metadata.reference_id. This is not a general-purpose invoice-opening API. See Installation.

Compatibility exports​

When enabled in Config.CompatExports, wasabi_billing also answers export calls aimed at replaced billing resources. See Migration for setup rules.

codem-billing​

ExportPurpose
createBillingCreate an invoice from issuer and target server IDs. Amount is pre-VAT; optional society is normalized by stripping society_. Returns a reference or nil.
CheckBillingCount of unpaid/overdue received invoices among the latest 200 received records for a player server ID.
local reference = exports['codem-billing']:createBilling(
issuerSource, targetServerId, amount, reason, society
)
local count = exports['codem-billing']:CheckBilling(playerSource)

These are not exports on exports.wasabi_billing. The real codem-billing resource must be removed. wasabi_billing provides it in fxmanifest.lua.