pos-printer
is a Go application designed to fetch order details from an API and print a formatted receipt on a thermal printer. It uses environment variables for configuration and supports token-based authentication.
- Go 1.16 or later
- A
.env
file with the necessary environment variables
Create a .env
file in the root directory of the project with the following variables:
API_USERNAME=your_api_username
API_KEY=your_api_key
TOKEN_URL=https://example.com/get-token
ORDER_URL=https://example.com/orders/%s
HEADER_KEY=your_header_key
HEADER_VALUE=your_header_value
STORE_NAME=Your Store Name
STORE_LINK=https://yourstore.com
STORE_ADDRESS=Your Store Address
Run the following command to install the required dependencies:
go mod tidy
- Build the application:
go build -o pos-printer
- Run the application:
./pos-printer
- Enter the order ID when prompted to fetch and print the receipt.
- Footer Template: Customize the footer of the receipt by editing the
footer_template.txt
file. - Receipt Formatting: Modify the
printReceipt
function inmain.go
to change the receipt format.
This project is licensed under the MIT License.