Commit Graph

51 Commits

Author SHA1 Message Date
2d86e1d23f chore: bump version to trigger CI
Some checks failed
Deploy / deploy (push) Has been cancelled
2026-04-16 18:00:38 +02:00
b92132474b various error checks and formatting
Some checks failed
Deploy / deploy (push) Has been cancelled
2026-04-14 15:26:36 +02:00
8157789e66 update: some updates to the deploy action 2026-04-13 14:48:20 +02:00
7a8f7e9c2a update: add some config to the deploy action 2026-04-13 14:39:12 +02:00
44a9de0209 ci: add github actions deploy 2026-04-13 14:29:51 +02:00
7882667e35 update: commented out unused country codes 2026-04-13 14:08:47 +02:00
a22ba382c2 feat: add ssh key management to account page 2026-04-13 13:33:19 +02:00
7cbefeae40 fix: some fixes 2026-04-12 12:35:05 +02:00
e11e708095 fix: shit was NOT working from last commit 2026-04-12 12:22:06 +02:00
6559c4dd8f fix and feature: made checkout page cleaner, and added card and address modification to account page
the checkout flow was a bit wonky because it would display the same info twice which looked weird and confusing. this is now changed to only show once and update one of the pages independantly.

Now added the possibility to modify card and address list in the account page and not in the checkout flow
2026-04-12 12:11:04 +02:00
157a752540 fix: added user verification to continue checkout after adding card
when the user added their card it would instantly complete the order. this could be unwanted so now i have added an extra input requirement to confirm the payment after adding the card
2026-04-11 20:03:17 +02:00
de9120d1eb fix: Caddyfile domain and Stripe webhook API version mismatch
- Update Caddyfile from placeholder api.yourdomain.com to api.sshops.uk
- Use ConstructEventWithOptions with IgnoreAPIVersionMismatch to handle
  Stripe account API version (2026-01-28.clover) vs stripe-go v78 (2024-04-10)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 19:10:06 +02:00
77a044e11d bruh 2026-04-11 11:37:11 +02:00
40dccc8139 something 2026-04-11 11:10:37 +02:00
ac04676abb adding catppuccin theme 2026-04-11 11:05:16 +02:00
53e443e93d updating 2026-04-09 19:31:55 +02:00
6dba7c6dc6 fix: output api binary to /tmp to avoid conflict with api/ directory 2026-04-09 19:15:58 +02:00
c12b0dcbc2 update 2026-04-09 19:11:39 +02:00
ef5c4ef554 update 2026-04-09 19:06:33 +02:00
7c00202929 add docker and deployment files 2026-04-09 19:05:29 +02:00
639b75578e theme system 2026-04-09 17:39:59 +02:00
062242e346 feat: add browser-based card collection via Stripe Checkout Session
adds a /pay/{token} redirect endpoint that generates a short URL
pointing to a stripe checkout sessions in setup mode. The TUI shows a QR
code and URL on the payment page so users can add a card via the browser
instead of entering raw card data over SSH.

the checkout.session.completed webhook saves the card to the database.
the TUI polls GET /api/v1/cards every second and auto-proceeds to
confirmation once the new card is detected.

also adds a dev.sh startup script that runs all four required processes.
(SSH server, API server, Stripe CLI listener, ngrok) in a single
terminal
2026-04-08 01:03:43 +02:00
6094e05b6f feat: shorten checkout URLs via in-memory redirect for smaller QR codes
Stripe checkout URLs are too long to produce a scannable QR code in a
terminal. Add an in-memory token→URL store and a /pay/{token} redirect
endpoint so the TUI shows a short URL (e.g. localhost:8080/pay/a3f1c2b4)
that fits in a QR. APP_URL config controls the base URL (defaults to
API_URL). Revert to returning sess.URL directly in CollectCard if this
approach needs to be abandoned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 21:55:52 +02:00
a4d5a1559a fix: resoce cart persistance, quantity increment and post-order state bugs
Three bugs fixed, two of them from the last commit, one of them has been
long living.

