@aglyn/plugins-commerce 1.14.0 → 1.15.0

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.
Files changed (152) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/account-subscriptions.d.ts +51 -0
  3. package/src/lib/components/account-subscriptions.js +168 -0
  4. package/src/lib/components/account-subscriptions.js.map +1 -0
  5. package/src/lib/components/account.js +12 -48
  6. package/src/lib/components/account.js.map +1 -1
  7. package/src/lib/components/cart.js +30 -6
  8. package/src/lib/components/cart.js.map +1 -1
  9. package/src/lib/components/commerce-console-page.js +6 -0
  10. package/src/lib/components/commerce-console-page.js.map +1 -1
  11. package/src/lib/components/commerce-console-sections.d.ts +1 -1
  12. package/src/lib/components/commerce-console-sections.js +5 -0
  13. package/src/lib/components/commerce-console-sections.js.map +1 -1
  14. package/src/lib/components/console/paid-media.d.ts +1 -0
  15. package/src/lib/components/console/paid-media.js +15 -4
  16. package/src/lib/components/console/paid-media.js.map +1 -1
  17. package/src/lib/components/console/payments-settings-card.component.js +1 -1
  18. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  19. package/src/lib/components/console/pos/pos-hardware-api.d.ts +10 -1
  20. package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
  21. package/src/lib/components/console/pos/pos-hardware-buyer.component.js +2 -2
  22. package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -1
  23. package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +2 -0
  24. package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -1
  25. package/src/lib/components/console/pos-cellular-control.component.d.ts +1 -1
  26. package/src/lib/components/console/pos-cellular-control.component.js +5 -5
  27. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
  28. package/src/lib/components/console/pos-devices-card.component.js +2 -2
  29. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  30. package/src/lib/components/console/pos-hardware-card.component.d.ts +5 -0
  31. package/src/lib/components/console/pos-hardware-card.component.js +77 -8
  32. package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
  33. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +137 -19
  34. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
  35. package/src/lib/components/console/pos-page.component.js +19 -2
  36. package/src/lib/components/console/pos-page.component.js.map +1 -1
  37. package/src/lib/components/console/product-editor-dialog.component.js +21 -2
  38. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  39. package/src/lib/components/console/subscription-detail-dialog.component.d.ts +58 -0
  40. package/src/lib/components/console/subscription-detail-dialog.component.js +201 -0
  41. package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -0
  42. package/src/lib/components/console/subscriptions-card.component.d.ts +60 -0
  43. package/src/lib/components/console/subscriptions-card.component.js +280 -0
  44. package/src/lib/components/console/subscriptions-card.component.js.map +1 -0
  45. package/src/lib/components/hardware-terms-consent.d.ts +22 -0
  46. package/src/lib/components/hardware-terms-consent.js +85 -0
  47. package/src/lib/components/hardware-terms-consent.js.map +1 -0
  48. package/src/lib/components/product-detail.js +25 -5
  49. package/src/lib/components/product-detail.js.map +1 -1
  50. package/src/lib/constants/operator-alerts.d.ts +1 -1
  51. package/src/lib/constants/operator-alerts.js +4 -4
  52. package/src/lib/constants/operator-alerts.js.map +1 -1
  53. package/src/lib/model/commerce-orders.d.ts +6 -2
  54. package/src/lib/model/commerce-orders.js.map +1 -1
  55. package/src/lib/model/commerce-payment-methods.d.ts +24 -0
  56. package/src/lib/model/commerce-payment-methods.js +35 -0
  57. package/src/lib/model/commerce-payment-methods.js.map +1 -1
  58. package/src/lib/model/commerce.d.ts +6 -0
  59. package/src/lib/model/commerce.js.map +1 -1
  60. package/src/lib/model/index.d.ts +1 -0
  61. package/src/lib/model/index.js +1 -0
  62. package/src/lib/model/index.js.map +1 -1
  63. package/src/lib/model/paid-media.d.ts +8 -0
  64. package/src/lib/model/paid-media.js +13 -0
  65. package/src/lib/model/paid-media.js.map +1 -1
  66. package/src/lib/model/pos-hardware-in-person.d.ts +23 -2
  67. package/src/lib/model/pos-hardware-in-person.js +52 -20
  68. package/src/lib/model/pos-hardware-in-person.js.map +1 -1
  69. package/src/lib/model/pos-hardware-tax-summary.d.ts +5 -1
  70. package/src/lib/model/pos-hardware-tax-summary.js +2 -1
  71. package/src/lib/model/pos-hardware-tax-summary.js.map +1 -1
  72. package/src/lib/model/pos-hardware-terms.d.ts +37 -2
  73. package/src/lib/model/pos-hardware-terms.js +68 -3
  74. package/src/lib/model/pos-hardware-terms.js.map +1 -1
  75. package/src/lib/model/pos-hardware.d.ts +101 -15
  76. package/src/lib/model/pos-hardware.js +128 -18
  77. package/src/lib/model/pos-hardware.js.map +1 -1
  78. package/src/lib/model/pos-reader-splash.js +2 -2
  79. package/src/lib/model/pos-reader-splash.js.map +1 -1
  80. package/src/lib/model/product-write.d.ts +3 -0
  81. package/src/lib/model/subscription-view.d.ts +90 -0
  82. package/src/lib/model/subscription-view.js +176 -0
  83. package/src/lib/model/subscription-view.js.map +1 -0
  84. package/src/lib/server/billing-webhook.d.ts +4 -6
  85. package/src/lib/server/billing-webhook.js +109 -51
  86. package/src/lib/server/billing-webhook.js.map +1 -1
  87. package/src/lib/server/cart-checkout.js +45 -10
  88. package/src/lib/server/cart-checkout.js.map +1 -1
  89. package/src/lib/server/cart.js +15 -3
  90. package/src/lib/server/cart.js.map +1 -1
  91. package/src/lib/server/checkout.js +58 -16
  92. package/src/lib/server/checkout.js.map +1 -1
  93. package/src/lib/server/draft-order.js +7 -3
  94. package/src/lib/server/draft-order.js.map +1 -1
  95. package/src/lib/server/membership-account.d.ts +22 -0
  96. package/src/lib/server/membership-account.js +52 -8
  97. package/src/lib/server/membership-account.js.map +1 -1
  98. package/src/lib/server/pos-auth.d.ts +3 -3
  99. package/src/lib/server/pos-auth.js +3 -3
  100. package/src/lib/server/pos-auth.js.map +1 -1
  101. package/src/lib/server/pos-cellular-billing.js +1 -1
  102. package/src/lib/server/pos-cellular-billing.js.map +1 -1
  103. package/src/lib/server/pos-cellular-notify.js +1 -1
  104. package/src/lib/server/pos-cellular-notify.js.map +1 -1
  105. package/src/lib/server/pos-cellular.js +1 -1
  106. package/src/lib/server/pos-cellular.js.map +1 -1
  107. package/src/lib/server/pos-hardware-admin.js +86 -13
  108. package/src/lib/server/pos-hardware-admin.js.map +1 -1
  109. package/src/lib/server/pos-hardware-attach.js +5 -5
  110. package/src/lib/server/pos-hardware-attach.js.map +1 -1
  111. package/src/lib/server/pos-hardware-cancel.js +65 -0
  112. package/src/lib/server/pos-hardware-cancel.js.map +1 -1
  113. package/src/lib/server/pos-hardware-closure-notices.js +2 -5
  114. package/src/lib/server/pos-hardware-closure-notices.js.map +1 -1
  115. package/src/lib/server/pos-hardware-closure.js +5 -8
  116. package/src/lib/server/pos-hardware-closure.js.map +1 -1
  117. package/src/lib/server/pos-hardware-in-person.d.ts +2 -1
  118. package/src/lib/server/pos-hardware-in-person.js +72 -17
  119. package/src/lib/server/pos-hardware-in-person.js.map +1 -1
  120. package/src/lib/server/pos-hardware-notify.d.ts +2 -0
  121. package/src/lib/server/pos-hardware-notify.js +30 -5
  122. package/src/lib/server/pos-hardware-notify.js.map +1 -1
  123. package/src/lib/server/pos-hardware-readers.d.ts +25 -0
  124. package/src/lib/server/pos-hardware-readers.js +206 -85
  125. package/src/lib/server/pos-hardware-readers.js.map +1 -1
  126. package/src/lib/server/pos-hardware-returns.d.ts +8 -3
  127. package/src/lib/server/pos-hardware-returns.js +39 -7
  128. package/src/lib/server/pos-hardware-returns.js.map +1 -1
  129. package/src/lib/server/pos-hardware-sale-fields.d.ts +76 -0
  130. package/src/lib/server/pos-hardware-sale-fields.js +114 -1
  131. package/src/lib/server/pos-hardware-sale-fields.js.map +1 -1
  132. package/src/lib/server/pos-hardware-sale.d.ts +2 -0
  133. package/src/lib/server/pos-hardware-sale.js +1 -0
  134. package/src/lib/server/pos-hardware-sale.js.map +1 -1
  135. package/src/lib/server/pos-hardware-tax-return-source.js +7 -4
  136. package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -1
  137. package/src/lib/server/pos-hardware-webhook.js +16 -3
  138. package/src/lib/server/pos-hardware-webhook.js.map +1 -1
  139. package/src/lib/server/pos-hardware.d.ts +14 -3
  140. package/src/lib/server/pos-hardware.js +83 -18
  141. package/src/lib/server/pos-hardware.js.map +1 -1
  142. package/src/lib/server/pos-ops-routes.js +2 -10
  143. package/src/lib/server/pos-ops-routes.js.map +1 -1
  144. package/src/lib/server/quote-pay.js +8 -4
  145. package/src/lib/server/quote-pay.js.map +1 -1
  146. package/src/lib/server/stream.d.ts +2 -0
  147. package/src/lib/server/stream.js +22 -2
  148. package/src/lib/server/stream.js.map +1 -1
  149. package/src/lib/server/tax-return-source.js +5 -1
  150. package/src/lib/server/tax-return-source.js.map +1 -1
  151. package/src/lib/server.js +2 -2
  152. package/src/lib/server.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/subscriptions-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport {\n Chip,\n List,\n ListItemButton,\n ListItemText,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n getAggregateFromServer,\n limit,\n orderBy,\n query,\n sum,\n count,\n where,\n type Firestore,\n} from 'firebase/firestore'\nimport { useSearchParams } from 'next/navigation'\nimport { useEffect, useRef, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreDoc,\n usePagedCollection,\n} from '@aglyn/tenant-feature-instance'\nimport CommerceStatTile from './commerce-stat-tile.component'\nimport SubscriptionDetailDialog, { type SubscriptionRow } from './subscription-detail-dialog.component'\n\nexport interface SubscriptionsCardProps {\n hostId: string\n}\n\n/** The query key that opens one subscription on arrival: the renewal notification's link. */\nexport const SUBSCRIPTIONS_SUBSCRIPTION_PARAM = 'subscription'\n\ntype SubscriptionFilter = (typeof CommerceModel.SUBSCRIPTION_FILTER_STATUSES)[number] | 'all'\n\nexport interface SubscriptionsSummary {\n monthlyRecurringCents: number\n payingCount: number\n trialCount: number\n pastDueCount: number\n}\n\n/**\n * The figures above the list, from aggregation queries: what a store with\n * thousands of subscribers pays for is a handful of index reads, never one\n * read per subscriber.\n *\n * Monthly recurring revenue is summed per billing interval, because a sum\n * cannot divide a yearly price by twelve on the way. Only LIVE-mode\n * subscriptions count: a test checkout is a rehearsal, and the order\n * analytics leave it out for the same reason (`order-analytics.ts`). A\n * subscription with no stored `interval` is left out of the figure rather\n * than guessed at; every sale since AGL-1732 stores one.\n */\nexport async function loadSubscriptionsSummary(\n firestore: Firestore,\n hostId: string,\n): Promise<SubscriptionsSummary> {\n const subscriptions = collection(firestore, 'hosts', hostId, 'subscriptions')\n const paying = (interval: CommerceModel.SubscriptionBillingInterval) =>\n getAggregateFromServer(\n query(\n subscriptions,\n where('status', 'in', [...CommerceModel.SUBSCRIPTION_PAYING_STATUSES]),\n where('interval', '==', interval),\n where('livemode', '==', true),\n ),\n {\n subscriptions: count(),\n totalCents: sum('totals.totalCents'),\n taxCents: sum('totals.taxCents'),\n },\n )\n const counted = (status: string) =>\n getAggregateFromServer(\n query(subscriptions, where('status', '==', status), where('livemode', '==', true)),\n { subscriptions: count() },\n )\n // AGL-1715-EXEMPT: four separate count queries, one per figure on the card;\n // the status words are each query's own filter, not a membership set.\n const [monthly, yearly, trials, pastDue] = await Promise.all([\n paying('month'),\n paying('year'),\n counted('trialing'),\n counted('past_due'),\n ])\n const figure = (value: unknown) => Number(value) || 0\n return {\n monthlyRecurringCents:\n CommerceModel.monthlyRecurringCents(\n monthly.data().totalCents,\n monthly.data().taxCents,\n 'month',\n ) +\n CommerceModel.monthlyRecurringCents(\n yearly.data().totalCents,\n yearly.data().taxCents,\n 'year',\n ),\n payingCount: figure(monthly.data().subscriptions) + figure(yearly.data().subscriptions),\n trialCount: figure(trials.data().subscriptions),\n pastDueCount: figure(pastDue.data().subscriptions),\n }\n}\n\n/**\n * Subscriptions (AGL-4191): every subscription on the site, newest first, and\n * what they add up to.\n *\n * Until this, a merchant could see subscriptions only one person at a time, in\n * a site member's Purchases: a digital or service subscription writes no order\n * per cycle, so Orders never showed them either.\n *\n * THE STATUS FILTER IS THE QUERY, as on Returns: `status == X` ordered by\n * `createdAtMs` descending, served by the `subscriptions(status ASC,\n * createdAtMs DESC)` composite; \"All\" is the single-field order alone. Opening\n * a row shows the subscription's invoices; `?subscription={id}` opens one on\n * arrival, which is where the renewal notification links.\n */\nexport function SubscriptionsCard(props: SubscriptionsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const [filter, setFilter] = useState<SubscriptionFilter>('all')\n const [selectedId, setSelectedId] = useState<string | null>(null)\n const [summary, setSummary] = useState<SubscriptionsSummary | null>(null)\n const [summaryFailed, setSummaryFailed] = useState(false)\n\n const { data: store } = useFirestoreDoc<Record<string, unknown>>(\n () => doc(firestore, 'hosts', hostId, 'settings', 'store'),\n [firestore, hostId],\n )\n const currency = String(store?.currency ?? 'USD').toUpperCase()\n const money = (cents: number) => CommerceModel.formatOrderMoney(cents, currency)\n\n useEffect(() => {\n let live = true\n setSummaryFailed(false)\n loadSubscriptionsSummary(firestore, hostId)\n .then((next) => {\n if (live) setSummary(next)\n })\n .catch((error) => {\n console.error('Subscriptions summary unavailable', error)\n if (live) setSummaryFailed(true)\n })\n return () => {\n live = false\n }\n }, [firestore, hostId])\n\n const {\n rows,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n status,\n } = usePagedCollection<SubscriptionRow>(\n (pageLimit) =>\n query(\n collection(firestore, 'hosts', hostId, 'subscriptions'),\n ...(filter === 'all' ? [] : [where('status', '==', filter)]),\n orderBy('createdAtMs', 'desc'),\n limit(pageLimit),\n ),\n [firestore, hostId, filter],\n { idField: '$id' },\n )\n\n const searchParams = useSearchParams()\n const seededId = searchParams?.get(SUBSCRIPTIONS_SUBSCRIPTION_PARAM) ?? null\n // Once per id, so closing the dialog does not reopen it on the next render.\n const seeded = useRef<string | null>(null)\n useEffect(() => {\n if (!seededId || seeded.current === seededId) return\n seeded.current = seededId\n setSelectedId(seededId)\n }, [seededId])\n\n // A linked subscription need not be on this page, so it is read by id.\n const onPage = selectedId ? (rows.find((row) => row.$id === selectedId) ?? null) : null\n const { data: linked } = useFirestoreDoc<Omit<SubscriptionRow, '$id'>>(\n () =>\n selectedId && !onPage\n ? doc(firestore, 'hosts', hostId, 'subscriptions', selectedId)\n : null,\n [firestore, hostId, selectedId, Boolean(onPage)],\n )\n const selected: SubscriptionRow | null =\n onPage ?? (selectedId && linked ? { ...linked, $id: selectedId } : null)\n\n return (\n <CardDisplay\n header={'Subscriptions'}\n help={pluginDocsHelp('catalog', { anchor: '#subscriptions-list' })}\n HeaderProps={{\n action: (\n <TextField\n label=\"Status\"\n value={filter}\n onChange={(event) => setFilter(event.target.value as SubscriptionFilter)}\n size=\"small\"\n select\n sx={{ minWidth: 160 }}\n >\n <MenuItem value=\"all\">{'All'}</MenuItem>\n {CommerceModel.SUBSCRIPTION_FILTER_STATUSES.map((value) => (\n <MenuItem key={value} value={value}>\n {CommerceModel.subscriptionStatusLabel(value)}\n </MenuItem>\n ))}\n </TextField>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <Stack direction=\"row\" useFlexGap sx={{ flexWrap: 'wrap', columnGap: 4, rowGap: 1.5 }}>\n <CommerceStatTile\n label=\"Monthly recurring revenue\"\n value={summary ? money(summary.monthlyRecurringCents) : summaryFailed ? '—' : '…'}\n />\n <CommerceStatTile\n label=\"Paying subscribers\"\n value={summary ? String(summary.payingCount) : summaryFailed ? '—' : '…'}\n />\n <CommerceStatTile\n label=\"In a free trial\"\n value={summary ? String(summary.trialCount) : summaryFailed ? '—' : '…'}\n />\n <CommerceStatTile\n label=\"Past due\"\n value={summary ? String(summary.pastDueCount) : summaryFailed ? '—' : '…'}\n />\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {summaryFailed\n ? 'These figures could not be loaded. The list below is unaffected.'\n : 'Monthly recurring revenue counts active and past-due subscriptions paid in live mode, with a yearly plan counted as a twelfth and tax left out.'}\n </Typography>\n {rows.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {status === 'error'\n ? // The rules gate subscriptions on the order book's permission.\n 'Subscriptions take the \"See orders and webhooks\" permission on this site.'\n : status === 'loading'\n ? 'Loading subscriptions…'\n : filter === 'all'\n ? 'No subscriptions yet. When someone subscribes to a monthly or yearly product, they appear here.'\n : `No ${CommerceModel.subscriptionStatusLabel(filter).toLowerCase()} subscriptions.`}\n </Typography>\n ) : (\n <List disablePadding>\n {rows.map((row) => {\n const dateText = CommerceModel.subscriptionDateText(\n CommerceModel.subscriptionDateLine(row),\n )\n const price =\n row.totals?.totalCents != null\n ? `${money(Number(row.totals.totalCents) || 0)}${CommerceModel.subscriptionIntervalSuffix(row.interval)}`\n : ''\n const paid =\n Number(row.invoicesCount ?? 0) > 0\n ? `${money(Number(row.paidCents) || 0)} paid so far`\n : ''\n return (\n <ListItemButton key={row.$id} onClick={() => setSelectedId(row.$id)} divider>\n <ListItemText\n primary={`${row.customerName || row.customerEmail || 'Unknown customer'} · ${CommerceModel.subscriptionPlanName(row)}`}\n secondary={[price, dateText, paid].filter(Boolean).join(' · ')}\n />\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexShrink: 0 }}>\n {row.livemode === false ? (\n <Chip label=\"Test\" size=\"small\" variant=\"outlined\" />\n ) : null}\n <Chip\n label={CommerceModel.subscriptionStatusLabel(row.status)}\n size=\"small\"\n color={CommerceModel.subscriptionStatusColor(row.status)}\n variant=\"outlined\"\n />\n </Stack>\n </ListItemButton>\n )\n })}\n </List>\n )}\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={rows.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n </Stack>\n {selected ? (\n <SubscriptionDetailDialog\n hostId={hostId}\n subscription={selected}\n currency={currency}\n onClose={() => setSelectedId(null)}\n />\n ) : null}\n </CardDisplay>\n )\n}\nSubscriptionsCard.displayName = 'SubscriptionsCard'\n\nexport default SubscriptionsCard\n"],"names":["CommerceModel","CardDisplay","ListPagination","pluginDocsHelp","Chip","List","ListItemButton","ListItemText","MenuItem","Stack","TextField","Typography","collection","doc","getAggregateFromServer","limit","orderBy","query","sum","count","where","useSearchParams","useEffect","useRef","useState","useFirestore","useFirestoreDoc","usePagedCollection","CommerceStatTile","SubscriptionDetailDialog","SUBSCRIPTIONS_SUBSCRIPTION_PARAM","loadSubscriptionsSummary","firestore","hostId","subscriptions","paying","interval","SUBSCRIPTION_PAYING_STATUSES","totalCents","taxCents","counted","status","monthly","yearly","trials","pastDue","Promise","all","figure","value","Number","monthlyRecurringCents","data","payingCount","trialCount","pastDueCount","SubscriptionsCard","props","rows","filter","setFilter","selectedId","setSelectedId","summary","setSummary","summaryFailed","setSummaryFailed","store","currency","String","toUpperCase","money","cents","formatOrderMoney","live","then","next","catch","error","console","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","searchParams","seededId","get","seeded","current","onPage","find","row","$id","linked","Boolean","selected","header","help","anchor","HeaderProps","action","label","onChange","event","target","size","select","sx","minWidth","SUBSCRIPTION_FILTER_STATUSES","map","subscriptionStatusLabel","contentGutterX","contentGutterY","spacing","direction","useFlexGap","flexWrap","columnGap","rowGap","variant","color","length","toLowerCase","disablePadding","dateText","subscriptionDateText","subscriptionDateLine","price","totals","subscriptionIntervalSuffix","paid","invoicesCount","paidCents","onClick","divider","primary","customerName","customerEmail","subscriptionPlanName","secondary","join","alignItems","flexShrink","livemode","subscriptionStatusColor","rowCount","onPageChange","onPageSizeChange","subscription","onClose","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,cAAc,QAAQ,eAAc;AAC7C,SACEC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,YAAY,EACZC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SACEC,UAAU,EACVC,GAAG,EACHC,sBAAsB,EACtBC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,KAAK,QAEA,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,kBAAiB;AACjD,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACnD,SACEC,YAAY,EACZC,eAAe,EACfC,kBAAkB,QACb,iCAAgC;AACvC,OAAOC,sBAAsB,oCAAgC;AAC7D,OAAOC,8BAAwD,4CAAwC;AAMvG,2FAA2F,GAC3F,OAAO,MAAMC,mCAAmC,eAAc;AAW9D;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,yBACpBC,SAAoB,EACpBC,MAAc;IAEd,MAAMC,gBAAgBtB,WAAWoB,WAAW,SAASC,QAAQ;IAC7D,MAAME,SAAS,CAACC,WACdtB,uBACEG,MACEiB,eACAd,MAAM,UAAU,MAAM;eAAIpB,cAAcqC,4BAA4B;SAAC,GACrEjB,MAAM,YAAY,MAAMgB,WACxBhB,MAAM,YAAY,MAAM,QAE1B;YACEc,eAAef;YACfmB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qD,QAAQ,KAAK,sBAChB,KAAC/I;gDAAKoG,OAAM;gDAAOI,MAAK;gDAAQe,SAAQ;iDACtC;0DACJ,KAACvH;gDACCoG,OAAOxG,cAAckH,uBAAuB,CAACpB,IAAIrD,MAAM;gDACvDmE,MAAK;gDACLgB,OAAO5H,cAAcoJ,uBAAuB,CAACtD,IAAIrD,MAAM;gDACvDkF,SAAQ;;;;;+BAbO7B,IAAIC,GAAG;wBAkBhC;;kCAGJ,KAAC7F;wBACC+E,MAAMA;wBACNE,UAAUA;wBACVkE,UAAU3F,KAAKmE,MAAM;wBACrB7C,SAASA;wBACTsE,cAAcpE;wBACdqE,kBAAkBnE;;;;YAGrBc,yBACC,KAACrE;gBACCI,QAAQA;gBACRuH,cAActD;gBACd9B,UAAUA;gBACVqF,SAAS,IAAM3F,cAAc;iBAE7B;;;AAGV;AACAN,kBAAkBkG,WAAW,GAAG;AAEhC,eAAelG,kBAAiB"}
@@ -0,0 +1,22 @@
1
+ /** The two answers a checkout of card reader hardware carries (AGL-4038). */
2
+ export interface HardwareTermsAnswer {
3
+ accepted: boolean;
4
+ businessUse: boolean;
5
+ }
6
+ export declare const NO_HARDWARE_TERMS_ANSWER: HardwareTermsAnswer;
7
+ /** Whether both boxes are ticked, so the checkout will be taken. */
8
+ export declare function hardwareTermsAnswered(answer: HardwareTermsAnswer): boolean;
9
+ /**
10
+ * THE TERMS OF SALE AT AN ONLINE CHECKOUT OF CARD READER HARDWARE (AGL-4038).
11
+ *
12
+ * Shown in the cart, and on a product page after its checkout asked for it,
13
+ * when the store selling is the platform's own and the order holds a card
14
+ * reader or an accessory: the buyer accepts the terms of sale (Terms,
15
+ * Sections 4.26–4.32, linked) and confirms they are buying for use in their
16
+ * business. The server refuses the checkout without both; these boxes are
17
+ * how the buyer gives them.
18
+ */
19
+ export declare function HardwareTermsConsent(props: {
20
+ answer: HardwareTermsAnswer;
21
+ onChange: (answer: HardwareTermsAnswer) => void;
22
+ }): import("react").JSX.Element;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
+ import Checkbox from "@mui/material/Checkbox";
20
+ import FormControlLabel from "@mui/material/FormControlLabel";
21
+ import Link from "@mui/material/Link";
22
+ import Stack from "@mui/material/Stack";
23
+ import Typography from "@mui/material/Typography";
24
+ import { POS_HARDWARE_TERMS_SECTIONS, posHardwareTermsUrl } from "../model/pos-hardware-terms.js";
25
+ export const NO_HARDWARE_TERMS_ANSWER = {
26
+ accepted: false,
27
+ businessUse: false
28
+ };
29
+ /** Whether both boxes are ticked, so the checkout will be taken. */ export function hardwareTermsAnswered(answer) {
30
+ return answer.accepted && answer.businessUse;
31
+ }
32
+ /**
33
+ * THE TERMS OF SALE AT AN ONLINE CHECKOUT OF CARD READER HARDWARE (AGL-4038).
34
+ *
35
+ * Shown in the cart, and on a product page after its checkout asked for it,
36
+ * when the store selling is the platform's own and the order holds a card
37
+ * reader or an accessory: the buyer accepts the terms of sale (Terms,
38
+ * Sections 4.26–4.32, linked) and confirms they are buying for use in their
39
+ * business. The server refuses the checkout without both; these boxes are
40
+ * how the buyer gives them.
41
+ */ export function HardwareTermsConsent(props) {
42
+ const { answer, onChange } = props;
43
+ return /*#__PURE__*/ _jsxs(Stack, {
44
+ "data-testid": "hardware-terms-consent",
45
+ children: [
46
+ /*#__PURE__*/ _jsx(FormControlLabel, {
47
+ control: /*#__PURE__*/ _jsx(Checkbox, {
48
+ size: "small",
49
+ checked: answer.accepted,
50
+ onChange: (event)=>onChange(_extends({}, answer, {
51
+ accepted: event.target.checked
52
+ }))
53
+ }),
54
+ label: /*#__PURE__*/ _jsxs(Typography, {
55
+ variant: "body2",
56
+ children: [
57
+ 'I accept the ',
58
+ /*#__PURE__*/ _jsx(Link, {
59
+ href: posHardwareTermsUrl(),
60
+ target: "_blank",
61
+ rel: "noopener noreferrer",
62
+ children: `hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS})`
63
+ }),
64
+ '.'
65
+ ]
66
+ })
67
+ }),
68
+ /*#__PURE__*/ _jsx(FormControlLabel, {
69
+ control: /*#__PURE__*/ _jsx(Checkbox, {
70
+ size: "small",
71
+ checked: answer.businessUse,
72
+ onChange: (event)=>onChange(_extends({}, answer, {
73
+ businessUse: event.target.checked
74
+ }))
75
+ }),
76
+ label: /*#__PURE__*/ _jsx(Typography, {
77
+ variant: "body2",
78
+ children: 'I am buying this hardware for use in my business.'
79
+ })
80
+ })
81
+ ]
82
+ });
83
+ }
84
+
85
+ //# sourceMappingURL=hardware-terms-consent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/hardware-terms-consent.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport Checkbox from '@mui/material/Checkbox'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport Link from '@mui/material/Link'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport { POS_HARDWARE_TERMS_SECTIONS, posHardwareTermsUrl } from '../model/pos-hardware-terms'\n\n/** The two answers a checkout of card reader hardware carries (AGL-4038). */\nexport interface HardwareTermsAnswer {\n accepted: boolean\n businessUse: boolean\n}\n\nexport const NO_HARDWARE_TERMS_ANSWER: HardwareTermsAnswer = { accepted: false, businessUse: false }\n\n/** Whether both boxes are ticked, so the checkout will be taken. */\nexport function hardwareTermsAnswered(answer: HardwareTermsAnswer): boolean {\n return answer.accepted && answer.businessUse\n}\n\n/**\n * THE TERMS OF SALE AT AN ONLINE CHECKOUT OF CARD READER HARDWARE (AGL-4038).\n *\n * Shown in the cart, and on a product page after its checkout asked for it,\n * when the store selling is the platform's own and the order holds a card\n * reader or an accessory: the buyer accepts the terms of sale (Terms,\n * Sections 4.26–4.32, linked) and confirms they are buying for use in their\n * business. The server refuses the checkout without both; these boxes are\n * how the buyer gives them.\n */\nexport function HardwareTermsConsent(props: {\n answer: HardwareTermsAnswer\n onChange: (answer: HardwareTermsAnswer) => void\n}) {\n const { answer, onChange } = props\n return (\n <Stack data-testid=\"hardware-terms-consent\">\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={answer.accepted}\n onChange={(event) => onChange({ ...answer, accepted: event.target.checked })}\n />\n }\n label={\n <Typography variant=\"body2\">\n {'I accept the '}\n <Link href={posHardwareTermsUrl()} target=\"_blank\" rel=\"noopener noreferrer\">\n {`hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS})`}\n </Link>\n {'.'}\n </Typography>\n }\n />\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={answer.businessUse}\n onChange={(event) => onChange({ ...answer, businessUse: event.target.checked })}\n />\n }\n label={<Typography variant=\"body2\">{'I am buying this hardware for use in my business.'}</Typography>}\n />\n </Stack>\n )\n}\n"],"names":["Checkbox","FormControlLabel","Link","Stack","Typography","POS_HARDWARE_TERMS_SECTIONS","posHardwareTermsUrl","NO_HARDWARE_TERMS_ANSWER","accepted","businessUse","hardwareTermsAnswered","answer","HardwareTermsConsent","props","onChange","data-testid","control","size","checked","event","target","label","variant","href","rel"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,OAAOA,cAAc,yBAAwB;AAC7C,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,iCAA6B;AAQ9F,OAAO,MAAMC,2BAAgD;IAAEC,UAAU;IAAOC,aAAa;AAAM,EAAC;AAEpG,kEAAkE,GAClE,OAAO,SAASC,sBAAsBC,MAA2B;IAC/D,OAAOA,OAAOH,QAAQ,IAAIG,OAAOF,WAAW;AAC9C;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASG,qBAAqBC,KAGpC;IACC,MAAM,EAAEF,MAAM,EAAEG,QAAQ,EAAE,GAAGD;IAC7B,qBACE,MAACV;QAAMY,eAAY;;0BACjB,KAACd;gBACCe,uBACE,KAAChB;oBACCiB,MAAK;oBACLC,SAASP,OAAOH,QAAQ;oBACxBM,UAAU,CAACK,QAAUL,SAAS,aAAKH;4BAAQH,UAAUW,MAAMC,MAAM,CAACF,OAAO;;;gBAG7EG,qBACE,MAACjB;oBAAWkB,SAAQ;;wBACjB;sCACD,KAACpB;4BAAKqB,MAAMjB;4BAAuBc,QAAO;4BAASI,KAAI;sCACpD,CAAC,wCAAwC,EAAEnB,4BAA4B,CAAC,CAAC;;wBAE3E;;;;0BAIP,KAACJ;gBACCe,uBACE,KAAChB;oBACCiB,MAAK;oBACLC,SAASP,OAAOF,WAAW;oBAC3BK,UAAU,CAACK,QAAUL,SAAS,aAAKH;4BAAQF,aAAaU,MAAMC,MAAM,CAACF,OAAO;;;gBAGhFG,qBAAO,KAACjB;oBAAWkB,SAAQ;8BAAS;;;;;AAI5C"}
@@ -43,6 +43,7 @@ import { generatePresetId } from "../utils/generate-preset-id.js";
43
43
  import { useStorefrontPurchaseEvent } from "../utils/use-storefront-purchase-event.js";
44
44
  import { addToCart } from "../utils/add-to-cart.js";
45
45
  import { CartFulfillmentChoice, useCartFulfillment } from "./cart-fulfillment.js";
46
+ import { HardwareTermsConsent, hardwareTermsAnswered, NO_HARDWARE_TERMS_ANSWER } from "./hardware-terms-consent.js";
46
47
  import { ID as PRODUCT_REVIEWS_ID } from "./product-reviews.js";
47
48
  import { ID as RELATED_PRODUCTS_ID } from "./related-products.js";
48
49
  import { readLocalWishlist, toggleWishlist } from "./wishlist.js";
@@ -306,6 +307,10 @@ function slugFromLocation() {
306
307
  // because every further click gets the identical refusal.
307
308
  const [status, setStatus] = useState('idle');
308
309
  const [message, setMessage] = useState('');
310
+ // The terms of sale and business use, once a checkout of card reader
311
+ // hardware asked for them (AGL-4038).
312
+ const [hardwareTerms, setHardwareTerms] = useState(NO_HARDWARE_TERMS_ANSWER);
313
+ const [hardwareTermsAsked, setHardwareTermsAsked] = useState(false);
309
314
  // Buy-now's half of AGL-1721: asked only when the server refuses to price
310
315
  // shipping without a destination, so a digital product, a subscription, or
311
316
  // a merchant whose rates are the same everywhere never shows it. `null` is
@@ -502,6 +507,8 @@ function slugFromLocation() {
502
507
  fulfillment: fulfillment.request
503
508
  } : {}, coupon.trim() ? {
504
509
  couponCode: coupon.trim()
510
+ } : {}, hardwareTermsAsked ? {
511
+ hardwareTerms
505
512
  } : {}, advertisingConsentField(hostId)))
