g-billing Integration

Hook Sky Banking into g-billing so players can view and pay invoices directly from the bank UI on QBCore servers.

Requirements

  • QBCore with g-billing already installed and working.
  • Banking config using Config.BillingSystem = 'g_billing' and Config.BillingMode = 'menu' so invoices open in the billing UI.

Setup

Enable g-billing in Banking

Update your banking config:

config.lua
Config.BillingSystem = 'g_billing'
Config.BillingMode = 'menu'

This keeps the Bank UI clean and hands players over to g-billing when they open the invoices tab.

Wire Callbacks Inside g-billing

Append the following snippet to server/main.lua inside the g-billing resource. It exposes the bills list to Banking and lets players settle invoices without leaving the bank.

g-billing/server/main.lua
QBCore.Functions.CreateCallback('g-billing:server:getBillsForBanking', function(source, cb)
    local bills = getBillsToPay(source)
    cb(bills)
end)

RegisterNetEvent('g-billing:server:payBillFromBanking')
AddEventHandler('g-billing:server:payBillFromBanking', function(billId)
    local src = source
    local player = QBCore.Functions.GetPlayer(src)
    local playerCitizenId = player.PlayerData.citizenid

    local billResult = MySQL.query.await('SELECT * FROM bills WHERE id = ? AND recipient_citizenid = ? AND status = ?', {
        billId,
        playerCitizenId,
        'Unpaid'
    })

    if not billResult or not billResult[1] then
        TriggerClientEvent('QBCore:Notify', src, Lang:t('error.retrieving_bills'), 'error')
        return
    end

    local bill = billResult[1]

    if player.Functions.GetMoney('bank') >= bill.amount then
        player.Functions.RemoveMoney('bank', bill.amount, Lang:t('other.bill_pay_desc'))
        exports['qb-management']:AddMoney(bill.sender_account, bill.amount)
        
        local sender = QBCore.Functions.GetPlayerByCitizenId(bill.sender_citizenid)
        local datetime = os.date('%Y-%m-%d %H:%M:%S')
        
        if sender then
            TriggerEvent('g-billing:server:notifyBillStatusChange', sender.PlayerData.source, Lang:t('info.bill_paid_sender', { billId = bill.id, amount = comma_value(bill.amount), recipient = bill.recipient_name }), 'success', Lang:t('other.sent_bill_paid_text_subject'), Lang:t('info.bill_paid_sender_text', { billId = bill.id, amount = comma_value(bill.amount), recipient = bill.recipient_name }))
        end
        
        TriggerEvent('g-billing:server:notifyBillStatusChange', src, Lang:t('success.bill_paid_recipient', { billId = bill.id, amount = comma_value(bill.amount), senderName = bill.sender_name, account = bill.sender_account }), 'success', Lang:t('other.received_bill_paid_text_subject'), Lang:t('success.bill_paid_recipient_text', { billId = bill.id, amount = comma_value(bill.amount), senderName = bill.sender_name, account = bill.sender_account }))
        
        MySQL.update('UPDATE bills SET status = ?, status_date = ? WHERE id = ? AND recipient_citizenid = ? AND status = ?', {
            'Paid',
            datetime,
            bill.id,
            bill.recipient_citizenid,
            'Unpaid'
        })
    else
        TriggerClientEvent('QBCore:Notify', src, Lang:t('error.not_enough_money'), 'error')
    end
end)

Support

Need help? Our support team is always ready to assist

Join Discord