@aglyn/plugins-commerce 1.29.1 → 1.29.3

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 (89) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/checkout-tax-blocked-notice.component.d.ts +18 -0
  3. package/src/lib/components/console/checkout-tax-blocked-notice.component.js +67 -0
  4. package/src/lib/components/console/checkout-tax-blocked-notice.component.js.map +1 -0
  5. package/src/lib/components/console/payments-settings-card.component.d.ts +2 -2
  6. package/src/lib/components/console/payments-settings-card.component.js +99 -5
  7. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  8. package/src/lib/components/console/product-editor-dialog.component.js +14 -3
  9. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  10. package/src/lib/components/console/products-hub-card.component.js +51 -14
  11. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  12. package/src/lib/components/console/stripe-tax-readiness.component.d.ts +45 -0
  13. package/src/lib/components/console/stripe-tax-readiness.component.js +276 -0
  14. package/src/lib/components/console/stripe-tax-readiness.component.js.map +1 -0
  15. package/src/lib/components/console/tax-settings-card.component.js +22 -8
  16. package/src/lib/components/console/tax-settings-card.component.js.map +1 -1
  17. package/src/lib/constants/operator-alerts.d.ts +9 -0
  18. package/src/lib/constants/operator-alerts.js +22 -1
  19. package/src/lib/constants/operator-alerts.js.map +1 -1
  20. package/src/lib/declarations.server.js +11 -0
  21. package/src/lib/declarations.server.js.map +1 -1
  22. package/src/lib/model/commerce-record-routes.d.ts +13 -1
  23. package/src/lib/model/commerce-record-routes.js +22 -2
  24. package/src/lib/model/commerce-record-routes.js.map +1 -1
  25. package/src/lib/model/commerce-tax-readiness.d.ts +79 -0
  26. package/src/lib/model/commerce-tax-readiness.js +99 -0
  27. package/src/lib/model/commerce-tax-readiness.js.map +1 -0
  28. package/src/lib/model/commerce.d.ts +7 -0
  29. package/src/lib/model/commerce.js +17 -4
  30. package/src/lib/model/commerce.js.map +1 -1
  31. package/src/lib/model/payments-setup-status.d.ts +68 -0
  32. package/src/lib/model/payments-setup-status.js +103 -0
  33. package/src/lib/model/payments-setup-status.js.map +1 -0
  34. package/src/lib/plan-entitlements.d.ts +2 -2
  35. package/src/lib/plan-entitlements.js +4 -12
  36. package/src/lib/plan-entitlements.js.map +1 -1
  37. package/src/lib/server/cart-checkout.js +3 -0
  38. package/src/lib/server/cart-checkout.js.map +1 -1
  39. package/src/lib/server/checkout-tax-refusal.d.ts +51 -0
  40. package/src/lib/server/checkout-tax-refusal.js +133 -0
  41. package/src/lib/server/checkout-tax-refusal.js.map +1 -0
  42. package/src/lib/server/checkout.d.ts +2 -1
  43. package/src/lib/server/checkout.js +7 -2
  44. package/src/lib/server/checkout.js.map +1 -1
  45. package/src/lib/server/connect-prefill.d.ts +65 -0
  46. package/src/lib/server/connect-prefill.js +85 -0
  47. package/src/lib/server/connect-prefill.js.map +1 -0
  48. package/src/lib/server/connect.d.ts +4 -2
  49. package/src/lib/server/connect.js +117 -37
  50. package/src/lib/server/connect.js.map +1 -1
  51. package/src/lib/server/draft-order.js +4 -2
  52. package/src/lib/server/draft-order.js.map +1 -1
  53. package/src/lib/server/pos-order.js +1 -1
  54. package/src/lib/server/pos-order.js.map +1 -1
  55. package/src/lib/server/product-writer.d.ts +27 -0
  56. package/src/lib/server/product-writer.js +174 -4
  57. package/src/lib/server/product-writer.js.map +1 -1
  58. package/src/lib/server/quote-pay.d.ts +6 -0
  59. package/src/lib/server/quote-pay.js +8 -2
  60. package/src/lib/server/quote-pay.js.map +1 -1
  61. package/src/lib/server/seller-stripe-account.d.ts +19 -0
  62. package/src/lib/server/seller-stripe-account.js +40 -4
  63. package/src/lib/server/seller-stripe-account.js.map +1 -1
  64. package/src/lib/server/site-page-resolver.d.ts +11 -5
  65. package/src/lib/server/site-page-resolver.js +102 -19
  66. package/src/lib/server/site-page-resolver.js.map +1 -1
  67. package/src/lib/server/site-search.d.ts +43 -0
  68. package/src/lib/server/site-search.js +124 -0
  69. package/src/lib/server/site-search.js.map +1 -0
  70. package/src/lib/server/tax-readiness.d.ts +56 -0
  71. package/src/lib/server/tax-readiness.js +169 -0
  72. package/src/lib/server/tax-readiness.js.map +1 -0
  73. package/src/lib/server.js +10 -2
  74. package/src/lib/server.js.map +1 -1
  75. package/src/lib/transfer/product-image-copy.server.d.ts +77 -0
  76. package/src/lib/transfer/product-image-copy.server.js +307 -0
  77. package/src/lib/transfer/product-image-copy.server.js.map +1 -0
  78. package/src/lib/transfer/product-images.d.ts +62 -0
  79. package/src/lib/transfer/product-images.js +143 -0
  80. package/src/lib/transfer/product-images.js.map +1 -0
  81. package/src/lib/transfer/product-sources.d.ts +92 -0
  82. package/src/lib/transfer/product-sources.js +519 -0
  83. package/src/lib/transfer/product-sources.js.map +1 -0
  84. package/src/lib/transfer/product-transfer.d.ts +26 -1
  85. package/src/lib/transfer/product-transfer.js +283 -11
  86. package/src/lib/transfer/product-transfer.js.map +1 -1
  87. package/src/lib/transfer/products.server.d.ts +29 -3
  88. package/src/lib/transfer/products.server.js +289 -13
  89. package/src/lib/transfer/products.server.js.map +1 -1
