Integration
Bank
Bank adapters for IBANs and job accounts, and how to add one for your own bank resource.
Player money always goes through the framework (the bank account of QBCore, Qbox or ESX). A bank adapter adds two things: where a character's IBAN comes from, and job accounts for company invoices.
luaConfig.Bank = {
Adapter = 'auto', -- 'auto' | 'tgiann-bank' | 'qb-management' | 'renewed-banking' | 'esx_society' | 'framework'
}
auto uses the first one running, in the order of the table below. A named adapter that is not running falls back to auto with a warning. The console names the result:
cfg[fx-phone:bank] bank adapter: tgiann-bank
| Adapter | Needs | IBAN | Job accounts |
|---|---|---|---|
tgiann-bank |
tgiann-bank | The character's main account in tgiann-bank, else the phone's own | The job accounts configured in tgiann-bank |
qb-management |
qb-management | The phone's own | GetAccount, AddMoney, RemoveMoney |
renewed-banking |
Renewed-Banking | The phone's own | getAccountMoney, addAccountMoney, removeAccountMoney |
esx_society |
esx_society and esx_addonaccount | The phone's own | Shared account society_<job> |
framework |
Nothing | The phone's own (ServerConfig.IbanGenerate) |
None |
#What job accounts are used for
Company invoices (Config.Invoices.Jobs) pay the cutSender share to the job account. If the adapter has no account for that job, the payment is refused, the payer is refunded and the app shows no_account. With the framework adapter, set cutSender = 0 for every job or company invoices cannot be paid.
Bosses can also see their job account in the Bank app and move money between it and their own (Config.Bank.Accounts.JobAccount).
Settings: Bank and invoices.
#tgiann-bank
- New phones take the IBAN of the character's tgiann-bank main account. Transfers in the phone accept that IBAN.
- With tgiann-bank running, its own extra and shared accounts are shown in the Bank app, read only.
- tgiann-bank's job money calls do not report failures, so FX Phone reads the job balance before and after each move and only counts it when the balance really changed. Moves on one account run one after the other.
- The tgiann-bank side of the integration (transfer friends from FX Phone contacts) is described on Adapters.
#Your own bank
Files in server/integrations/bank/ are loaded automatically. Add one, for example my-bank.lua:
luaIntegration = Integration or {}
Integration.BankAdapters = Integration.BankAdapters or {}
local adapter = { Name = 'my-bank' }
function adapter.Available()
return GetResourceState('my-bank') == 'started'
end
-- The character's IBAN, or nil to use the phone's own.
function adapter.GetIban(identifier)
return exports['my-bank']:GetIban(identifier)
or Integration.BankAdapters.framework.GetIban(identifier)
end
-- The identifier owning an IBAN, or nil.
function adapter.FindByIban(iban)
return exports['my-bank']:GetOwner(iban)
or Integration.BankAdapters.framework.FindByIban(iban)
end
-- A job account's balance, or nil when the job has none.
function adapter.GetJobBalance(job)
return exports['my-bank']:GetSocietyBalance(job)
end
-- true only when the money really moved.
function adapter.AddJobMoney(job, amount)
return exports['my-bank']:AddSocietyMoney(job, amount) == true
end
function adapter.RemoveJobMoney(job, amount)
return exports['my-bank']:RemoveSocietyMoney(job, amount) == true
end
Integration.BankAdapters['my-bank'] = adapter
Then set Config.Bank.Adapter = 'my-bank'. auto only tries the built-in names.
#Exports
Scripts read balances, add transactions and send invoices through the server exports: Bank exports and Invoice exports.