Skip to content

Checkout ​

Storefront with cart

At the counter ​

Walk up to a shop. Within Config.Catalog.peekDistance (8 m) a peek card shows the brand, whether the shop is open, staff on duty and a few highlights. At the counter, E opens the storefront. With np_menu running, clerks also get a "Shop" context option.

The storefront has:

  • a header with the brand plate, tagline, street, opening hours, your loyalty points, and your cash and bank;
  • tabs, an Offers tab, search (/ focuses it), sorting, and a list or grid view (saved per player);
  • the item list with weight, stock, price and an add button;
  • the cart on the left with a carry-capacity bar, the totals, the payment tiles and Pay.

Item states: in stock, low stock, sold out (with the next delivery time and a bell for "notify me"), and locked with the reason: license, age, job, business license, purchase limit or waiting period. Locked items stay visible.

What the server checks ​

The client only sends a shop id, item names, counts, a payment method and the counter index. Everything else is computed on the server: prices, stock, discounts, licenses, ages, weights and the player's position.

Every purchase runs in this order:

  1. Quote: each line is priced and checked (stock, locks, limits, carry weight). The quote carries a hash.
  2. Pay with that hash. If a price changed in between, the purchase stops with price_changed and the cart refreshes.
  3. beforeBuy hooks of other resources may veto it (Exports & hooks). This runs before the payment: nothing is charged or handed over yet.
  4. Lines that will go to the counter need a pickup stash the inventory accepted, before anything is charged (else no_space). Then stock is taken and the money is charged.
  5. Each line is handed over: into the pockets, else into the pickup stash, else that line is refunded.
  6. Receipt, purchase trail, loyalty points, shop revenue, then afterBuy (with the lines that were actually handed over) and the np_shops:server:purchased event.

No double charges. The NUI gives every payment attempt a request id (one per cart, method and quote) and reuses it when it retries after a timeout, a network error or busy. The same id within Config.Checkout.requestTtl (600 s) answers the first receipt again; this is checked before anything else, so a retry works even after the player stepped away. A retry while the first request still runs answers busy. The client waits paymentTimeout + 15 s for checkout.pay (the np_payments sheet may stay open that long), the fuel payment 180 s, every other call 10 s.

Pricing ​

The unit price of a line goes through these steps, in this order:

Step Source
priceModifier hook Another resource may replace the unit price (hooks)
Offer The line's offer = { price, untilAt }, or an owner offer. Shown with a strike-through price and the end date
Bulk The line's bulk tiers, e.g. "from 5 −10 %"
Happy hour shop.happyHour, or Config.Checkout.happyHour for its shop types (food, 17–19 h, 10 %)
Job discount Config.Checkout.jobDiscounts per Config.Jobs group while on duty (police and medic 10 %), plus the shop's own discounts
Loyalty The player's tier at this brand

VAT: Config.Checkout.taxPercent adds tax on the receipt (default 0). It goes to the society in taxAccount.

Payment ​

Receipt

The shop decides which methods it takes (payment = { cash, card, company, black }).

With np_payments running, the method tiles come from np_payments: cash, checking, savings, shared, business and faction accounts and bank cards, each with its bank logo. Pay opens the np_payments sheet with the chosen method preselected. Details:

  • The merchant is np_shops:<shopId> with the shop's label and icon. The category follows the shop type (Config.Checkout.paymentCategory: shop, food, fuel, service).
  • The money goes to the owner's business account for owned shops, to the shop's society when it has one, or nowhere for an NPC shop.
  • Tip is offered while staff is on duty (allowTip). Split and pay later are off by default (allowSplit, allowLater). With pay later, the goods are handed over and the receipt says "later".
  • Pay-later and financed purchases credit the shop when np_payments reports the invoice paid (np_payments:invoicePaid), not at the counter.
  • The merchant tint on the sheet is a Nimbus tint name: the brand color is mapped to the nearest one.
  • Vangelico offers financing plans as extra methods. See Shop types → Luxury.

Without np_payments, cash and bank come from the framework (standalone: the cash item). The chosen method is charged directly, with no sheet.

Extra methods from np_shops itself:

Method Who Paid from
company Employees from job grade Config.Checkout.companyGrades (2) The job's society account. The tile shows the company's brand (Config.Checkout.jobBrands)
business:<shopId> Owners and managers of a shop That shop's business account
black Shops with payment.black = true or currency = 'black_money' Black money