- the cart query in the ViewInit handler used user_id on cart_items, but
that column does not exist, cart_items links to carts via cart_id. Fixed
by first finding the users cart and then querying items by cart_id,
which is how the reso of the cart handlers already do it.

- GetViewInit was missing the json.Decode call entirely. so the response
body was never parsed. This meant m.User was never set, blocking all
cart syncs and address saves, and the cart always loaded empty.

- after a successful order, the cart was never cleared locally even
though the server deleted the cart items. this meant that the user had
to quit and ssh back in to see the cart update. fixed by clreaing
m.Cart, m.CartCursor and m.ShippingInfo in the CheckoutResultMsg success
handler
2026-03-27 12:21:58 +01:00
296c052fa7 refactor: move SSH auth and initial data loading to splash screen
previously main.go handled auth directly, it connected to the database,
ran migrations, created a JWT manager and SSHAuthService, and
authenticated the SSH key before the TUI even started. this commit rips
all of that out

Auth now happens inside the TUI during the splash screen via
splashAuthCmd, which calls the /auth/token endpoint. if no user exists
or the fingerprint it auto-creates one using the SSH public ke, so there
is no longer a separate registartion flow. The token and user com back
in the response.

once authed splashViewInitCmd fires a single /view/init request that
loads everything needed to start the app, products, cart, addresses,
cards, and orders, before switching to the shop page

