ferst-core 0.10.3 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  // ferst-modules — what this site has from its organisation's modules in the Ferst portal:
3
- // the forms it can place and the calendar it shows. Run it in a client repo root:
3
+ // the forms it can place, what it can take payment for, and the calendar it shows. Run it in a client repo root:
4
4
  //
5
5
  // npx --no-install ferst-modules # the site named in ferst-site.json
6
6
  // npx --no-install ferst-modules --site <address> # or ask by the site's address
7
7
  // npx --no-install ferst-modules --json # the raw answer
8
8
  //
9
9
  // Forms and calendars live in the portal, never in the repo: place a form with a
10
- // `{ "type": "form", "form": "<its name on this site>" }` block, and show the calendar by setting
10
+ // `{ "type": "form", "form": "<its name on this site>" }` block, take a payment with a
11
+ // `{ "type": "pay", "item": "<its id>" }` block, and show the calendar by setting
11
12
  // calendarSettings.embedUrl to the address printed here.
12
13
  import { readFileSync, realpathSync } from 'node:fs';
13
14
  import { resolve } from 'node:path';
14
15
  import { pathToFileURL } from 'node:url';
15
16
  import { resolveGitBase } from '../lib/git-base.mjs';
16
17
 
18
+ /** £40, £40.50 (lib/pay formatPrice, for a plain .mjs bin). */
19
+ const price = (amount, currency = 'gbp') => {
20
+ const units = amount / 100;
21
+ const text = Number.isInteger(units) ? String(units) : units.toFixed(2);
22
+ return currency.toLowerCase() === 'gbp' ? `£${text}` : `${text} ${currency.toUpperCase()}`;
23
+ };
24
+
17
25
  /**
18
26
  * True when THIS file is run as a CLI (not imported). Each bin needs its own copy:
19
27
  * `import.meta.url` is per file, so one borrowed from another bin only ever matches that
@@ -52,6 +60,14 @@ export function formatModules(data) {
52
60
  }
53
61
  out.push('');
54
62
 
63
+ out.push('Payments');
64
+ if (!data.modules.payments) out.push(' The Payments module is off for this site, or has nothing to take payment for yet (portal: Payments).');
65
+ for (const p of data.pay ?? []) {
66
+ out.push(` ${p.title}: ${price(p.amount, p.currency)}`);
67
+ out.push(` place it with: { "type": "pay", "item": "${p.id}" }`);
68
+ }
69
+ out.push('');
70
+
55
71
  out.push('Events');
56
72
  if (!data.events) out.push(' The Events module is off for this site.');
57
73
  else {
@@ -27,6 +27,7 @@ import Gallery from './recipes/Gallery.astro';
27
27
  import Testimonial from './recipes/Testimonial.astro';
28
28
  import ContactForm from './recipes/ContactForm.astro';
29
29
  import Form from './recipes/Form.astro';
30
+ import Pay from './recipes/Pay.astro';
30
31
  import Accordion from './recipes/Accordion.astro';
31
32
  import Tiles from './recipes/Tiles.astro';
32
33
  import Banner from './recipes/Banner.astro';
@@ -81,6 +82,7 @@ const registry: Record<BlockType, any> = {
81
82
  testimonial: Testimonial,
82
83
  contactForm: ContactForm,
83
84
  form: Form,
85
+ pay: Pay,
84
86
  accordion: Accordion,
85
87
  tiles: Tiles,
86
88
  banner: Banner,
@@ -28,6 +28,12 @@ interface Props {
28
28
  submitLabel?: string;
29
29
  note?: string;
30
30
  fields?: Field[];
31
+ /** Sent with the form, unseen (e.g. the page to come back to). */
32
+ hidden?: Record<string, string>;
33
+ /** Add a field only bots fill (`_gotcha`): the platform refuses a form that has it filled. */
34
+ honeypot?: boolean;
35
+ /** Prefixes the fields' ids, so two forms on one page don't share them. */
36
+ idPrefix?: string;
31
37
  }
32
38
  const {
33
39
  title,
@@ -37,6 +43,9 @@ const {
37
43
  submitLabel = 'Send message',
38
44
  note,
39
45
  fields = [],
46
+ hidden = {},
47
+ honeypot = false,
48
+ idPrefix = 'cf',
40
49
  } = Astro.props;
41
50
  // Alignment overrides (BlockLayout): the title + intro default to centred; the block's
42
51
  // own `align`, or `headingAlign` for the title alone, overrides it from the page data.
@@ -52,8 +61,14 @@ const headAlign = headingAlign ?? blockAlign ?? 'center';
52
61
  </div>
53
62
  )}
