Exports & events ​
These are server exports. Names are case-sensitive. Use trusted server code and validate player authorization in the calling resource; an export is not a public network endpoint.
| Export | Purpose |
|---|---|
getBusiness(faction), getBusinesses(filter?) |
Business data; filter supports faction |
getVenue(id), getVenues(filter?) |
Venue data; filter supports faction |
getState(id) |
State and optional expiry |
setLockdown(id, on, reason) |
Change venue lockdown |
getMenu(id, opts?) |
Enabled business menu; opts.npc = true filters NPC-eligible items |
checkout(src, id, lines, opts?) |
Payment request and ledger flow |
createOrder(id, lines, meta?) |
Create a ticket; does not itself charge the customer |
createExternalOrder(sourceId, venueId, lines, paymentRef, opts?) |
Guarded casino-bar or entertainment bottle-service ticket creation |
getSale(id) |
Cached or persisted sale |
refundSale(id, lines, byCid, reason) |
Refund selected quantities using their allocated charged merchandise and tax, retaining tips and delivery fees |
getStock(id, item?) |
One item or aggregate stock view |
adjustStock(id, item, delta, reason, ref?, src?) |
Inventory movement and stock ledger |
bumpLine(ticketId, line, meta?) |
Complete a line; readiness follows all lines |
getLoyalty(cid, program), addPoints(cid, program, n, reason) |
Loyalty lookup and adjustment |
getReport(venueId, range) |
Venue report; public export uses venue scope |
registerPremises(faction, premises), releasePremises(faction, premises) |
Housing business premises |
local venues = exports.np_commerce:getVenues({ faction = 'my_business' })
local state, untilAt = exports.np_commerce:getState('my_counter')
local menu = exports.np_commerce:getMenu('my_counter', { npc = true })
checkout cart lines use { itemId, qty, mods? } from the web contract. Inspect the installed server implementation before constructing scripted payment options: server-origin calls can intentionally bypass staff interaction checks. refundSale line entries accept { lineId, qty }; failed calls return a false/nil result and an error code.
External ticket sources ​
createExternalOrder is registered by server/modules/zz_integrations.lua. It accepts np_casino:bar only from the invoking np_casino resource, and np_entertainment:bottle_service only from np_entertainment. Other callers return source_not_allowed. This server-only seam does not charge a customer or verify an external payment: the allowed caller supplies its payment reference after completing its own checkout.
Lines use { item = menuItemId, qty = integer } with 1–30 lines and quantities of 1–50, and are normalized against the commerce menu; input prices are ignored. A payment reference is required, at least one line must have a station route, and opts.station may be bar, kitchen, expo or pickup. The general createOrder export is a trusted internal ticket primitive; use this guarded seam for the supported external origins.
Addon extension points ​
np_commerce also hosts np_addon API 1.
| Export | Definition |
|---|---|
registerServiceEffect(id, def) |
def.run(ticket, line, ctx) performs a service |
registerSupplier(id, def) |
def.quote and def.order callbacks |
registerOrderSource(id, def) |
Register an order source definition |
registerLoyaltyPerk(id, def) |
Register a loyalty perk definition |
addHook(name, fn) |
beforeSale, afterSale, beforeRefund, beforeOrder, priceModifier, beforeStateChange |
Hook arguments differ by hook; read the matching call site before using them. For example beforeOrder receives (venueId, lines, meta) and a false result vetoes creation. Registration alone does not imply every definition is consumed by each workflow.
Events and state ​
Server events emitted by the implementation include np_commerce:sale, np_commerce:refund, np_commerce:tip, np_commerce:stateChanged, np_commerce:stockLow, np_commerce:flag and np_commerce:ticket:created|claimed|bumped|ready|handed|recalled. Ticket events carry the ticket; state changes carry (venueId, state, oldState).
The client transport uses np_commerce:client:push for staff NUI messages and scoped RPC responses. Treat these as internal transport. UI payloads and callbacks are defined in web/src/contract.ts; phone contracts are in the same file. Do not use client messages as proof of payment or stock state.
Venue state is published under GlobalState['npCommerce:' .. venueId]. Read the server export when your resource needs the current authority.