OrigenNetwork
Docs

Exports · origen_banking

All exports are registered under the resource name origen_banking and are server-side only.


Response envelope

Most account exports return a structured envelope instead of a raw boolean:

lua
-- success
{ success = true, data = { ... }, meta = { message = { key = '...', args = { ... } } } }
 
-- failure
{ success = false, error = { key = 'errors.insufficient_balance', args = { ... } } }

The key field is a locale key from locales/*.json, so the calling resource can translate the message itself.

The job account exports in the compatibility layer use a simpler envelope: { success = true, data = { balance = number } } or { success = false, error = 'insufficient_balance' } where error is a plain string.


Job & society accounts

getJobAccountBalance(jobName)number, string|nil

Returns the current balance of a job account. Read-only — it never creates the account.

lua
local balance, err = exports['origen_banking']:getJobAccountBalance('mechanic')
ParameterTypeDescription
jobNamestringExact owner name stored in the database, e.g. 'ambulance'

Returns 0 and an error reason ('invalid_job_name' or 'account_not_found') when the account does not exist.


depositJobAccount(jobName, amount, detail)table

Adds money to a job account. Creates the account automatically when it does not exist yet.

lua
local res = exports['origen_banking']:depositJobAccount('mechanic', 2500, 'Repair job')
if res.success then print(res.data.balance) end
ParameterTypeDescription
jobNamestringJob / society name
amountnumberPositive integer
detailstringOptional audit label shown in the transaction history

Errors: invalid_amount, invalid_job_name.


withdrawJobAccount(jobName, amount, detail)table

Removes money from a job account. Never auto-creates the account.

lua
local res = exports['origen_banking']:withdrawJobAccount('mechanic', 500, 'Parts purchase')

Errors: invalid_amount, account_not_found, insufficient_balance.


getAccountMoney(accountName)number

Legacy alias of getJobAccountBalance. Returns only the balance, or 0.

addAccountMoney(accountName, amount)boolean

Legacy deposit. Auto-creates the account. Registers the transaction as Society income.

removeAccountMoney(accountName, amount)boolean

Legacy withdrawal. Returns false when the account does not exist or the balance is insufficient.


Accounts

newAccount(data)Account

Creates an account object. When data.id is omitted a new IBAN is generated and the account is persisted immediately.

FieldTypeDescription
ownerstringCitizen ID, job name or gang name
namestringDisplay name
balancenumberInitial balance. Default 0
defaultbooleanMarks it as the player's primary account
sharedbooleanMarks it as a shared job / gang account
bankstringOptional bank ID the account belongs to

GetAccountById(id)Account | nil

Returns the account from the in-memory cache, falling back to a database lookup.

lua
local account = exports['origen_banking']:GetAccountById('1234567890123456')

GetAccountAccessByCitizenid(citizenid)table

Returns the raw access list for a citizen: an array of { accountId, permission }. Permission is 'owner', 'manager' or 'operator'.


GetAccountsInfoByCitizenId(citizenid)table

Returns the full account list for a citizen, enriched for UI use: members, account type ('personal' / 'shared'), the framework primary flag and live balance. Job and gang accounts the player currently has access to are injected at runtime.

This export resolves job and gang access on every call and can create the shared account if it does not exist yet. Do not call it in a loop.


CreateInitialAccount(citizenid)string

Creates the primary account for a citizen and returns the generated account ID.


LoadAccountsForPlayer(citizenid)

Preloads every account owned by, or shared with, a citizen into memory. Accounts are lazy-loaded on player connect, so this is only needed for offline operations.


Payments

"Active account" is the account currently selected in the player's activeAccount metadata. "Default account" is the one flagged as default in the database.

GetActiveAccBalance(source)number | nil

Returns the balance of the player's active account. Cached for 500 ms.


PayWithAccId(accountId, amount, detail)table

Charges a specific account by ID.

ParameterTypeDescription
accountIdstringTarget account IBAN
amountnumberAmount to charge
detailstringReason shown in the transaction history

Errors: errors.account_not_found, errors.insufficient_balance.


PayWithActiveAcc(source, amount, detail)table

Charges the player's currently active account.

lua
local res = exports['origen_banking']:PayWithActiveAcc(source, 150, 'Parking fee')
if not res.success then print(res.error.key) end

PayFromDefaultAcc(source, amount, detail)table

Charges the player's default account. When that account is the framework primary, the balance is debited from framework bank money instead of the database.


ReceiveToActiveAcc(source, amount, detail)table

Credits the player's active account.


ReceiveToDefaultAcc(source, amount, detail)table

Credits the player's default account. Framework primary accounts are credited directly to framework bank money.


SetActiveAccBalance(source, amount)boolean

Overwrites the balance of the player's active account. No transaction is registered.


SetDefaultAccBalance(source, amount)boolean

Overwrites the balance of the player's default account. When it is the framework primary, the difference is applied to framework bank money.

Both setters bypass transaction history and permission checks. Use them only for admin or migration tooling.


Loans

CreateLoan(accountId, typeKey, amount, term, collateral)table

Creates a loan against an account, applying every server-side validation.

ParameterTypeDescription
accountIdstringAccount that receives the disbursement
typeKeystringLoan type key from Config.Loans.Types, e.g. 'personal'
amountnumberPrincipal
termnumberNumber of installments, must be in allowedTerms
collateralstringAsset reference. Required when the type sets requiresCollateral
lua
local res = exports['origen_banking']:CreateLoan(accountId, 'personal', 15000, 12)
if res.success then print(res.loanId) end

Errors: disabled, account_not_found, invalid_type, invalid_term.


GetPlayerLoans(citizenId)table

Returns every loan belonging to a citizen, shaped as the UI receives them.


HasOverdueLoan(citizenId)boolean

Returns true when the citizen has an overdue or defaulted loan. Useful to gate credit-based purchases in dealerships, rentals and similar resources.

lua
if exports['origen_banking']:HasOverdueLoan(citizenid) then
    -- deny the financed purchase
end

Banks

newBank(data)Bank

Creates a bank entity.

GetBankById(id)Bank | nil

Returns a bank from cache or database.


Cards

newCard(data)Card

Creates a card bound to an account.

GetCardById(id)Card | nil

Returns a card from cache or database.