Fuel bills at the counter ​

Fuel bill in the cart

With np_fuel and its pay inside setting, drivers at a fuel station fill up first and pay at the counter of the station's shop (a shop linked with the station).

  • Your open bills of that station show at the top of the cart under Fuel to pay: pump, litres, fuel, plate and amount, each with a green Pay button. Only your own bills, and only at the shop of that station.
  • Pay opens np_fuel's checkout for the bill (the np_payments sheet with the station as merchant, or the framework account). It is paid on its own, not with the cart. np_shops moves no money for it: np_fuel books the station and hands over the fuel_receipt.
  • A toast confirms it ("Fuel paid: $47") and the list refreshes. A bill that was already paid or dropped answers "That fuel bill is already paid or gone."
  • You have to stand at the counter (too_far otherwise).

np_fuel keeps one open bill per player. Leaving the station or not paying in time is a drive-off on np_fuel's side (the owner gets an alert and the plate); np_shops sees the bill disappear.

Refunds ​

A refund (a line that couldn't be handed over, a canceled food order) goes back the way the money came:

Paid with Refund
np_payments (any account or card) np_payments Refund of that payment
company, business:<shopId> Back to the company or business account (the payment is remembered Config.Checkout.refKeepHours, 24 h)
Pay later The invoice is voided
Financing The share of the instalments is voided, newest instalment first. An instalment that is paid anyway is refunded from its payment
Framework cash, bank, black money (without np_payments) Paid back from the stored receipt

Only a charge from the player's own money (cash, bank, black money, a card or a personal or savings account) may fall back to a payout to the player when its refund fails. Company, business, shared and faction accounts, pay later and financing never do: a failed refund is logged as refund_failed for staff.

Receipts ​

Every purchase writes a receipt: lines, discounts, tax, total, method (with its bank logo and card number), points, and where the goods went (pockets, pickup or order). Food receipts carry the order ticket, weapon receipts the serial numbers, financed receipts the plan.

Receipts are kept per character (receiptsKept, 100) and shown in the shop and in the phone app. Without np_payments, np_shops also writes a Wallet entry in np_phone (Config.Checkout.walletEntry).

Loyalty ​

Each brand runs its own loyalty card. Players earn pointsPerDollar (0.1) points for every dollar paid. The tier follows the dollars spent at that brand and gives its percent off every line:

Tier Spent at the brand Discount
Bronze $0 0 %
Silver $500 2 %
Gold $2,000 5 %

Points and tier show in the shop header and on the receipt. Turn it off with Config.Checkout.loyalty.enabled = false.

Pickup ​

A line that doesn't fit into the pockets is not refused. It goes to a pickup stash for that shop and character (np_shops_pickup:<16 hex>, a hash of shop and identifier, because np_inventory takes stash ids of at most 64 characters; np_shops_pickups maps it back, and older long ids are moved at start). The stash must be accepted by the inventory before the purchase is charged. The player gets a toast. The storefront then shows a Pickup button that closes the shop and opens the stash. Settings: Config.Checkout.pickup (30 slots, 200 kg, kept 7 days).

Inventories without stashes (the ESX inventory, qb pockets) can't hold a pickup. There, overweight lines are refused with no_space.

Staffed checkout ​

When employees of an owned shop are on duty, purchases count as staffed sales: tips are offered and the staff commission is booked (never for staff buying in their own shop). Staff can also ring up a cart for a customer standing nearby (checkout.ring):

  1. The customer gets a toast ("… rang up 3 item line(s) for you") and an Open the checkout key prompt for Config.Checkout.ring.answerSeconds (20 s).
  2. Pressing the interact key accepts (checkout.ringAnswer). The clerk must still be on duty and within 5 m. The customer's shop screen opens with that cart, the clerk gets a toast, and the receipt names the cashier. Nothing opens or takes focus without the customer's answer.
  3. A customer has one open request at a time (another clerk gets busy), and a clerk can send one request every ring.cooldownMs (10 s).

With nobody on duty, the NPC checkout fills in at a reduced margin.

Purchase limits ​

A line with limit = { count, hours } counts the purchases of each character. The item locks with "limit" once the limit is reached, and a cart that would pass it fails with limit_reached. Weapons have their own limits; see Shop types → Weapons.