@@ -0,0 +1,51 @@
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
+ */
17
+ import { notifyHostManagers, raiseOperatorAlert } from '@aglyn/tenant-data-admin';
18
+ import { type CheckoutTaxBlock } from '../model/commerce-tax-readiness';
19
+ export declare const CHECKOUT_TAX_REFUSAL_DOC = "taxCheckoutRefusal";
20
+ export declare const CHECKOUT_TAX_REFUSAL_RETELL_MS: number;
21
+ /** The marker, as stored. */
22
+ export interface CheckoutTaxRefusalRecord {
23
+ reason: CheckoutTaxBlock;
24
+ firstAtMs: number;
25
+ lastAtMs: number;
26
+ count: number;
27
+ }
28
+ export interface CheckoutTaxRefusalDeps {
29
+ firestore(): FirebaseFirestore.Firestore;
30
+ notifyManagers: typeof notifyHostManagers;
31
+ raiseAlert: typeof raiseOperatorAlert;
32
+ now(): number;
33
+ }
34
+ /** Whether a refusal starts a new episode: the marker is gone, for another reason, or long quiet. */
35
+ export declare function isNewCheckoutTaxRefusal(existing: Partial<CheckoutTaxRefusalRecord> | null | undefined, reason: CheckoutTaxBlock, nowMs: number): boolean;
36
+ /**
37
+ * Records one refused checkout and, when it starts an episode, tells the
38
+ * site's managers and the operator. Never throws and never delays the
39
+ * refusal: callers `void` it beside the 409 they return.
40
+ */
41
+ export declare function reportCheckoutTaxRefusal(hostId: string, reason: CheckoutTaxBlock, deps?: CheckoutTaxRefusalDeps): Promise<'told' | 'counted' | 'failed'>;
42
+ /**
43
+ * {@link reportCheckoutTaxRefusal} for a checkout route: started beside the
44
+ * refusal it reports and kept alive past the response, so the 409 goes out
45
+ * at once and the report still finishes.
46
+ */
47
+ export declare function tellCheckoutTaxRefusal(hostId: string, reason: CheckoutTaxBlock): void;
48
+ /** The marker's last refusal for `reason`, or null. Never throws. */
49
+ export declare function readCheckoutTaxRefusal(firestore: FirebaseFirestore.Firestore, hostId: string): Promise<CheckoutTaxRefusalRecord | null>;
50
+ /** Drops the marker, so the next refusal tells the owner again. Never throws. */
51
+ export declare function clearCheckoutTaxRefusal(firestore: FirebaseFirestore.Firestore, hostId: string): Promise<void>;
@@ -0,0 +1,133 @@
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
+ */ import { firebaseAdmin, hostDisplayName, notifyHostManagers, raiseOperatorAlert } from "@aglyn/tenant-data-admin";
17
+ import { keepAlive } from "@aglyn/tenant-data-admin/server/keep-alive";
18
+ import { COMMERCE_CHECKOUT_TAX_SETUP_REFUSED } from "../constants/operator-alerts.js";
19
+ import { checkoutTaxRefusalNotice } from "../model/commerce-tax-readiness.js";
20
+ /*==========================================
21
+ * TELLING THE OWNER A SHOPPER WAS REFUSED FOR TAX (AGL-4245)
22
+ *
23
+ * Checkout refuses every shopper of a store whose sales tax is not set up,
24
+ * and until this the shopper was the only one who knew. A refusal now writes
25
+ * one marker per store, `hosts/{hostId}/settings/taxCheckoutRefusal`, in a
26
+ * transaction, and the raise that CREATES it tells the site's managers and
27
+ * raises the operator alert. Every later refusal for the same reason only
28
+ * counts, so a busy store's owner is told once, not once per shopper.
29
+ *
30
+ * The marker goes when the console's readiness route reads the store as no
31
+ * longer blocked (a mode chosen, Stripe Tax on), so a store that breaks again
32
+ * later is told again. A marker whose last refusal is older than
33
+ * `CHECKOUT_TAX_REFUSAL_RETELL_MS` counts as a new episode too: an owner who
34
+ * fixed it in Stripe without opening the console leaves the marker behind,
35
+ * and it must not silence the next time.
36
+ *=========================================*/ export const CHECKOUT_TAX_REFUSAL_DOC = 'taxCheckoutRefusal';
37
+ export const CHECKOUT_TAX_REFUSAL_RETELL_MS = 14 * 24 * 60 * 60 * 1000;
38
+ const defaultDeps = ()=>({
39
+ firestore: ()=>firebaseAdmin.app().firestore(),
40
+ notifyManagers: notifyHostManagers,
41
+ raiseAlert: raiseOperatorAlert,
42
+ now: ()=>Date.now()
43
+ });
44
+ const markerRef = (firestore, hostId)=>firestore.collection('hosts').doc(hostId).collection('settings').doc(CHECKOUT_TAX_REFUSAL_DOC);
45
+ /** Whether a refusal starts a new episode: the marker is gone, for another reason, or long quiet. */ export function isNewCheckoutTaxRefusal(existing, reason, nowMs) {
46
+ if (!existing || existing.reason !== reason) return true;
47
+ const last = Number(existing.lastAtMs);
48
+ return !Number.isFinite(last) || nowMs - last >= CHECKOUT_TAX_REFUSAL_RETELL_MS;
49
+ }
50
+ const REASON_FOR_STAFF = {
51
+ 'tax-undecided': 'the store has not chosen how it handles sales tax',
52
+ 'stripe-tax-not-active': 'the store chose Stripe Tax and Stripe Tax is not on in its own Stripe account'
53
+ };
54
+ /**
55
+ * Records one refused checkout and, when it starts an episode, tells the
56
+ * site's managers and the operator. Never throws and never delays the
57
+ * refusal: callers `void` it beside the 409 they return.
58
+ */ export async function reportCheckoutTaxRefusal(hostId, reason, deps = defaultDeps()) {
59
+ try {
60
+ if (!hostId) return 'failed';
61
+ const firestore = deps.firestore();
62
+ const ref = markerRef(firestore, hostId);
63
+ const nowMs = deps.now();
64
+ const started = await firestore.runTransaction(async (transaction)=>{
65
+ const snapshot = await transaction.get(ref);
66
+ const existing = snapshot.exists ? snapshot.data() : null;
67
+ if (isNewCheckoutTaxRefusal(existing, reason, nowMs)) {
68
+ const record = {
69
+ reason,
70
+ firstAtMs: nowMs,
71
+ lastAtMs: nowMs,
72
+ count: 1
73
+ };
74
+ transaction.set(ref, record);
75
+ return record;
76
+ }
77
+ transaction.set(ref, {
78
+ lastAtMs: nowMs,
79
+ count: Math.max(0, Number(existing == null ? void 0 : existing.count) || 0) + 1
80
+ }, {
81
+ merge: true
82
+ });
83
+ return null;
84
+ });
85
+ if (!started) return 'counted';
86
+ const notice = checkoutTaxRefusalNotice(reason);
87
+ await deps.notifyManagers(hostId, {
88
+ type: 'content.order',
89
+ level: 'warning',
90
+ title: notice.title,
91
+ body: notice.body,
92
+ link: `/${hostId}/products/taxes`
93
+ });
94
+ const host = await firestore.collection('hosts').doc(hostId).get().catch(()=>null);
95
+ const site = (host == null ? void 0 : host.exists) ? hostDisplayName(host.data(), hostId) : hostId;
96
+ await deps.raiseAlert(COMMERCE_CHECKOUT_TAX_SETUP_REFUSED, {
97
+ dedupeKey: `${hostId}:${reason}:${started.firstAtMs}`,
98
+ hostId,
99
+ context: {
100
+ site: `${site} (${hostId})`,
101
+ reason: REASON_FOR_STAFF[reason]
102
+ }
103
+ });
104
+ return 'told';
105
+ } catch (error) {
106
+ console.error('[commerce] checkout tax refusal report failed', hostId, reason, error);
107
+ return 'failed';
108
+ }
109
+ }
110
+ /**
111
+ * {@link reportCheckoutTaxRefusal} for a checkout route: started beside the
112
+ * refusal it reports and kept alive past the response, so the 409 goes out
113
+ * at once and the report still finishes.
114
+ */ export function tellCheckoutTaxRefusal(hostId, reason) {
115
+ void keepAlive(reportCheckoutTaxRefusal(hostId, reason));
116
+ }
117
+ /** The marker's last refusal for `reason`, or null. Never throws. */ export async function readCheckoutTaxRefusal(firestore, hostId) {
118
+ try {
119
+ const snapshot = await markerRef(firestore, hostId).get();
120
+ return snapshot.exists ? snapshot.data() : null;
121
+ } catch (unused) {
122
+ return null;
123
+ }
124
+ }
125
+ /** Drops the marker, so the next refusal tells the owner again. Never throws. */ export async function clearCheckoutTaxRefusal(firestore, hostId) {
126
+ try {
127
+ await markerRef(firestore, hostId).delete();
128
+ } catch (error) {
129
+ console.error('[commerce] checkout tax refusal clear failed', hostId, error);
130
+ }
131
+ }
132
+
133
+ //# sourceMappingURL=checkout-tax-refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/checkout-tax-refusal.ts"],"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\nimport {\n firebaseAdmin,\n hostDisplayName,\n notifyHostManagers,\n raiseOperatorAlert,\n} from '@aglyn/tenant-data-admin'\nimport { keepAlive } from '@aglyn/tenant-data-admin/server/keep-alive'\nimport { COMMERCE_CHECKOUT_TAX_SETUP_REFUSED } from '../constants/operator-alerts'\nimport {\n type CheckoutTaxBlock,\n checkoutTaxRefusalNotice,\n} from '../model/commerce-tax-readiness'\n\n/*==========================================\n * TELLING THE OWNER A SHOPPER WAS REFUSED FOR TAX (AGL-4245)\n *\n * Checkout refuses every shopper of a store whose sales tax is not set up,\n * and until this the shopper was the only one who knew. A refusal now writes\n * one marker per store, `hosts/{hostId}/settings/taxCheckoutRefusal`, in a\n * transaction, and the raise that CREATES it tells the site's managers and\n * raises the operator alert. Every later refusal for the same reason only\n * counts, so a busy store's owner is told once, not once per shopper.\n *\n * The marker goes when the console's readiness route reads the store as no\n * longer blocked (a mode chosen, Stripe Tax on), so a store that breaks again\n * later is told again. A marker whose last refusal is older than\n * `CHECKOUT_TAX_REFUSAL_RETELL_MS` counts as a new episode too: an owner who\n * fixed it in Stripe without opening the console leaves the marker behind,\n * and it must not silence the next time.\n *=========================================*/\n\nexport const CHECKOUT_TAX_REFUSAL_DOC = 'taxCheckoutRefusal'\nexport const CHECKOUT_TAX_REFUSAL_RETELL_MS = 14 * 24 * 60 * 60 * 1000\n\n/** The marker, as stored. */\nexport interface CheckoutTaxRefusalRecord {\n reason: CheckoutTaxBlock\n firstAtMs: number\n lastAtMs: number\n count: number\n}\n\nexport interface CheckoutTaxRefusalDeps {\n firestore(): FirebaseFirestore.Firestore\n notifyManagers: typeof notifyHostManagers\n raiseAlert: typeof raiseOperatorAlert\n now(): number\n}\n\nconst defaultDeps = (): CheckoutTaxRefusalDeps => ({\n firestore: () => firebaseAdmin.app().firestore(),\n notifyManagers: notifyHostManagers,\n raiseAlert: raiseOperatorAlert,\n now: () => Date.now(),\n})\n\nconst markerRef = (firestore: FirebaseFirestore.Firestore, hostId: string) =>\n firestore.collection('hosts').doc(hostId).collection('settings').doc(CHECKOUT_TAX_REFUSAL_DOC)\n\n/** Whether a refusal starts a new episode: the marker is gone, for another reason, or long quiet. */\nexport function isNewCheckoutTaxRefusal(\n existing: Partial<CheckoutTaxRefusalRecord> | null | undefined,\n reason: CheckoutTaxBlock,\n nowMs: number,\n): boolean {\n if (!existing || existing.reason !== reason) return true\n const last = Number(existing.lastAtMs)\n return !Number.isFinite(last) || nowMs - last >= CHECKOUT_TAX_REFUSAL_RETELL_MS\n}\n\nconst REASON_FOR_STAFF: Readonly<Record<CheckoutTaxBlock, string>> = {\n 'tax-undecided': 'the store has not chosen how it handles sales tax',\n 'stripe-tax-not-active': 'the store chose Stripe Tax and Stripe Tax is not on in its own Stripe account',\n}\n\n/**\n * Records one refused checkout and, when it starts an episode, tells the\n * site's managers and the operator. Never throws and never delays the\n * refusal: callers `void` it beside the 409 they return.\n */\nexport async function reportCheckoutTaxRefusal(\n hostId: string,\n reason: CheckoutTaxBlock,\n deps: CheckoutTaxRefusalDeps = defaultDeps(),\n): Promise<'told' | 'counted' | 'failed'> {\n try {\n if (!hostId) return 'failed'\n const firestore = deps.firestore()\n const ref = markerRef(firestore, hostId)\n const nowMs = deps.now()\n const started = await firestore.runTransaction(async (transaction) => {\n const snapshot = await transaction.get(ref)\n const existing = snapshot.exists ? (snapshot.data() as Partial<CheckoutTaxRefusalRecord>) : null\n if (isNewCheckoutTaxRefusal(existing, reason, nowMs)) {\n const record: CheckoutTaxRefusalRecord = { reason, firstAtMs: nowMs, lastAtMs: nowMs, count: 1 }\n transaction.set(ref, record)\n return record\n }\n transaction.set(\n ref,\n { lastAtMs: nowMs, count: Math.max(0, Number(existing?.count) || 0) + 1 },\n { merge: true },\n )\n return null\n })\n if (!started) return 'counted'\n const notice = checkoutTaxRefusalNotice(reason)\n await deps.notifyManagers(hostId, {\n type: 'content.order',\n level: 'warning',\n title: notice.title,\n body: notice.body,\n link: `/${hostId}/products/taxes`,\n })\n const host = await firestore.collection('hosts').doc(hostId).get().catch(() => null)\n const site = host?.exists ? hostDisplayName(host.data() as Record<string, unknown>, hostId) : hostId\n await deps.raiseAlert(COMMERCE_CHECKOUT_TAX_SETUP_REFUSED, {\n dedupeKey: `${hostId}:${reason}:${started.firstAtMs}`,\n hostId,\n context: { site: `${site} (${hostId})`, reason: REASON_FOR_STAFF[reason] },\n })\n return 'told'\n } catch (error) {\n console.error('[commerce] checkout tax refusal report failed', hostId, reason, error)\n return 'failed'\n }\n}\n\n/**\n * {@link reportCheckoutTaxRefusal} for a checkout route: started beside the\n * refusal it reports and kept alive past the response, so the 409 goes out\n * at once and the report still finishes.\n */\nexport function tellCheckoutTaxRefusal(hostId: string, reason: CheckoutTaxBlock): void {\n void keepAlive(reportCheckoutTaxRefusal(hostId, reason))\n}\n\n/** The marker's last refusal for `reason`, or null. Never throws. */\nexport async function readCheckoutTaxRefusal(\n firestore: FirebaseFirestore.Firestore,\n hostId: string,\n): Promise<CheckoutTaxRefusalRecord | null> {\n try {\n const snapshot = await markerRef(firestore, hostId).get()\n return snapshot.exists ? (snapshot.data() as CheckoutTaxRefusalRecord) : null\n } catch {\n return null\n }\n}\n\n/** Drops the marker, so the next refusal tells the owner again. Never throws. */\nexport async function clearCheckoutTaxRefusal(\n firestore: FirebaseFirestore.Firestore,\n hostId: string,\n): Promise<void> {\n try {\n await markerRef(firestore, hostId).delete()\n } catch (error) {\n console.error('[commerce] checkout tax refusal clear failed', hostId, error)\n }\n}\n"],"names":["firebaseAdmin","hostDisplayName","notifyHostManagers","raiseOperatorAlert","keepAlive","COMMERCE_CHECKOUT_TAX_SETUP_REFUSED","checkoutTaxRefusalNotice","CHECKOUT_TAX_REFUSAL_DOC","CHECKOUT_TAX_REFUSAL_RETELL_MS","defaultDeps","firestore","app","notifyManagers","raiseAlert","now","Date","markerRef","hostId","collection","doc","isNewCheckoutTaxRefusal","existing","reason","nowMs","last","Number","lastAtMs","isFinite","REASON_FOR_STAFF","reportCheckoutTaxRefusal","deps","ref","started","runTransaction","transaction","snapshot","get","exists","data","record","firstAtMs","count","set","Math","max","merge","notice","type","level","title","body","link","host","catch","site","dedupeKey","context","error","console","tellCheckoutTaxRefusal","readCheckoutTaxRefusal","clearCheckoutTaxRefusal","delete"],"mappings":"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"}
@@ -27,7 +27,8 @@ import type { PluginApiHandler } from '@aglyn/aglyn/server';
27
27
  *
