Server side

PayInvoice

---An export to pay invoice manually.
---@param source number
---@param invoiceId number
---@return boolean, number
local success, amountPaid = exports["tgg-billing"]:PayInvoice(source, invoiceId)

CancelInvoice

---An export to cancel invoice manually.
---@param source number
---@param invoiceId number
---@return boolean
local success = exports["tgg-billing"]:CancelInvoice(source, invoiceId)

CreateInvoice

---An export to create an invoice manually.
---@param invoiceData table
---@return table The created invoice
local invoice = exports["tgg-billing"]:CreateInvoice(invoiceData)

Invoice Data Structure:

local invoiceData = {
    -- Required fields
    total = 100,                        -- Total amount (before tax)
    taxPercentage = 10,                 -- Tax percentage (from company config)
    sender = 'police',                  -- Company identifier (must match config) or '__personal'
    senderId = "Your sender Id",       -- Usually this is the player's identifier
    senderName = "Your sender name",   -- Usually this is the player's name
    recipientId = "The recipient Id",  -- The recipient's identifier
    recipientName = "The recipient name", -- Optional: The recipient's name
    recipientType = 'player',           -- 'player' or 'company' (defaults to 'player')
    
    -- Invoice items
    items = {
        {
            key = "speeding",           -- Item key
            label = "Speeding",         -- Display label
            price = 100,                -- Item price
            quantity = 1,               -- Quantity
            priceChange = false,        -- Whether price can be changed (from config)
            quantityChange = false      -- Whether quantity can be changed (from config)
        }
    },
    
    -- Optional fields
    notes = "Your notes here",          -- Optional notes
    senderCompanyName = "Your society name", -- If sender is '__personal' might be nil
    skipAcceptance = false              -- Optional. If true, bypasses acceptance and sets status to 'unpaid' immediately
}
Example: Skip acceptance (invoice goes directly to 'unpaid' status)
-- Useful for automated systems like speed cameras
local invoiceDataAutoPay = {
    total = 100,
    taxPercentage = 10,
    sender = 'police',
    senderName = 'Speed Camera System',
    recipientId = 'BP711N34',
    recipientName = 'Player Name',
    recipientType = 'player',
    items = {
        {
            key = 'speeding',
            label = 'Speeding',
            price = 100,
            quantity = 1,
            priceChange = false,
            quantityChange = false
        }
    },
    notes = 'Speed camera violation detected at Route 68.',
    skipAcceptance = true -- Bypasses acceptance requirement
}

local invoice3 = exports['tgg-billing']:CreateInvoice(invoiceDataAutoPay)

Last updated