Browse docs
Billing Exports
Billing Exports for the Free Phone custom-app, billing and CrewLink integrations.
This page documents the supported public integration calls. Client exports must run in a client script and server exports must run in a server script. Internal NUI callbacks and net events are not public APIs.
Keep the resource folder named
sky_phone. Validate every returned success value and keep money,
permissions, ownership, and other authoritative changes on the server.Billing Exports
Billing exports are server-only and validate invoice state and monetary mutations inside Free Phone.
CreateInvoice(data)
- Purpose: Creates a validated invoice for an online player or known character identifier.
- Arguments:
data(table): Invoice definition.recipientSource(number?): Online recipient server ID.recipientIdentifier(string?): Known character identifier when no source is supplied.issuerSource(number?): Online issuer server ID.issuerIdentifier(string?): Known issuer identifier.issuerAccount(string): Account receiving paid funds.issuerLabel(string): Display name shown to the recipient.title(string): Invoice title.description(string?): Invoice details.amount(number): Server-validated invoice amount.dueDays(number?): Optional payment period.
- Returns:
string | nil, string?— invoice ID orniland an error code.
server.lua
local invoice_id, error_code = exports["sky_phone"]:CreateInvoice({
recipientSource = target_source,
issuerSource = source,
issuerAccount = "ambulance",
issuerLabel = "Los Santos Medical",
title = "Medical treatment",
description = "Emergency treatment and medication.",
amount = 1300,
dueDays = 7,
})
if not invoice_id then
print(("[medical] Invoice failed: %s"):format(error_code))
return
end
print(("[medical] Created invoice %s"):format(invoice_id))
Never accept an invoice amount from an untrusted client without validating the service and price on the server.
CancelInvoice(invoiceId, actorIdentifier)
- Purpose: Cancels an open invoice.
- Arguments:
invoiceId(string): Invoice ID returned byCreateInvoice.actorIdentifier(string): Character or integration actor responsible for cancellation.
- Returns:
boolean.
server.lua
local cancelled = exports["sky_phone"]:CancelInvoice(
invoice_id,
issuer_identifier
)
if not cancelled then
print("Invoice could not be cancelled")
end
GetBillingAccountBalance(accountKey)
- Purpose: Reads the current internal balance for a billing account.
- Arguments:
accountKey(string): Account key such asambulance.
- Returns:
number | nil.
server.lua
local balance = exports["sky_phone"]:GetBillingAccountBalance("ambulance") or 0
print(("Medical billing balance: $%s"):format(balance))
RemoveBillingAccountBalance(accountKey, amount)
- Purpose: Atomically withdraws an amount when sufficient balance is available.
- Arguments:
accountKey(string): Billing account key.amount(number): Positive server-calculated withdrawal amount.
- Returns:
boolean.
server.lua
local removed = exports["sky_phone"]:RemoveBillingAccountBalance(
"ambulance",
5000
)
if not removed then
print("Insufficient billing balance or invalid request")
end