506
513
  });
507
514
  const payload = await response.json().catch(()=>({}));
@@ -547,12 +554,20 @@ function slugFromLocation() {
547
554
  window.location.assign(payload.url);
548
555
  return;
549
556
  }
557
+ // Card reader hardware needs the terms of sale ticked (AGL-4038).
558
+ if (payload == null ? void 0 : payload.needsHardwareTerms) {
559
+ var _ref2;
560
+ setHardwareTermsAsked(true);
561
+ setMessage(String((_ref2 = payload == null ? void 0 : payload.error) != null ? _ref2 : ''));
562
+ setStatus('ask');
563
+ return;
564
+ }
550
565
  // Buy-now's half of AGL-2019. The server's own 501 wording is not
551
566
  // rendered to a visitor; this surface is public.
552
567
  if (payload == null ? void 0 : payload.fulfillmentChanged) {
553
- var _ref2;
568
+ var _ref3;
554
569
  fulfillment.reload();
555
- setMessage(String((_ref2 = payload == null ? void 0 : payload.error) != null ? _ref2 : ''));
570
+ setMessage(String((_ref3 = payload == null ? void 0 : payload.error) != null ? _ref3 : ''));
556
571
  setStatus('error');
557
572
  return;
558
573
  }
@@ -562,13 +577,13 @@ function slugFromLocation() {
562
577
  return;
563
578
  }
