⚙️Configuration

Comprehensive instructions on configuring files and utilizing export functions.

Billing Exports

This module provides a set of exports to interact with the billing system.

You can use these exports from other resources with:

exports["crm-billing"]:functionName(args)

🔸Get Invoice By ID

Retrieve a single invoice by its ID.

local crm_invoice = exports["crm-billing"]:crm_get_invoice(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (table | nil) – Invoice object if found, otherwise nil.

Example

local crm_invoice = exports["crm-billing"]:crm_get_invoice(12)
if crm_invoice then
    print(("Invoice #%s amount: %s"):format(crm_invoice.crm_id, crm_invoice.crm_amount))
end

🔸Get Player Invoices

Retrieve all invoices for a player.

local crm_invoices = exports["crm-billing"]:crm_player_invoices(crm_identifier)

Parameters

  • crm_identifier (string) – Character identifier.

Returns

  • (table | nil) – Table of player invoices if found, otherwise nil.

Example

local crm_invoices = exports["crm-billing"]:crm_player_invoices("RO7G58L8")
if crm_invoices then
    for _, crm_invoice in pairs(crm_invoices) do
        print(("Invoice #%s - %s$"):format(crm_invoice.crm_id, crm_invoice.crm_reason))
    end
end

🔸Get Society Invoices

Retrieve all invoices for a society (job).

local crm_invoices = exports["crm-billing"]:crm_society_invoices(crm_job)

Parameters

  • crm_job (string) – Job name (e.g., "police", "mechanic").

Returns

  • (table | nil) – Table of society invoices if found, otherwise nil.

Example

local crm_invoices = exports["crm-billing"]:crm_society_invoices("police")
if crm_invoices then
    print(("Police department has %s invoices"):format(#crm_invoices))
end

🔸Create Invoice

Create a new invoice.

exports["crm-billing"]:crm_create_invoice(crm_sender, crm_receiver, crm_data, crm_cb)

Parameters

  • crm_sender (number) – Sender character ID (must be online).

  • crm_receiver (number) – Receiver character ID (must be online).

  • crm_data (table) – Invoice data. Example:

    {
        crm_reason = "Reckless driving",
        crm_amount = 600,
        crm_type = "crm-society" -- or "crm-personal"
    }
  • crm_cb (function | optional) – Callback function returning the created invoice.

Example

exports["crm-billing"]:crm_create_invoice(
    1,  -- sender
    2,  -- receiver
    {crm_reason = "Repair service", crm_amount = 150, crm_type = "crm-personal"},
    function(crm_invoice)
        print("Invoice created with ID:", crm_invoice.crm_id)
    end
)

🔸Pay Invoice

Pay an invoice if possible.

local crm_success = exports["crm-billing"]:crm_pay_invoice(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (boolean)true if paid successfully, false otherwise.

Example

local crm_ok = exports["crm-billing"]:crm_pay_invoice(10)
if crm_ok then
    print("Invoice paid successfully!")
else
    print("Failed to pay invoice.")
end

🔸Cancel Invoice

Cancel an invoice.

local crm_success = exports["crm-billing"]:crm_cancel_invoice(crm_id)

Parameters

  • crm_id (number) – Invoice ID.

Returns

  • (boolean)true if invoice was cancelled, false if not found.

Example

if exports["crm-billing"]:crm_cancel_invoice(5) then
    print("Invoice cancelled.")
else
    print("Invoice not found.")
end

Last updated