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))
endboolean success, number|string idOrErrorGetUnpaidInvoices(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
))
endtable[] — Array of invoice objects with fields: id, amount, reason, issuer_name, issuer_job, target_name, status, created_atPayInvoiceByIdForSource(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))
endboolean success, table|string invoiceOrErrorCanManageCatalog(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)
endboolean canManage, string|nil jobNameFramework Public Functions
These functions are available in sv_framework_public.lua and can be called from any server-side script within the resource or via the global FrameworkPublic table:
FrameworkPublic.GetIdentifier(src)
Returns the unique identifier for the player (e.g. 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 is allowed to issue society invoices based on Config.Billing.jobs.
FrameworkPublic.FindSourceByIdentifier(identifier)
Finds an online player's source ID by their 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 are fired:
jkbilling:activitymanager:invoiceCreated
Fired 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:invoicePaid
Fired 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:createInvoice
JK Billing listens for this event, allowing ActivityManager to create invoices in the JK Billing system.