564
579
  if (payload == null ? void 0 : payload.needsShippingCountry) {
565
- var _ref3;
580
+ var _ref4;
566
581
  var _payload_shippingCountries;
567
582
  if (payload == null ? void 0 : payload.needsShippingPostalCode) setAskPostal(true);
568
583
  setShipCountries(((_payload_shippingCountries = payload.shippingCountries) == null ? void 0 : _payload_shippingCountries.length) ? payload.shippingCountries : [
569
584
  ...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES
570
585
  ]);
571
- setMessage(String((_ref3 = payload == null ? void 0 : payload.error) != null ? _ref3 : ''));
586
+ setMessage(String((_ref4 = payload == null ? void 0 : payload.error) != null ? _ref4 : ''));
572
587
  // An unserved destination is a refusal and reads as one; being
573
588
  // asked the first time is not.
574
589
  setStatus(shipTo ? 'error' : 'ask');
@@ -977,7 +992,8 @@ function slugFromLocation() {
977
992
  // the control latches off rather than inviting a retry that
978
993
  // cannot succeed (AGL-2019).
979
994
  status === 'unconfigured' || // Asked but unanswered: the server would only refuse again.
980
- fulfillment.method === 'shipping' && shipCountries !== null && !shipTo || fulfillment.method === 'shipping' && askPostal && !shipPostal.trim() || !fulfillment.ready,
995
+ fulfillment.method === 'shipping' && shipCountries !== null && !shipTo || fulfillment.method === 'shipping' && askPostal && !shipPostal.trim() || !fulfillment.ready || // Card reader hardware: both boxes ticked (AGL-4038).
996
+ hardwareTermsAsked && !hardwareTermsAnswered(hardwareTerms),
981
997
  onClick: handleBuy,
982
998
  sx: {
983
999
  flex: 1
@@ -1079,6 +1095,10 @@ function slugFromLocation() {
1079
1095
  mb: 2
1080
1096
  }
1081
1097
  }) : null,
1098
+ hardwareTermsAsked ? /*#__PURE__*/ _jsx(HardwareTermsConsent, {
1099
+ answer: hardwareTerms,
1100
+ onChange: setHardwareTerms
1101
+ }) : null,
1082
1102
  status === 'ask' || status === 'unconfigured' ? /*#__PURE__*/ _jsx(Alert, {
1083
1103
  severity: "info",
1084
1104
  sx: {