BlowfishCMS
A small content management system for OpenBSD
version 0.45.6 · ISC · 2026-12-03 · releases
402 lines · 26.4 KB · view it drawn · download this file
# Store
Sell items from your pages. Buyers collect them in a cart and pay on
[Stripe](https://stripe.com)'s own checkout page, so card numbers never reach
your server. You get an email for each order, and the buyer a confirmation.
What you sell can be printed on demand: [Printful](https://www.printful.com)
or [Gelato](https://www.gelato.com) makes each item when it's bought and sends
it straight to the buyer, with no stock for you to keep.
The Store adds:
- a **Products** screen, where you manage what you sell;
- an **Items for sale** block for any page;
- an **Orders** screen, for payments and what to send;
- a **Print on demand** screen, for connecting Printful and Gelato and
following what they make.
| | |
|---|---|
| Version | 1.7.3 |
| Needs | BlowfishCMS 0.45.0 or newer; a Stripe account; Postmark set up on the Mail screen for the emails; for print on demand, a Printful or Gelato account |
| Connects to | `api.stripe.com`; `api.printful.com`, `files.cdn.printful.com` (its mockups) and `order.gelatoapis.com` once they're connected |
| Runs as | its own service, `blowfish_xstore` (account `_bfxstore`) |
| Keeps | products in the catalogue; orders, Stripe's, Printful's and Gelato's keys in its own private folders; the cart in each buyer's own browser |
## Switching it on
In the admin, open **Site → Add-ons**, upload its archive
(`store-VERSION.tar.gz`) under **available** if the Store isn't listed yet,
then press **install** beside Store. The server installs it and
switches it on within a minute or two: it creates the Store's account, private
folders, service and web addresses. A **Store** tab then appears on
**Site → Add-ons**, with **Products**, **Orders** and **Print on demand**
under it.
Or, on the server:
```sh
doas blowfishctl addon install store
doas blowfishctl addon enable store
```
To switch it off, use its **on** switch on the Add-ons screen
(`doas blowfishctl addon disable store`). Products, orders and keys are kept,
and the shop blocks are hidden until it's switched on again.
## 1. Shop settings (Products screen)
| Setting | Meaning |
|---|---|
| Currency | Every price is in this currency. Choose it before adding products. |
| Button text | The words on the buy button when the cart is off, such as *Buy*. |
| Shipping cost per order | One flat amount per order, added when anything in it needs shipping. Use 0 for free shipping. |
| Shipping name | How it's labelled at checkout, such as *Standard post*. |
| Ships to | Two-letter country codes separated by spaces, such as `US CA GB`. Buyers can only enter addresses in these countries. |
| Free shipping over | Optional. Orders of this much or more (before shipping) ship free; Stripe shows *Free shipping*. |
| Cart | On (from the start): each item's button adds it to the cart (**Cart button** sets its words), and buyers pay for everything at once. Off: each item's button goes straight to payment for that item. |
| Email me each new order | On: each paid order is emailed to you, with what was bought, the buyer, the address and a link to Orders. |
| Email buyers a confirmation | On: the buyer gets a confirmation of their order from your site (Stripe's own receipt comes as well, in live mode). Their replies reach you. |
| A note for the confirmation | Optional text added to the buyer's confirmation, such as when orders are sent. |
**The cart** is kept in the buyer's own browser (no cookies, nothing on your
server until checkout). A **Cart** button shows in the corner of every page
while it has something in it; the buyer can change quantities (up to 10 of
each, and no more than are left) and remove items before **Check out**. A
buyer without JavaScript still buys one item at a time.
**The emails** go through your site's Postmark connection (**Settings →
Mail**), within a minute of Stripe confirming the payment. Yours go to the
*update alerts* address, or, if that's empty, to where contact messages go.
Each order is emailed once. Test-mode orders say so in your email.
## 2. Products
The **Items for sale** block lists products in the order of the Products
screen: drag one by its handle (⠿), or use **move up / down** in its **…**
menu (where **delete** is too). For each product:
| Field | Meaning |
|---|---|
| Name and price | Price as `12.50`. Stripe's minimum is 0.50 or about that in your currency. |
| Number available | The total you can sell, across all orders. Leave it empty for no limit. When it runs out, the item shows *Sold out*. |
| Description | Markdown, with the toolbar above it; its **?** lists what Markdown can do. |
| Main picture | JPEG, PNG or WebP; it's shown square on the shop's card, and first on the product's page. For a printed item, the printer's mockup. |
| Pictures (once it's saved) | All the pictures its page shows, in order, under **pictures of …** below the form: **add pictures** (several at once, or one from Pictures; for a colour, or every colour), **make main** (the card shows it), **hide** or **show**, and in each one's **…** menu **move up / down**, its colour (your own) and **delete** (your own; Printful's can be hidden, not deleted, as the next sync would bring them back). A product without a main picture shows its first picture on its card. |
| Made by | **Me**: you send it yourself. **Printful** or **Gelato**: that printer makes it and sends it; see *4. Print on demand*. |
| Printful item | Printful only, for a product you add yourself: the item's *sync variant ID* (one size and colour of one of your Printful products). The field offers your Printful items; picking one for a new product fills in its name, and its price when it's in the shop's currency. You rarely need this: what you publish in Printful appears here by itself, with all its sizes (see *4. Print on demand*). |
| Gelato product UID, Print file, Back print file | Gelato only: the product's UID from Gelato's catalogue (one product, size and colour), and the web address of your design (PNG, JPEG or PDF), such as one under **Files** (an address starting with `/` is made a full one). The back is optional. |
| Needs shipping | Asks for a delivery address at checkout and adds the shipping cost. Always on for what a printer makes. |
| For sale | Switch it off to hide an item without deleting it; the switch is in its row on the Products screen too. |
Deleting a product doesn't touch past orders: they keep its name and price.
## 3. Connect Stripe (Orders screen, *stripe* box)
Do this in **test mode** first. No real money moves, and Stripe gives you test
cards.
### The API key
1. In the Stripe Dashboard, switch on **Test mode**.
2. Go to **Developers → API keys → Create restricted key**.
3. Name it after your site. Set **Checkout Sessions** to **Write** and leave
everything else at *None*.
4. Copy the key (`rk_test_…`). Paste it on the Orders screen under **Stripe
secret key** and press **save**.
The key is checked with Stripe before it's saved, and never shown again. A
restricted key can only start checkouts: if it leaked, nobody could use it to
read your balance or move money. A full secret key (`sk_…`) also works, but
isn't recommended.
### The webhook
The webhook is how Stripe tells your site an order was paid. Without it,
orders stay *pending*.
1. In Stripe (same mode), go to **Developers → Webhooks → Add endpoint**
(Stripe may call it *Add destination*).
2. Endpoint URL: `https://your-domain/x/store/webhook` (the Orders screen
shows yours).
3. Events:
- `checkout.session.completed`: payment finished (required)
- `checkout.session.async_payment_succeeded`: a delayed payment, such as a
bank debit, cleared
- `checkout.session.async_payment_failed`: a delayed payment failed
- `checkout.session.expired`: the buyer left without paying (frees the
items they were holding)
4. Save, open the endpoint, reveal its **Signing secret** (`whsec_…`), paste it
under **Webhook signing secret** and save.
The **Last webhook** line on the Orders screen shows the latest delivery, and
the reason if it was refused.
## 4. Print on demand (Print on demand screen)
Printful and Gelato print an item when it's bought and send it to the buyer
under your shop's name. Once an order is paid, the Store sends each printer
its part of the order by itself: the items, how many, and the buyer's name,
address and email. The printer charges you for each order through your
account with them; buyers pay you your price and the shop's shipping cost.
You can use one printer, both, or neither, and mix their products with ones
you send yourself in the same cart. Connect a printer before you sell what it
makes: until then, those products can't be bought.
### Printful
1. In Printful, make a store of the kind **Manual order platform / API**
(Printful → Stores → Add store), and add your products to it with your
designs.
2. At [developers.printful.com](https://developers.printful.com) → **Your
tokens**, create a private token for that store only. Under **Scopes**,
tick these three and nothing else:
- **View and manage all orders**
- **View all store products**
- **View and manage webhooks**
Note the date it expires.
3. On **Print on demand**, paste it under **Printful private token** and
press **save**. Leave **Store ID** empty unless the token reaches your
whole account; then give the store's number (Printful → Stores).
The token is checked with Printful before it's saved, and never shown again.
Saving it also tells Printful where to send its updates (its webhook), at a
private address of your site, and brings your Printful products into the
shop.
**Your Printful products appear on Products by themselves**, within a minute
of connecting, and of publishing, changing or deleting one in Printful
afterwards:
- Each Printful product is **one product** in the shop, with its own page
where buyers choose its colour and size (see *5. The shop page*). A sticker
in three sizes, or a tee in three colours and five sizes, is one listing.
- Its **colours, sizes and prices are Printful's**: the variants you published
and the retail prices you set. Change them in Printful, and the shop
follows. A size Printful has run out of shows greyed out and can't be
bought until it's back.
- Its **pictures are Printful's mockups**: every variant's (every colour's
and every size's), so buyers see the one they choose. A picture Printful
keeps as several files (one per size, all looking the same) is shown once;
so is the main mockup when it's one of them. They follow Printful too. If
some couldn't be fetched, Products says so after the sync. **When
Printful's aren't right**, edit the product on Products: hide the wrong
ones, add your own (for a colour, or all), put them in order and choose
the main one. Printful's syncs keep all of that.
- Its **name, description and main picture are yours** after that: it
starts with Printful's name and mockup, and the blank product's
description from Printful's catalogue (materials and the like). Edit them on
Products, and later changes in Printful leave them alone. A main picture
you choose (or upload) replaces the mockup for good. If Printful gives it
no main mockup, its card shows its first picture.
- It's **for sale at once**. Switch it off on Products to hide it. One you
delete there isn't brought back by Printful; **bring them back** on
Products undoes that.
- One **deleted in Printful** goes off sale, and says why. So does one whose
prices in Printful are in another currency than the shop's (Printful →
Stores → your store's settings, or the shop's currency on Products), until
that's put right.
**Your Printful products** on Print on demand lists each with its options and
which product on Products sells it. **sync with Printful** hands them all to
Products again; use it after updating from Store 1.5.0, so Printful also
sends product updates.
Printful tokens expire: make a new one before the date and save it the same
way.
### Gelato
1. At Gelato → **Developer → API keys**, create a key.
2. On **Print on demand**, paste it under **Gelato API key** and press
**save**. It's checked with Gelato first, and never shown again.
3. The Gelato box then shows a **Webhook address**. At Gelato → **Developer →
Webhooks**, add it for the events **Order status updated** and **Order item
tracking code updated**. Only Gelato should know this address.
4. For each product, find its **product UID** in Gelato's product catalogue
(it names the product, size and colour), and put your design where it has
a web address: under **Files**, for example.
### Settings
| Setting | Meaning |
|---|---|
| Send paid orders straight into production | On (from the start): paid orders are made at once. Off: they arrive at the printer as drafts, made only once you confirm them there. **Test-mode payments always arrive as drafts**, which are neither made nor charged; delete them at the printer. |
| Email buyers when their order ships | On: once a printer sends an order, the buyer gets an email from your site with what was sent and its tracking. |
| Gelato's shipping | How Gelato sends orders: the cheapest it has, or normal, standard or express. Printful uses its standard shipping. |
### What happens to an order
The order's line on **Orders**, and **Sent to printers** on Print on demand,
show how each part stands: *draft*, *being made*, *on hold*, *shipped* (with
the tracking number, linked), *delivered*, *canceled*. Your email for each
new order says where each part went.
The printers' webhooks tell the shop when something changes. The Store never
believes the webhook itself: it only asks the printer about that order, so
the address alone can't change anything. **check** beside an order, or
**check them all**, asks the printers at once.
If a printer refuses an order (an address it can't deliver to, a product it
no longer makes), the order shows **not sent**, with the printer's reason.
You get an email about it as well. Fix the cause and press **send again**.
If an order is held, fails or is canceled at the printer after it was sent,
you're emailed, and it's sorted out in the printer's own dashboard.
An order whose every item was made by printers is marked *sent* once they've
all shipped it. Items you send yourself still need **mark sent**.
## 5. The shop page
Switching the Store on makes its own page, **Shop** at `/shop/`, with an
**Items for sale** block. It starts off, so you can add products first: turn
it on under **Address, menu & on/off** on the Store's **Page** tab, or in
**Pages**. Its layout and blocks are edited on that tab; what it sells is
managed on Products. While the Store is switched off, the page answers "not found".
A site that already showed products on a page keeps that page as the shop.
You can also add an **Items for sale** block to any other page. The block can
show:
- all products, or a single one;
- a grid of cards, or a list with the pictures beside the text.
Each card shows the product's picture, name, price (*from* the cheapest when
its options differ) and the start of its description, with a **View** button.
A product with nothing to choose can also go into the cart from its card.
**Each product has its own page** (`/x/store/item/…`), which **View**, its
picture and its name open:
- its **pictures**, laid out as in a big online shop: the thumbnails in a
column beside a large picture (in a row under it on phones), each shown on
pointing at it or clicking; arrows, or the keyboard's arrow keys, step
through them, "3 / 8" says where you are, and clicking the large picture
shows it full size. The pictures stay in view while the details beside
them scroll;
- its **colours** as swatches: choosing one shows that colour's pictures,
and choosing a size (or any option) shows its own picture when it has one;
- its **sizes** as buttons, those not made (or out of stock) in the chosen
colour greyed out; other options, such as a mug's, are buttons too;
- its price, which follows what's chosen;
- **Quantity** with − and + buttons (1 to 10, or as many as are left);
- **Add to cart**, into the same cart as the shop's, and its description.
Without JavaScript the colours and sizes are ordinary radio buttons, and the
page still sells the one chosen. Product pages are in the sitemap, and carry
structured data (their pictures, price or price range, and whether they're in
stock), so search engines can show them. The shop, its pages and the cart take
the theme's colours, corners and fonts.
## 6. Test purchase
1. On the public page, press **Add to cart**, then **Check out** in the cart.
You should land on Stripe's checkout.
2. Pay with the card `4242 4242 4242 4242`, any future expiry date, any CVC
and any postcode.
3. You return to a *Thank you* page.
4. On the Orders screen, the order shows **paid**, with the buyer's email and
address, and within a minute you get its email (and the address you paid
with gets the confirmation).
Stripe doesn't email receipts in test mode; your site's emails are sent in
both modes.
With a printed item in the cart, the order also appears at the printer as a
**draft**, and on Print on demand under **Sent to printers**. Check the
address and items there, then delete the draft at the printer.
## 7. Going live
1. Finish **activating your Stripe account** (business and bank details).
2. Turn test mode off and repeat **step 3** in live mode. Live mode has its
own key (`rk_live_…`), its own webhook endpoint and its own signing secret;
save both new ones. The status line then reads *saved: live (real
payments)*.
3. In Stripe → **Settings → Customer emails**, turn on **Successful payments**,
so buyers get a receipt.
4. Make sure the Mail screen's Postmark connection works (**send a test
message**), so you and buyers get the order emails.
5. If a printer makes what you sell, add a payment method to your Printful or
Gelato account, so the orders it's sent can be made.
## Day to day
- **Orders** has three lists: **to send** (paid but not yet marked sent),
**paid**, and **everything**. **mark sent** moves an order out of the to-send
list. Test-mode orders are labelled *test*.
- **Stock**: the Products screen shows how many of each limited item are
left beside it ("3 of 10 left"). Items in an unfinished checkout are held
for an hour, so two buyers can't both take the last one.
- **Printed items** are made and sent by the printer. Follow them on Print on
demand; a refund for one is made in Stripe, and canceling it (if it isn't
made yet) at the printer.
- **Refunds, disputes and payouts** are handled in the Stripe Dashboard.
- **Orders are kept on your server** in the Store's private folder. They're
included in `blowfishctl backup`; the Stripe, Printful and Gelato keys are
only in `--with-secrets` backups.
## Troubleshooting
| What you see | Cause |
|---|---|
| "The shop isn't taking orders yet" | No Stripe key saved. |
| "Payment couldn't be started" | Stripe refused the request. Check the key is still valid; `grep blowfish /var/log/daemon` shows Stripe's reason. |
| Orders stay *pending* | The webhook isn't arriving or is refused. Check **Last webhook** on the Orders screen, and the endpoint's delivery list in Stripe; press **Resend** once fixed. |
| "Bad signature: … doesn't match" | The signing secret is from a different endpoint, or from the other mode. |
| "Bad signature: … seconds away from this server's clock" | The server's clock is wrong: `doas rcctl enable ntpd && doas rcctl start ntpd`. |
| The Orders screen says the Store isn't set up | Switch it off and on again on the Add-ons screen, or run `doas blowfishctl addon enable store`. |
| "Your cart is empty." | Checkout was pressed with nothing in the cart; add an item first. |
| "Choose a quantity from 1 to 10 of each item." | At most 10 of one item per order. |
| "Something in your cart isn't for sale any more…" / "That item isn't for sale any more." | An item was turned off or deleted after it was added. Remove it from the cart. |
| "Only 2 of … left." / "… is sold out." | Fewer are left than asked for (unfinished checkouts hold items for an hour). |
| "Give the cart button some text." | The *Cart button* setting can't be empty. |
| No order emails arrive | Check Postmark on the Mail screen (**send a test message**) and that an *update alerts* or receiving address is set. Queued mail waits while Postmark isn't set up; `/var/www/var/db/blowfishcms-contact/contact.log` shows what was sent. |
| "… can't be ordered right now." | The product is made by a printer that isn't connected. Connect it on Print on demand, or set the product's **Made by** to *Me*. |
| "Printful item: its sync variant ID, a number…" | Give the item's number from **Your Printful products** on Print on demand, or pick it from the field's list. |
| "Gelato product UID: copy it from Gelato's product catalogue…" | The UID is a single word of letters, digits, `_`, `-` and `.`, such as `apparel_product_gca_t-shirt_…`. |
| "Print file: the address of the design Gelato prints…" / "… the full address of the file, starting with https://." | A Gelato product needs the web address of its design. |
| "Printful refused the key" / "Gelato refused the key" | The token or key is wrong, deleted or (Printful) expired. Make a new one. |
| "Printful: the key isn't allowed to do this…" | The token lacks a scope: it needs **View and manage all orders**, **View all store products** and **View and manage webhooks**, for the right store. |
| A product published in Printful doesn't appear on Products | It takes up to a minute. Check **Last update** on Print on demand: Printful's updates need the token's **View and manage webhooks** scope. **sync with Printful** brings them all in at once. If you deleted it on Products before, press **bring them back** there. |
| A product from Printful is off sale with "It's no longer in Printful." | It was deleted (or ignored) in Printful. Delete it on Products, or publish it in Printful again. |
| … with "Its prices in Printful are in EUR, and the shop's in USD." | Printful's retail prices are in its store's currency. Make it the shop's, or change the shop's currency on Products. It goes back on sale by itself once they match. |
| … with "Printful gives it no price of at least 0.50." | Give it a retail price in Printful. |
| "That colour doesn't come in that size. Choose another." | The product's page was used without JavaScript and the chosen colour isn't made in the chosen size. Choose one of the sizes that isn't greyed out. |
| "… is out of stock at the moment." | Printful has none of that option just now (the page greys it out). Choose another, or try again later; it comes back by itself when Printful has it. |
| Every product's page says **Out of stock** | Store 1.7.0 read products saved by 1.6.0 (which kept no word on stock), and some answers from Printful, as out of stock. Update to 1.7.1: an option is in stock unless Printful says it's out of stock, temporarily out of stock or discontinued. Press **sync with Printful** to bring back any it took off sale. |
| A product's page says "not found" | It's switched off, or deleted, on Products. |
| A product shows no picture on the shop's card | It has none at all: add one under **pictures of …** when editing it (or its **Main picture**). With any picture, the card shows its main one, or its first. |
| "A picture from Printful can be hidden, not deleted…" | The next sync would bring it back: **hide** it instead, and it stays hidden. |
| "Choose one or more pictures (JPEG, PNG or WebP), or one from Pictures." / "Up to 20 pictures at a time." / "A product can have up to 80 pictures." | **add pictures** was pressed with no file chosen, too many at once, or the product is full; delete some first. |
| "At the last sync, N pictures couldn't be fetched (…)" on Products | Printful's address for them didn't answer; the reason follows. The others are shown; **sync with Printful** tries again. |
| "Choose which … you'd like." | A product with options was bought without one chosen (an old page, or no JavaScript): choose one in its **Choose** menu. |
| Names show as `3″×3″` | Store 1.5.0 saved some names from Printful garbled; updating to 1.6.0 mends them. It also stops Stripe's checkout page showing names with characters such as ″, × or é garbled, in the Store and in Services. |
| "Store ID: a number, or leave it empty." | Leave it empty for a store's own token. |
| "Printful connected… Its updates couldn't be set up" | The token lacks the **webhooks** permission. Orders are still sent; press **check them all** to hear how they stand, or give the token the permission and save it again. |
| "Printful couldn't be reached" / "Gelato couldn't be reached" | Try again in a minute; check the server can reach `api.printful.com` and `order.gelatoapis.com`. |
| An order shows **not sent to Printful** or **not sent to Gelato** | The printer refused it; its reason follows. Fix it (in the product, or at the printer) and press **send again** on Print on demand. "The order has no delivery address." means Stripe didn't collect one: the product needs shipping. "The order has no email address, which Gelato needs." means the buyer gave none. |
| An order stays **sending** | The printer didn't answer. **send again** (after five minutes) first asks the printer whether it has the order, so it's never sent twice. |
| "Printful: draft, confirm it there" | A test payment, or **Send paid orders straight into production** is off. Confirm it at the printer to have it made. |
| Orders at a printer never show *shipped* | The printer's webhook isn't set up (Printful: save the token again; Gelato: add the address under Developer → Webhooks). **Last update** on Print on demand shows the latest one; **check them all** asks the printers meanwhile. |
## Limits
- Up to 10 of each item, and 30 different items, per order.
- One flat shipping rate per order (free over an amount, if you like). Stripe
can add tax if you enable Stripe Tax on your account; the Store doesn't
calculate it.
- Payment receipts come from Stripe; your site sends the order emails.
- Printed items use the shop's own shipping cost, not the printer's: set it so
it covers what they charge you. The Store doesn't ask the printers for
shipping prices at checkout.
- Options (sizes, colours) come from Printful. A product you make yourself,
or one made by Gelato, has one kind; offer each Gelato size as its own
product.
- Up to 60 of Printful's pictures a product, and up to 80 pictures in all.
- A limited **Number available** is shared by all of a product's options.
- Printful orders use its standard shipping. Printful items come from
products already made in Printful (sync products); Gelato's from its
product UID and your print files.