| 1 | # abono example |
| 2 | |
| 3 | A small rastrillo app that sells memberships with abono. It has sign-in by |
| 4 | emailed link, the starter pages, and the sandbox in place of Stripe, so you |
| 5 | can click through the whole flow without a Stripe account. |
| 6 | |
| 7 | ## Run it |
| 8 | |
| 9 | ```sh |
| 10 | cd example |
| 11 | go run . |
| 12 | ``` |
| 13 | |
| 14 | Open http://localhost:8080. It listens on 127.0.0.1 only. |
| 15 | |
| 16 | 1. Sign in with any address. No mail is sent: the sign-in link is written |
| 17 | to the log, so open it from there. |
| 18 | 2. Buy a plan. The checkout and billing pages are the sandbox's stand-ins |
| 19 | for Stripe's: nothing is charged. |
| 20 | 3. 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 | |
| 24 | The words on the pages are message keys (`abono.pages.pricing_title`) until |
| 25 | abono's English catalog lands. The layout has one key of its own, |
| 26 | `example.signout`; the sign-in screen is rastrillo's. |
| 27 | |
| 28 | Settings are environment variables; `main.go` lists them. Set `STRIPE_KEY` |
| 29 | and `STRIPE_WEBHOOK_SECRET` to use a Stripe test account instead of the |
| 30 | sandbox. |
| 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 |
| 47 | go test ./... |
| 48 | RASTRILLO_CHROME=/usr/bin/chromium go test -tags browser -run TestBrowser . |
| 49 | ``` |
| 50 | |
| 51 | The second drives the pages in Chromium from the plans to cancelling. It |
| 52 | fails, rather than skips, when there is no browser. `make ci` at the |
| 53 | repository root runs both. |
| 54 | |