Exports & Events
Use these server exports to integrate JK Billing with your custom scripts and resources.
Server exports
CreateInvoice(data)Create an invoice programmatically from any server script.
local ok, invoiceId = exports['JK-Billing']:CreateInvoice({
targetIdentifier = 'license:abc123', -- Target player identifier
targetName = 'John Doe', -- Target player display name
issuerIdentifier = 'license:xyz789', -- Issuer identifier
issuerName = 'Dr. Smith', -- Issuer display name
issuerJob = 'ambulance', -- Job name for society invoices
amount = 5000, -- Invoice amount
reason = 'Medical Treatment', -- Invoice reason/description
})
if ok then
print('Invoice created with ID: ' .. invoiceId)
else
print('Failed: ' .. tostring(invoiceId))
endReturns: boolean success, number|string idOrError
GetUnpaidInvoices(targetIdentifier)Get all unpaid invoices for a player by their identifier.
local invoices = exports['JK-Billing']:GetUnpaidInvoices('license:abc123')
for _, invoice in ipairs(invoices) do
print(string.format('ID %d: $%d from %s - %s',
invoice.id,
invoice.amount,
invoice.issuer_name,
invoice.reason
))
endReturns: table[] — invoice objects with: id, amount, reason, issuer_name, issuer_job, target_name, status, created_at
PayInvoiceByIdForSource(sourceId, invoiceId)Pay an invoice on behalf of an online player. Money is deducted from the player's configured account.
local ok, result = exports['JK-Billing']:PayInvoiceByIdForSource(source, 42)
if ok then
print('Invoice paid! Amount: $' .. result.amount)
else
print('Payment failed: ' .. tostring(result))
endReturns: boolean success, table|string invoiceOrError
CanManageCatalog(source)Check if a player has permission to manage the product catalog for their job.
local canManage, jobName = exports['JK-Billing']:CanManageCatalog(source)
if canManage then
print('Player can manage catalog for job: ' .. jobName)
endReturns: boolean canManage, string|nil jobName
Framework public functions
Available in sv_framework_public.lua and callable via the global FrameworkPublic table:
FrameworkPublic.GetIdentifier(src)Returns the unique identifier for the player (ESX identifier, QB citizenid, or license).
FrameworkPublic.GetName(src)Returns the player's RP character name.
FrameworkPublic.GetJob(src)Returns jobName, grade for the player.
FrameworkPublic.IsJobAllowed(jobName)Checks if a job can issue society invoices based on Config.Billing.jobs.
FrameworkPublic.FindSourceByIdentifier(identifier)Finds an online player's source ID by identifier. Returns nil if not online.
Banking public functions
Available in sv_banking_public.lua:
BankingPublic.AddSocietyMoney(jobName, amount)Add money to a society/job bank account. Auto-routes to the correct banking system.
BankingPublic.RemoveSocietyMoney(jobName, amount)Remove money from a society/job bank account.
BankingPublic.ResolveType()Returns the resolved banking system name (e.g. 'esx_society', 'qb_management', 'custom').
ActivityManager events
When Config.ActivityManager.enabled is true and the job is linked to a guild, these events fire:
jkbilling:activitymanager:invoiceCreatedFired when a society invoice is created for a guild-linked job.
-- Payload:
{
invoiceId = 123,
source = playerSource,
targetId = targetSource,
targetIdentifier = 'license:...',
targetName = 'John Doe',
issuerName = 'Officer Smith',
issuerJob = 'police',
amount = 5000,
reason = 'Speeding Fine',
paid = false,
status = 'unpaid'
}jkbilling:activitymanager:invoicePaidFired when a society invoice is paid for a guild-linked job.
-- Payload:
{
invoiceId = 123,
source = issuerSource, -- may be 0 if issuer is offline
targetId = payerSource,
targetName = 'John Doe',
issuerName = 'Officer Smith',
issuerJob = 'police',
amount = 5000,
reason = 'Speeding Fine',
paid = true,
status = 'paid'
}activitymanager:billing:createInvoiceJK Billing listens for this event, allowing ActivityManager to create invoices in the JK Billing system.