54
63
  <form class="b-contact-form__form" action={action} method={method}>
64
+ {Object.entries(hidden).map(([name, value]) => <input type="hidden" name={name} value={value} />)}
65
+ {honeypot && (
66
+ <div class="b-contact-form__trap" aria-hidden="true">
67
+ <label>Leave this empty <input type="text" name="_gotcha" tabindex="-1" autocomplete="off" /></label>
68
+ </div>
69
+ )}
55
70
  {fields.map((field) => {
56
- const id = `cf-${field.name}`;
71
+ const id = `${idPrefix}-${field.name}`;
57
72
  const type = field.type ?? 'text';
58
73
  return (
59
74
  <div class="b-contact-form__field">
@@ -164,6 +179,13 @@ const headAlign = headingAlign ?? blockAlign ?? 'center';
164
179
  border-color: var(--gold);
165
180
  box-shadow: 0 0 0 3px var(--gold-light);
166
181
  }
182
+ .b-contact-form__trap {
183
+ position: absolute;
184
+ left: -10000px;
185
+ width: 1px;
186
+ height: 1px;
187
+ overflow: hidden;
188
+ }
167
189
  .b-contact-form__action {
168
190
  margin-top: 0.25rem;
169
191
  }
@@ -0,0 +1,203 @@
1
+ ---
2
+ /**
3
+ * Pay — a payment for one of the organisation's items from the Ferst Payments module ("Course fee",
4
+ * £40). The item's name and price are read from the platform at build time (lib/pay) and again in
5
+ * the browser, so a new name, a new price or a sale shows (and a sale ends) without a rebuild; the
6
+ * page never says what to charge. A sale shows as a sale, in one standard form: the usual price
7
+ * struck through, the sale price, and a "Sale" tag with its last day. The visitor gives a name and email; the form posts to the platform, which sends them to
8
+ * Stripe's page on the organisation's own account, and Stripe brings them back here with
9
+ * `?payment=done` or `?payment=cancelled` (and this block's anchor), where the block says so.
10
+ * Works without JavaScript: a plain form post, answered with a redirect to Stripe.
11
+ */
12
+ import ContactForm from './ContactForm.astro';
13
+ import Heading from '../blocks/Heading.astro';
14
+ import { formatPrice, loadPayItem, saleLine } from '../../lib/pay';
15
+ import { resolveGitBase, resolveSiteId } from '../../lib/git-base.mjs';
16
+
17
+ interface Props {
18
+ item: string;
19
+ title?: string;
20
+ intro?: string;
21
+ note?: string;
22
+ buttonLabel?: string;
23
+ }
24
+ const { item, title, intro, note, buttonLabel = 'Pay' } = Astro.props;
25
+ const def = await loadPayItem(item, { base: resolveGitBase(), siteId: resolveSiteId() });
26
+ const anchor = `pay-${def.id}`;
27
+ const price = formatPrice(def.amount, def.currency);
28
+ const was = def.sale ? formatPrice(def.sale.usualAmount, def.currency) : '';
29
+ const saleText = def.sale ? saleLine(def.sale.lastDay) : '';
30
+ const { align: blockAlign, headingAlign } = Astro.props as { align?: 'start' | 'center' | 'end'; headingAlign?: 'start' | 'center' | 'end' };
31
+ const headAlign = headingAlign ?? blockAlign ?? 'center';
32
+ ---
33
+
34
+ <section class="b-pay" id={anchor} data-pay={def.definition} data-label={buttonLabel} data-item-title={title ? undefined : ''}>
35
+ <div class="b-pay__head" data-recipe-head data-content-align={headAlign}>
36
+ <Heading text={title ?? def.title} level={2} />
37
+ <p class="b-pay__price">
38
+ <del class="b-pay__was" data-pay-was hidden={!def.sale}><span class="b-pay__sr">Usual price: </span><span data-pay-was-amount>{was}</span></del>
39
+ <span><span class="b-pay__sr" data-pay-now-label hidden={!def.sale}>Sale price: </span><span data-pay-now>{price}</span></span>
40
+ </p>
41
+ <p class="b-pay__sale" data-pay-sale hidden={!def.sale}><span class="b-pay__tag">Sale</span> <span data-pay-sale-text>{saleText}</span></p>
42
+ {intro && <p class="b-pay__intro">{intro}</p>}
43
+ </div>
44
+ <div class="b-pay__notice b-pay__notice--done" role="status" data-pay-done hidden>
45
+ <strong>Thank you: your payment has gone through.</strong> A receipt is on its way to your email.
46
+ </div>
47
+ <div class="b-pay__notice" role="status" data-pay-cancelled hidden>
48
+ Your payment wasn’t taken. You can try again whenever you’re ready.
49
+ </div>
50
+ <div class="b-pay__notice" role="status" data-pay-unavailable hidden>
51
+ This payment isn’t available just now.
52
+ </div>
53
+ <ContactForm
54
+ action={def.action}
55
+ method="post"
56
+ submitLabel={`${buttonLabel} ${price}`}
57
+ note={note ?? 'You’ll pay on Stripe’s secure page, and get a receipt by email.'}
58
+ fields={[
59
+ { name: 'name', label: 'Your name', type: 'text', required: true },
60
+ { name: 'email', label: 'Your email', type: 'email', required: true },
61
+ ]}
62
+ hidden={{ return_to: `${Astro.url.pathname}#${anchor}` }}
63
+ honeypot
64
+ idPrefix={anchor}
65
+ />
66
+ </section>
67
+
68
+ <script>
69
+ import { formatPrice, readSale, saleLine, type PayItemAnswer } from '../../lib/pay';
70
+
71
+ function setUp(block: HTMLElement, onlyOne: boolean) {
72
+ // Back from Stripe: say how it went, on the block that was paid (its anchor), then tidy the address.
73
+ const outcome = new URLSearchParams(location.search).get('payment');
74
+ if ((outcome === 'done' || outcome === 'cancelled') && (location.hash === `#${block.id}` || (onlyOne && !location.hash))) {
75
+ const notice = block.querySelector<HTMLElement>(outcome === 'done' ? '[data-pay-done]' : '[data-pay-cancelled]');
76
+ if (notice) notice.hidden = false;
77
+ const url = new URL(location.href);
78
+ url.searchParams.delete('payment');
79
+ history.replaceState(history.state, '', url);
80
+ }
81
+ // The name and price now (renamed, repriced, or a sale begun or ended since the build); gone
82
+ // from offer, the form is closed.
83
+ const src = block.dataset.pay;
84
+ if (!src) return;
85
+ fetch(src, { headers: { Accept: 'application/json' } })
86
+ .then(async (res) => {
87
+ const form = block.querySelector<HTMLFormElement>('form');
88
+ if (res.status === 404) {
89
+ block.querySelector<HTMLElement>('[data-pay-unavailable]')!.hidden = false;
90
+ form?.querySelectorAll<HTMLInputElement | HTMLButtonElement>('input, button').forEach((el) => { el.disabled = true; });
91
+ return;
92
+ }
93
+ if (!res.ok) return;
94
+ const d = (await res.json()) as PayItemAnswer;
95
+ const currency = d.currency ?? 'gbp';
96
+ const text = formatPrice(d.amount, currency);
97
+ const sale = readSale(d);
98
+ const set = (sel: string, value: string) => { const el = block.querySelector<HTMLElement>(sel); if (el && el.textContent !== value) el.textContent = value; };
99
+ const show = (sel: string, on: boolean) => { const el = block.querySelector<HTMLElement>(sel); if (el) el.hidden = !on; };
100
+ set('[data-pay-now]', text);
101
+ if (sale) {
102
+ set('[data-pay-was-amount]', formatPrice(sale.usualAmount, currency));
103
+ set('[data-pay-sale-text]', saleLine(sale.lastDay));
104
+ }
105
+ ['[data-pay-was]', '[data-pay-now-label]', '[data-pay-sale]'].forEach((sel) => show(sel, !!sale));
106
+ const button = form?.querySelector<HTMLButtonElement>('button[type="submit"]');
107
+ if (button) { const label = `${block.dataset.label ?? 'Pay'} ${text}`; if (button.textContent !== label) button.textContent = label; }
108
+ // The item's own name, unless the block gives its own title.
109
+ if (block.dataset.itemTitle !== undefined && d.title) set('.b-pay__head .b-heading', d.title);
110
+ })
111
+ .catch(() => { /* the price from the build stands; the platform reads the real one when they pay */ });
112
+ }
113
+
114
+ const blocks = Array.from(document.querySelectorAll<HTMLElement>('[data-pay]'));
115
+ blocks.forEach((b) => setUp(b, blocks.length === 1));
116
+ </script>
117
+
118
+ <style>
119
+ .b-pay {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: 1.25rem;
123
+ max-width: 40rem;
124
+ margin-inline: auto;
125
+ padding-inline: 1rem;
126
+ }
127
+ .b-pay :global(.b-contact-form) {
128
+ padding-inline: 0;
129
+ }
130
+ .b-pay__head {
131
+ display: flex;
132
+ flex-direction: column;
133
+ gap: 0.5rem;
134
+ }
135
+ .b-pay__price {
136
+ margin: 0;
137
+ font-family: var(--font-heading, var(--font-body));
138
+ font-size: 1.75rem;
139
+ font-weight: 700;
140
+ color: var(--fg);
141
+ font-variant-numeric: tabular-nums;
142
+ }
143
+ .b-pay__was {
144
+ margin-inline-end: 0.5rem;
145
+ font-size: 0.6em;
146
+ font-weight: 500;
147
+ color: var(--muted);
148
+ text-decoration-thickness: 0.08em;
149
+ }
150
+ .b-pay__sale {
151
+ margin: 0;
152
+ color: var(--muted);
153
+ font-size: 0.95rem;
154
+ }
155
+ .b-pay__tag {
156
+ display: inline-block;
157
+ margin-inline-end: 0.35rem;
158
+ padding: 0.1rem 0.55rem;
159
+ border: 1px solid var(--gold);
160
+ border-radius: 999px;
161
+ background: var(--gold-light);
162
+ color: var(--fg);
163
+ font-size: 0.75rem;
164
+ font-weight: 700;
165
+ letter-spacing: 0.06em;
166
+ text-transform: uppercase;
167
+ vertical-align: 0.1em;
168
+ }
169
+ /* Read out ("Usual price: £40", "Sale price: £30"), not shown. */
170
+ .b-pay__sr {
171
+ position: absolute;
172
+ width: 1px;
173
+ height: 1px;
174
+ overflow: hidden;
175
+ clip-path: inset(50%);
176
+ white-space: nowrap;
177
+ }
178
+ .b-pay__was[hidden],
179
+ .b-pay__sale[hidden],
180
+ .b-pay__sr[hidden] {
181
+ display: none;
182
+ }
183
+ .b-pay__intro {
184
+ margin: 0;
185
+ color: var(--muted);
186
+ line-height: 1.6;
187
+ }
188
+ .b-pay__notice {
189
+ padding: 0.85rem 1rem;
190
+ border: 1px solid var(--border);
191
+ border-radius: var(--radius-sm);
192
+ background: var(--bg-section);
193
+ color: var(--fg);
194
+ line-height: 1.5;
195
+ }
196
+ .b-pay__notice--done {
197
+ border-color: var(--gold);
198
+ background: var(--gold-light);
199
+ }
200
+ .b-pay__notice[hidden] {
201
+ display: none;
202
+ }
203
+ </style>
package/content/blocks.ts CHANGED
@@ -242,6 +242,25 @@ export const formBlock = z.object({
242
242
  note: z.string().optional(),
243
243
  });
244
244
 
245
+ /** A payment for one of the organisation's items, from the Ferst Payments module ("Course fee",
246
+ * £40). The block names the item; its name and price are the organisation's, read from the
247
+ * platform at build time (lib/pay) and again in the browser, never written here: the platform
248
+ * reads the price itself when the visitor pays. The visitor gives a name and email and pays on
249
+ * Stripe's page. List what a site can take payment for with `npx ferst-modules`. */
250
+ export const payBlock = z.object({
251
+ type: z.literal('pay'),
252
+ enabled: z.boolean().default(true),
253
+ /** The item's id in the portal (e.g. `pi_8c1d…`). */
254
+ item: z.string().min(1),
255
+ /** Defaults to the item's name. */
256
+ title: z.string().optional(),
257
+ intro: z.string().optional(),
258
+ /** Small print under the button (e.g. what happens after paying). */
259
+ note: z.string().optional(),
260
+ /** The button's words; the price follows them ("Pay £40"). */
261
+ buttonLabel: z.string().max(40).optional(),
262
+ });
263
+
245
264
  /** A contact form recipe. `fields` is generic (any labelled input list) so the
246
265
  * same recipe serves a contact page, an enquiry form, a sign-up, etc. `action`
247
266
  * is optional: the core ships no backend, so with none it renders a standard
@@ -727,6 +746,7 @@ export type RecipeBlock =
727
746
  | z.infer<typeof testimonialBlock>
728
747
  | z.infer<typeof contactFormBlock>
729
748
  | z.infer<typeof formBlock>
749
+ | z.infer<typeof payBlock>
730
750
  | z.infer<typeof accordionBlock>
731
751
  | z.infer<typeof tilesBlock>
732
752
  | z.infer<typeof bannerBlock>
@@ -870,6 +890,7 @@ export const blockSchema = z.discriminatedUnion(
870
890
  testimonialBlock,
871
891
  contactFormBlock,
872
892
  formBlock,
893
+ payBlock,
873
894
  accordionBlock,
874
895
  tilesBlock,
875
896
  bannerBlock,
@@ -960,7 +981,7 @@ export const blockTypes = (
960
981
  blockSchema as unknown as { options: ReadonlyArray<{ shape: { type: { value: BlockType } } }> }
961
982
  ).options.map((o) => o.shape.type.value);
962
983
 
963
- /** Blocks whose content comes from the Ferst platform at build time (a form placed by id).
984
+ /** Blocks whose content comes from the Ferst platform at build time (a form, an item to pay for).
964
985
  * The public showcase can't render them without the platform, so its galleries show the
965
986
  * look through their local twin instead (`form` renders with the contactForm recipe). */
966
- export const platformBlockTypes: readonly BlockType[] = ['form'];
987
+ export const platformBlockTypes: readonly BlockType[] = ['form', 'pay'];
@@ -29,6 +29,7 @@ const QUESTIONS: Record<string, RecipeQuestion | null> = {
29
29
  testimonial: ask('What people say', 'What have customers said about you?', 'Paste a kind word or review, with the person’s name or initials if they’re happy to be named.'),
30
30
  contactForm: ask('Contact form', 'What should people be able to ask you through this form?', 'Who answers, what you need to know from them, and how soon they can expect a reply.'),
31
31
  form: note('Form', 'This shows one of your organisation’s forms. Choose or create it in the portal under Forms.'),
32
+ pay: note('Payment', 'This takes a payment for one of the things your sites take payment for. Set what it’s for and its price in the portal, under Payments.'),
32
33
  accordion: ask('Expandable sections', 'What information should people be able to open up and read here?', 'Give each topic a short heading and the detail that goes under it.'),
33
34
  tiles: ask('Quick links', 'Where do visitors most often want to go from here?', 'List the places or tasks, a few words each, for example: opening times, book now, prices.'),
34
35
  banner: ask('Banner', 'What message deserves a bold band across the page?', 'A short statement or invitation, and where it should lead if anywhere.'),
package/lib/pay.ts ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * A "Pay" block takes a payment for one of the organisation's items (the Ferst Payments module).
3
+ * The block names the item; its name and price are the organisation's, read from the platform at
4
+ * build time (and again in the browser, so a new name, a new price or a sale shows, and a sale
5
+ * ends, without a rebuild). A sale shows as one: the usual price struck through and its last day. The page
6
+ * never says what to charge: the platform reads the price itself when the visitor pays.
7
+ *
8
+ * A payment is always the site's own, so the site must say who it is (`siteId` in
9
+ * ferst-site.json). An item that isn't on offer, or a platform that can't be reached, fails the
10
+ * build: better the last good deploy stays live than a Pay button that can't take a payment.
11
+ */
12
+ export interface PayItem {
13
+ id: string;
14
+ title: string;
15
+ /** In the smallest unit (pence). */
16
+ amount: number;
17
+ currency: string;
18
+ /** A sale running now: the usual price (struck through beside `amount`) and its last day (YYYY-MM-DD, UTC). */
19
+ sale: { usualAmount: number; lastDay: string } | null;
20
+ /** Where the browser posts the payment (the platform sends the visitor on to Stripe). */
21
+ action: string;
22
+ /** Where the page re-reads the current price. */
23
+ definition: string;
24
+ }
25
+
26
+ type FetchFn = (input: string, init?: RequestInit) => Promise<Response>;
27
+
28
+ /** £40, £40.50, £0.99; other currencies as "15 EUR". */
29
+ export function formatPrice(amount: number, currency: string): string {
30
+ const units = amount / 100;
31
+ const text = Number.isInteger(units) ? String(units) : units.toFixed(2);
32
+ return currency.toLowerCase() === 'gbp' ? `£${text}` : `${text} ${currency.toUpperCase()}`;
33
+ }
34
+
35
+ /**
36
+ * When a sale ends, in words: "until 30 November" (the year only when it isn't this one), or
37
+ * "ends today" on its last day. Days are UTC, as the platform sets them.
38
+ */
39
+ export function saleLine(lastDay: string, now = new Date()): string {
40
+ if (lastDay === now.toISOString().slice(0, 10)) return 'ends today';
41
+ const d = new Date(`${lastDay}T12:00:00Z`);
42
+ const sameYear = d.getUTCFullYear() === now.getUTCFullYear();
43
+ return `until ${d.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', ...(sameYear ? {} : { year: 'numeric' }), timeZone: 'UTC' })}`;
44
+ }
45
+
46
+ /** The platform's answer, as the block reads it (at build time and in the browser). */
47
+ export interface PayItemAnswer {
48
+ id: string; title: string; amount: number; currency?: string; action: string;
49
+ sale?: { usual_amount: number; last_day: string } | null;
50
+ }
51
+
52
+ export function readSale(d: Pick<PayItemAnswer, 'sale'>): PayItem['sale'] {
53
+ const s = d.sale;
54
+ return s && typeof s.usual_amount === 'number' && typeof s.last_day === 'string' ? { usualAmount: s.usual_amount, lastDay: s.last_day } : null;
55
+ }
56
+
57
+ const cache = new Map<string, Promise<PayItem>>();
58
+
59
+ export function loadPayItem(item: string, opts: { base: string; siteId?: string | null; fetch?: FetchFn }): Promise<PayItem> {
60
+ const key = `${opts.base}|${opts.siteId ?? ''}|${item}`;
61
+ let hit = cache.get(key);
62
+ if (!hit) {
63
+ hit = fetchItem(item, opts.base, opts.siteId ?? null, opts.fetch ?? fetch);
64
+ cache.set(key, hit);
65
+ hit.catch(() => cache.delete(key)); // a failure is retried by the next caller
66
+ }
67
+ return hit;
68
+ }
69
+
70
+ async function fetchItem(item: string, base: string, siteId: string | null, fetchFn: FetchFn): Promise<PayItem> {
71
+ if (!siteId) {
72
+ throw new Error(`Pay block: this site doesn't say who it is, so it can't take payments. Add "siteId" to ferst-site.json (or set FERST_SITE_ID).`);
73
+ }
74
+ const url = `${base}/sites/${encodeURIComponent(siteId)}/pay/${encodeURIComponent(item)}`;
75
+ let res: Response;
76
+ try {
77
+ res = await fetchFn(url, { headers: { Accept: 'application/json' } });
78
+ } catch (e) {
79
+ throw new Error(`Pay block: couldn’t reach the Ferst platform for item "${item}" (${url}): ${e instanceof Error ? e.message : String(e)}`);
80
+ }
81
+ if (res.status === 404) {
82
+ throw new Error(`Pay block: "${item}" isn’t on offer on this site. Check it in the portal (the Payments module: what your sites take payment for, and Payments switched on for the site), or run \`npx ferst-modules\` to list what this site can take payment for.`);
83
+ }
84
+ if (!res.ok) throw new Error(`Pay block: the Ferst platform answered ${res.status} for item "${item}" (${url}).`);
85
+ const d = (await res.json()) as PayItemAnswer;
86
+ return { id: d.id, title: d.title, amount: d.amount, currency: d.currency ?? 'gbp', sale: readSale(d), action: d.action, definition: url };
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferst-core",
3
- "version": "0.10.3",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "description": "Ferst Core — the shared, brand-agnostic client-site system: Astro components, layouts, content schemas, the layered config resolver, and a neutral styling architecture that every client overrides.",
6
6
  "license": "BUSL-1.1",