on the model side, User/*models.user and gossh.PublicKey were replaced
with plain Fingerprint and SSHPublicKeyStr strings, and NewModelWithAuth
was updated too
2026-03-27 12:18:05 +01:00
4eeb3eda9a feat: added a splash page 2026-03-26 18:34:19 +01:00
4bd4dfabd2 fix: deleting addresses didnt work. oops 2026-03-26 18:01:57 +01:00
3ff4aa9d50 fix: rewrote the huge 700+ line update call with modularized calls 2026-03-26 17:47:56 +01:00
93b257a612 fix: store coffee prices as int cents to prevent rounding errors
prices stored as float64 could lead to rounding errors when converting to cents for stripe (19.99 * 100 = 1998.99... truncating to 1998). canged Coffee.Price to int, storing cents directly. Updated the seed data, fallback products, API handlers, and all TUI display code to be in sync with this change.
2026-03-26 09:09:20 +01:00
f13bfd6572 feat: add order reconciliation job for crash recovery
Adds a background goruotine that runs every 5 minutes to find pending
orders with no Stripe ID older than 10 mins and patches them if stripe
shows a succeeded PaymentIntent. Covers the edge case where the server
crashes after charging but before the DB transaction commits. Also tags
PaymentIntents with order_id metadata at createion to make them
searchable
2026-03-25 21:00:30 +01:00
d5cb4259f5 fix: prevent charge-without-order by creating order before charging
When paying the application charges the card and then sends a payment
record to the database after, in a situation where something goes wrong
between those two steps, we could potentially end up where a users card
was charged but no record on what is was charged for. The fix is to
re-order ConvertCart to write a pending order record before calling
Stripe, this way a DB record always exists if anything fails
mid-operation. This implementation uses an idempotency key keyed to the
order ID to prevent double-charges on retry. Wraps the post-charge DB
updates in a transaction so marking paid andd clearing the cart are
atomic. Adds OrderStatusFailed and a CRITICAL log for the unrecoverable
case. Includes a checkout flow doc with test cards and reconcilation
steps.
2026-03-25 20:13:51 +01:00
1a49360191 feat: throw out the boolean navigation with page routing
replaced ViewingCart/ViewingAccount booleans and CheckoutStep int with a
single 'page' type and a SwitchPage() method, this is just almost
copying the reference implementation (terminalDotShop)'s routing
pattern. Adds inCartFlow(), chechoutStep(), and buildPageContent()
helpers to clean up those huge if/else chains in views, footer, header,
and breadcrumds. code is looking a lot better now!
2026-03-25 15:11:33 +01:00
93cc69d028 just updating the branch with current changes 2026-03-25 08:57:27 +01:00
c7fa292730 update: addeds some extra text in the account page and making some updates for the future for the setting default addresses and cards 2026-03-24 21:29:22 +01:00
0146fa3e76 update: updated README 2026-03-16 16:06:51 +01:00
0a6015b154 fix: Scrolling in detail view didnt work after the rework, this now works 2026-03-14 17:24:21 +01:00
cb2225f1aa update: reworked the handling of account tab to use bubbleteas viewport. it didnt work - yet 2026-03-14 01:20:21 +01:00
404ef31c52 some commits 2026-03-07 18:57:39 +01:00
d6db7e7c8f added some tests. mostly written by claude code 2026-03-03 08:44:47 +01:00
163790092e feat: save cart to database
the cart gets pushed to the database so that if you quit you can quickly
resume with the cart you had before you left
2026-03-02 22:52:11 +01:00
14c0e9ac8b patch: update order history after new order
when making a new order it wouldnt immediately pop up in the order
history in the account tab, you would have to close the connection and
ssh into the server again to see the order. this is now fixed and will
update immediately after ordering
2026-03-02 20:49:10 +01:00
bad11358da feat: view previous order details in account tab
feat: view previous order details in account tab

in the account tab you could view previous orders and how much they cost
but not the entire order and what got ordered and so on.

this is not added where you can go and click on a previous order and get
all the info about that order
2026-03-02 20:41:05 +01:00
f6ca8836c9 feat: added Bring address validation for Norwegian addresses 2026-03-01 20:52:36 +01:00
92d5c46e19 revert and update: reverted shippo logic and changed error msg in TUI
a while back i made shippo skip "validate" addresses that didnt
specifically fail the validation process. this meant that addresses
outside the us worked as long as they didnt specifically return false.
this is now reverted to test actual validaion.

also changed some error messages in the TUI so that the entire message
type is not also printed, just the message
2026-02-28 22:26:01 +01:00
18c7a93e0b feat: implement server-side cart persistance with Stripe PaymentIntents
feat: implement server-side cart persistence with Stripe PaymentIntents

Replaced the client-only in-mem cart with a database-backed cart system

- Add Cart and CartItem GORM models (two-table design)
- Add 6 cart API endpoints (get, set item, set address, set card, clear,
conver)
- Switch from Stripe Charge API to PaymentIntents with confirm:true
- Add 9 API client methods for cart and card operations
- Refactor TUI cart from map[int] (slice index) to map[uint] (CoffeeID)
- Replace single-shot checkout with saveCardAndConvert multi-step flow
- Add CheckingOut state with "submitting order..." processing indicator
- Fix Stripe tokenization to use secret key for server-side SSH apps
- Remove admin product CRUD endpoints and old checkout handler
2026-02-28 15:01:06 +01:00
6097b8c863 rework: added shipping validation at address creation
the last implementation just accepted any input for the shipping
validation and then only validated the address on payment. this is now
changed to validation upon creation upon finishing the shipping address
form.

when a user completes the shipping form, a client-side check is first
made to just simply check if there are any empty fields, if this check
passes it gets check server-side by shippo. If the address is not found
it will return an address not found error, and the user will not be able
to continue to the payment form. The invalid address will also not be
saved to the database.

if the check pass, we simply save the address to the database with an
ID. this ID is then passe in when doing the payment, instead of
validating at the payment phase.

this implementation currently only uses Shippo, which i have come to
realize does NOT support shipping in countries outside of the US (i
should have read the friendly manual before using Shippo). This means
that a huge rewrite is due.

i will focus on adding address validation for Norway first since thats
where i live. i plan on using Bring's api for this validation. i will
still keep Shippo for US based address verification even though this
project is focused fon nordic shipping - just for a rainy day if some
poor soul decides to order from AMERICA
2026-02-26 16:32:48 +01:00
7ebc5b24de updating the ui fr 2026-02-26 10:16:57 +01:00
7f07394537 something 2026-02-24 15:35:32 +01:00
59cd90b6a9 something 2026-02-23 19:51:13 +01:00
c5e7a3c290 somthing 2026-02-16 11:45:23 +01:00