rastrillo / abono Public

Clone
git clone https://amadan.net/rastrillo/abono

Plain git — no account needed to clone.

Download

Download this file

1# abono example
2
3A small rastrillo app that sells memberships with abono. It has sign-in by
4emailed link, the starter pages, and the sandbox in place of Stripe, so you
5can click through the whole flow without a Stripe account.
6
7## Run it
8
9```sh
10cd example
11go run .
12```
13
14Open http://localhost:8080. It listens on 127.0.0.1 only.
15
161. Sign in with any address. No mail is sent: the sign-in link is written
17 to the log, so open it from there.
182. Buy a plan. The checkout and billing pages are the sandbox's stand-ins
19 for Stripe's: nothing is charged.
203. Sign in as `owner@example.com` to see the owner's pages under `/admin`:
21 members, free memberships, subscriptions on prices no plan has, plans
22 and prices, and the Stripe status.
23
24The words on the pages are message keys (`abono.pages.pricing_title`) until
25abono's English catalog lands. The layout has one key of its own,
26`example.signout`; the sign-in screen is rastrillo's.
27
28Settings are environment variables; `main.go` lists them. Set `STRIPE_KEY`
29and `STRIPE_WEBHOOK_SECRET` to use a Stripe test account instead of the
30sandbox.
31
32## Where things are
33
34- `abono_pages.go` and `templates/abono/` were written by
35 `abono pages -pkg main -dir .` and are not edited here, so they stay
36 exactly what an app gets. abono's `cmd/abono` tests fail if they drift.
37- `app.go` wires it together: magic-link sign-in (rastrillo `auth`), `abono.New` with
38 the sandbox, the pages, and the webhook and daily-sync endpoints, which
39 `csrf.Exempt` lets through.
40- `models.go` has the user table, and the `Holder` that makes a user for
41 someone who pays before signing in. The only way into that user is a
42 sign-in link sent to the address it was made for.
43
44## Test it
45
46```sh
47go test ./...
48RASTRILLO_CHROME=/usr/bin/chromium go test -tags browser -run TestBrowser .
49```
50
51The second drives the pages in Chromium from the plans to cancelling. It
52fails, rather than skips, when there is no browser. `make ci` at the
53repository root runs both.
54