28
28
  * - The fee is NOT "2%". It is `resolveTransactionFeePct(org, productType)`
29
29
  * — a per-plan, per-product-type ladder with per-org staff overrides,
30
- * resolved per request. 2% is one cell of sixteen (Starter, physical).
30
+ * resolved per request. 2% was one cell of sixteen (Starter, physical)
31
+ * when this was written, and the ladder has moved since.
31
32
  * - Selling is gated on `commerce`, not on `marketplaceSelling` (AGL-470).
32
33
  * They are different entitlements on different plans: `marketplaceSelling`
33
34
  * gates the marketplace, and reading this comment as current would gate a
@@ -40,6 +40,7 @@ import { appendLocalFulfillmentMetadata, localFulfillmentLocationId, localStockR
40
40
  import { applyNativeCheckoutParams, nativeCheckoutStripeHeaders, readCheckoutSessionPayload, resolveNativeCheckoutMode } from "./native-checkout.js";
41
41
  import { ensureCheckoutDomain } from "./payment-method-domains.js";
42
42
  import { SELLER_STRIPE_TAX_NOT_SET_UP_MESSAGE, sellerStripeTaxActive } from "./seller-stripe-account.js";
43
+ import { tellCheckoutTaxRefusal } from "./checkout-tax-refusal.js";
43
44
  /**
44
45
  * Commerce Starter checkout (AGL-90): a site visitor buys a product. The
45
46
  * price ALWAYS comes from the host's product doc (never the request), the
@@ -52,7 +53,8 @@ import { SELLER_STRIPE_TAX_NOT_SET_UP_MESSAGE, sellerStripeTaxActive } from "./s
52
53
  *
53
54
  * - The fee is NOT "2%". It is `resolveTransactionFeePct(org, productType)`
54
55
  * — a per-plan, per-product-type ladder with per-org staff overrides,
55
- * resolved per request. 2% is one cell of sixteen (Starter, physical).
56
+ * resolved per request. 2% was one cell of sixteen (Starter, physical)
57
+ * when this was written, and the ladder has moved since.
56
58
  * - Selling is gated on `commerce`, not on `marketplaceSelling` (AGL-470).
57
59
  * They are different entitlements on different plans: `marketplaceSelling`
58
60
  * gates the marketplace, and reading this comment as current would gate a
@@ -540,7 +542,9 @@ export const checkoutHandler = async (req, res)=>{
540
542
  });
541
543
  if (taxDecision.kind === 'undecided') {
542
544
  // Above the attempt claim, like every other deterministic refusal on
543
- // this path — there is no claim to release yet.
545
+ // this path — there is no claim to release yet. The owner is told once
546
+ // (AGL-4245), not the shopper alone.
547
+ tellCheckoutTaxRefusal(hostId, 'tax-undecided');
544
548
  return res.status(409).json({
545
549
  error: CommerceModel.STOREFRONT_TAX_UNDECIDED_MESSAGE
546
550
  });
@@ -559,6 +563,7 @@ export const checkoutHandler = async (req, res)=>{
559
563
  // A direct-charge store's Stripe Tax runs on ITS account, against its
560
564
  // registrations, and Stripe refuses the session where it is not set up.
561
565
  if (direct && useStripeTax && !await sellerStripeTaxActive(String(accountId))) {
566
+ tellCheckoutTaxRefusal(hostId, 'stripe-tax-not-active');
562
567
  return res.status(409).json({
563
568
  error: SELLER_STRIPE_TAX_NOT_SET_UP_MESSAGE
564
569
  });