Welcome to the Jose Madrid Salsa developer docs — explore features, APIs, and deployment guides.
Jose Madrid SalsaJMS Docs

Receipt Printer

The office PC prints a receipt for every new order, wholesale request, fundraiser final order, contact form, sign-up and live chat request.

Receipt Printer

The office PC has an 80mm USB thermal receipt printer. A PowerShell script on that PC asks the storefront for anything new every 30 seconds and prints it:

ReceiptPrinted forSource
Online SalePaid website orders, including the main BigCommerce store's order copiesOrder (salesChannel = WEBSITE)
Fundraising SalePaid orders from the fundraising store, with the group and salespersonOrder (salesChannel = FUNDRAISER), its fundraiser, participant and sellerName
Contact FormContact form messages (spam-flagged ones are skipped) and other website formsConversation (main contact form), ContactSubmission
New FundraiserFundraiser sign-up applicationsFundraiserSignupRequest
Wholesale SalePaid wholesale orders entered in the adminOrder (salesChannel = WHOLESALE)
Wholesale OrderRequests from the wholesale order form, priced if staff have priced them, otherwise TBDWholesaleOrderRequest
Fundraiser Final OrderA community fundraiser's signed final order from fundraising.josemadridsalsa.com/submit, with ship-to, flavors, payment method and amount dueEngagementRequest (source = site:fundraising-submit)
Live Chat RequestEvery time a visitor asks for a person in the website chat; prints only the date and timeChatThread

An order prints once it is paid, so a checkout that is paid later prints then. Cancelled, refunded and exchange orders never print, nor do POS, kiosk, phone or other in-person orders. A wholesale request that staff later enter as a wholesale order prints twice, once for each.

Order receipts start with the sale-type header and the business block (name, address, phone, email and both websites), then the customer's name, address, phone, email and the order time (Eastern), the products, the customer's notes, the sale type (with the group and salesperson for fundraiser orders) and the totals.

How it works

PartWhere
Layouts (48 characters a line)apps/storefront/lib/receipt-printer/format.ts
What to printapps/storefront/lib/receipt-printer/feed.ts
FeedGET /api/receipt-printer/feed?since=<ISO time> with Authorization: Bearer <RECEIPT_PRINTER_API_KEY>
Printer scriptapps/receipt-printer/ReceiptPrinter.ps1 (Windows PowerShell 5.1, nothing to install)

The feed returns each receipt as ready-made lines (text, alignment, bold, double size). The script turns them into ESC/POS commands and writes them straight to the USB printer, so the printer needs no Windows print queue or driver.

Every poll asks for the last 72 hours (never earlier than when the script was first started, so the first run does not print the backlog). The script appends each printed receipt's id to printed.log and skips ids already there, so a receipt prints exactly once even though it appears in many polls. If the PC or the internet is down, the next poll prints what was missed in that window. The feed sends at most 100 receipts of each kind at a time; when a kind is full it returns nextSince, and the script keeps asking from there until everything has printed.

Setup

  1. Generate a key with openssl rand -hex 32 and set it as RECEIPT_PRINTER_API_KEY in Vercel (Production), then redeploy.

  2. On the office PC, create C:\ProgramData\JoseMadridReceiptPrinter\config.json:

    {
      "feedUrl": "https://www.josemadridsalsa.com/api/receipt-printer/feed",
      "apiKey": "<the same key>",
      "pollSeconds": 30
    }
  3. Plug in and switch on the printer, then print a sample:

    powershell -ExecutionPolicy Bypass -File apps\receipt-printer\ReceiptPrinter.ps1 -TestPrint
  4. Start it automatically at sign-in (a scheduled task named Jose Madrid Receipt Printer):

    powershell -ExecutionPolicy Bypass -File apps\receipt-printer\ReceiptPrinter.ps1 -Install

    -Uninstall removes the task; -Once runs a single poll.

Errors (printer unplugged, no internet, a rejected key) are written to receipt-printer.log in the same folder; the script keeps polling and prints once the problem is fixed.

To reprint a receipt, delete its line from printed.log; it prints on the next poll if it is still inside the 72-hour window. To revoke the PC, change RECEIPT_PRINTER_API_KEY.

How is this guide?

Edit on GitHub

Last updated on

On this page