@aglyn/plugins-commerce 1.13.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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/pos-hardware-terms.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 { LEGAL_ORIGIN } from '@aglyn/aglyn/app-utils/published-legal-pages'\n\n/*==========================================\n * THE TERMS OF SALE AT THE BOOTH (AGL-4038).\n *\n * The platform sells card readers in person under its published Terms,\n * Sections 4.26 to 4.32. Section 4.28 says how a buyer agrees: before paying,\n * they accept those terms electronically — on the register tablet handed to\n * them, or on the register's customer display — and where that can't be done\n * (no power, no connection), the receipt and a sign at the booth state that\n * the sale is made under them, and paying is agreeing.\n *\n * So a register sale of hardware carries `hardwareTermsAcceptance`: which\n * version of the Terms, when, how (`tablet`, `display`, or `notice` for the\n * receipt-and-sign route), the register user who handed it over, and the\n * device's address and browser, as a signature's audit does. The hardware\n * order the sale becomes copies it (`termsAcceptance`).\n *\n * `POS_HARDWARE_TERMS_VERSION` is the Terms version whose Sections 4.26–4.32\n * the summary below follows. It moves only when those sections change; a\n * console spec holds it at or below the published version.\n *=========================================*/\n\n/** The published Terms version the summary and every acceptance name. */\nexport const POS_HARDWARE_TERMS_VERSION = 'v21'\n\n/** The sections of the Terms that are the terms of sale for hardware. */\nexport const POS_HARDWARE_TERMS_SECTIONS = '4.26–4.32'\n\n/** The published Terms, where the full text is. */\nexport function posHardwareTermsUrl(): string {\n return `${LEGAL_ORIGIN}/legal/terms`\n}\n\n/** The Terms' address as a receipt or a sign prints it: `example.com/legal/terms`. */\nexport function posHardwareTermsAddress(): string {\n try {\n return `${new URL(LEGAL_ORIGIN).host}/legal/terms`\n } catch {\n return '/legal/terms'\n }\n}\n\n/**\n * What the buyer reads before accepting: Sections 4.26–4.32 in short, in the\n * published text's own order and terms, with the link to the whole. Never\n * instead of it: the acceptance is of the Terms, which this summarizes.\n */\nexport const POS_HARDWARE_TERMS_SUMMARY: readonly string[] = [\n 'We are the seller of this hardware. It is for use in a business in the United States, not for personal, family or household use, and you may not resell it.',\n 'Ownership and the risk of loss pass to you when the hardware is handed to you. Sales tax is charged at the rate our register charges for this sale.',\n 'You may return it within 30 days of buying it, in its original packaging and condition with all its accessories. You pay the return shipping, and any restocking fee Stripe charges us for the return comes off the refund.',\n 'For one year we warrant it, other than cables and other accessories, against defects in materials and workmanship under normal use. Repair or replacement is the only remedy.',\n 'Its software is Stripe’s, under Stripe’s terms. It needs an internet connection you provide, and its price does not include any internet or cellular data service.',\n 'Apart from that warranty, the hardware is provided as is, and our liability for it is limited to the amount you paid for it.',\n]\n\n/** How a buyer agreed to the terms of sale. */\nexport type PosHardwareTermsMethod = 'tablet' | 'display' | 'notice'\n\n/** `hardwareTermsAcceptance` on a register sale, and `termsAcceptance` on the hardware order. */\nexport interface PosHardwareTermsAcceptance {\n version: string\n sections: string\n method: PosHardwareTermsMethod\n atMs: number\n /** The register user who handed the tablet over or put the terms on the display; null for a notice. */\n staffUid: string | null\n /** The address and browser of the device the buyer accepted on; null for a notice. */\n ip: string | null\n userAgent: string | null\n}\n\nconst METHODS: readonly PosHardwareTermsMethod[] = ['tablet', 'display', 'notice']\n\n/** An acceptance as stored, or null for anything that is not one. */\nexport function posHardwareTermsAcceptanceOf(raw: unknown): PosHardwareTermsAcceptance | null {\n if (!raw || typeof raw !== 'object') return null\n const value = raw as Record<string, unknown>\n const method = String(value['method'] ?? '') as PosHardwareTermsMethod\n const atMs = Number(value['atMs'])\n if (!METHODS.includes(method) || !Number.isFinite(atMs) || atMs <= 0) return null\n const text = (field: string, max: number) =>\n typeof value[field] === 'string' && (value[field] as string) ? (value[field] as string).slice(0, max) : null\n return {\n version: text('version', 20) ?? POS_HARDWARE_TERMS_VERSION,\n sections: text('sections', 40) ?? POS_HARDWARE_TERMS_SECTIONS,\n method,\n atMs,\n staffUid: text('staffUid', 128),\n ip: text('ip', 100),\n userAgent: text('userAgent', 400),\n }\n}\n\n/** A fresh acceptance of the current terms of sale. */\nexport function posHardwareTermsAcceptance(input: {\n method: PosHardwareTermsMethod\n atMs: number\n staffUid?: string | null\n ip?: string | null\n userAgent?: string | null\n}): PosHardwareTermsAcceptance {\n return {\n version: POS_HARDWARE_TERMS_VERSION,\n sections: POS_HARDWARE_TERMS_SECTIONS,\n method: input.method,\n atMs: input.atMs,\n staffUid: input.method === 'notice' ? null : (input.staffUid ?? null),\n ip: input.method === 'notice' ? null : (input.ip ?? null)?.slice(0, 100) ?? null,\n userAgent: input.method === 'notice' ? null : (input.userAgent ?? null)?.slice(0, 400) ?? null,\n }\n}\n\n/** Whether a register sale sells hardware: marked when rung, or recorded since. */\nexport function isPosHardwareRegisterSale(order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined): boolean {\n return order?.hardwareSalePending === true || (typeof order?.hardwareOrderId === 'string' && Boolean(order.hardwareOrderId))\n}\n\n/**\n * The line every receipt of a register sale of hardware prints (Section\n * 4.28's fallback, printed whether or not the buyer also accepted\n * electronically): which terms the sale is made under, and that paying is\n * agreeing to them. Null on every other sale.\n */\nexport function posHardwareReceiptNotice(\n order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined,\n): string | null {\n if (!isPosHardwareRegisterSale(order)) return null\n return (\n `Card reader hardware on this receipt is sold under ${posHardwareTermsAddress()}, ` +\n `Sections ${POS_HARDWARE_TERMS_SECTIONS}. By paying for it you agree to those terms for this purchase.`\n )\n}\n\n/** A receipt footer with the terms notice after it, for a sale of hardware. */\nexport function withPosHardwareReceiptNotice(\n footer: string | null | undefined,\n order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined,\n): string {\n return [String(footer ?? '').trim(), posHardwareReceiptNotice(order)].filter(Boolean).join('\\n')\n}\n"],"names":["LEGAL_ORIGIN","POS_HARDWARE_TERMS_VERSION","POS_HARDWARE_TERMS_SECTIONS","posHardwareTermsUrl","posHardwareTermsAddress","URL","host","POS_HARDWARE_TERMS_SUMMARY","METHODS","posHardwareTermsAcceptanceOf","raw","value","text","method","String","atMs","Number","includes","isFinite","field","max","slice","version","sections","staffUid","ip","userAgent","posHardwareTermsAcceptance","input","isPosHardwareRegisterSale","order","hardwareSalePending","hardwareOrderId","Boolean","posHardwareReceiptNotice","withPosHardwareReceiptNotice","footer","trim","filter","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,YAAY,QAAQ,+CAA8C;AAE3E;;;;;;;;;;;;;;;;;;;2CAmB2C,GAE3C,uEAAuE,GACvE,OAAO,MAAMC,6BAA6B,MAAK;AAE/C,uEAAuE,GACvE,OAAO,MAAMC,8BAA8B,YAAW;AAEtD,iDAAiD,GACjD,OAAO,SAASC;IACd,OAAO,GAAGH,aAAa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AAUI,MAAMf,MAAM,KAAK,WAAW,QAAQe,kBAAAA,MAAMJ,QAAQ,YAAdI,kBAAkB;QAChEH,IAAIG,MAAMf,MAAM,KAAK,WAAW,gBAAQe,SAAAA,YAAAA,MAAMH,EAAE,YAARG,YAAY,yBAAb,AAACA,MAAmBP,KAAK,CAAC,GAAG,uBAAQ;QAC5EK,WAAWE,MAAMf,MAAM,KAAK,WAAW,iBAAQe,UAAAA,mBAAAA,MAAMF,SAAS,YAAfE,mBAAmB,yBAApB,AAACA,OAA0BP,KAAK,CAAC,GAAG,wBAAQ;IAC5F;AACF;AAEA,iFAAiF,GACjF,OAAO,SAASQ,0BAA0BC,KAAsF;IAC9H,OAAOA,CAAAA,yBAAAA,MAAOC,mBAAmB,MAAK,QAAS,QAAOD,yBAAAA,MAAOE,eAAe,MAAK,YAAYC,QAAQH,MAAME,eAAe;AAC5H;AAEA;;;;;CAKC,GACD,OAAO,SAASE,yBACdJ,KAAsF;IAEtF,IAAI,CAACD,0BAA0BC,QAAQ,OAAO;IAC9C,OACE,CAAC,mDAAmD,EAAE1B,0BAA0B,EAAE,CAAC,GACnF,CAAC,SAAS,EAAEF,4BAA4B,8DAA8D,CAAC;AAE3G;AAEA,6EAA6E,GAC7E,OAAO,SAASiC,6BACdC,MAAiC,EACjCN,KAAsF;IAEtF,OAAO;QAAChB,OAAOsB,iBAAAA,SAAU,IAAIC,IAAI;QAAIH,yBAAyBJ;KAAO,CAACQ,MAAM,CAACL,SAASM,IAAI,CAAC;AAC7F"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/pos-hardware-terms.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 { LEGAL_ORIGIN } from '@aglyn/aglyn/app-utils/published-legal-pages'\n\n/*==========================================\n * THE TERMS OF SALE AT THE BOOTH (AGL-4038).\n *\n * The platform sells card readers in person under its published Terms,\n * Sections 4.26 to 4.32. Section 4.28 says how a buyer agrees: before paying,\n * they accept those terms electronically — on the register tablet handed to\n * them, or on the register's customer display — and where that can't be done\n * (no power, no connection), the receipt and a sign at the booth state that\n * the sale is made under them, and paying is agreeing.\n *\n * So a register sale of hardware carries `hardwareTermsAcceptance`: which\n * version of the Terms, when, how (`tablet`, `display`, or `notice` for the\n * receipt-and-sign route), the register user who handed it over, and the\n * device's address and browser, as a signature's audit does. The hardware\n * order the sale becomes copies it (`termsAcceptance`).\n *\n * `POS_HARDWARE_TERMS_VERSION` is the Terms version whose Sections 4.26–4.32\n * the summary below follows. It moves only when those sections change; a\n * console spec holds it at or below the published version.\n *=========================================*/\n\n/** The published Terms version the summary and every acceptance name. */\nexport const POS_HARDWARE_TERMS_VERSION = 'v21'\n\n/** The sections of the Terms that are the terms of sale for hardware. */\nexport const POS_HARDWARE_TERMS_SECTIONS = '4.26–4.32'\n\n/** The published Terms, where the full text is. */\nexport function posHardwareTermsUrl(): string {\n return `${LEGAL_ORIGIN}/legal/terms`\n}\n\n/** The Terms' address as a receipt or a sign prints it: `example.com/legal/terms`. */\nexport function posHardwareTermsAddress(): string {\n try {\n return `${new URL(LEGAL_ORIGIN).host}/legal/terms`\n } catch {\n return '/legal/terms'\n }\n}\n\n/**\n * What the buyer reads before accepting: Sections 4.26–4.32 in short, in the\n * published text's own order and terms, with the link to the whole. Never\n * instead of it: the acceptance is of the Terms, which this summarizes.\n */\nexport const POS_HARDWARE_TERMS_SUMMARY: readonly string[] = [\n 'We are the seller of this hardware. It is for use in a business in the United States, not for personal, family or household use, and you may not resell it.',\n 'Ownership and the risk of loss pass to you when the hardware is handed to you. Sales tax is charged at the rate our register charges for this sale.',\n 'You may return it within 30 days of buying it, in its original packaging and condition with all its accessories. You pay the return shipping, and any restocking fee Stripe charges us for the return comes off the refund.',\n 'For one year we warrant it, other than cables and other accessories, against defects in materials and workmanship under normal use. Repair or replacement is the only remedy.',\n 'Its software is Stripe’s, under Stripe’s terms. It needs an internet connection you provide, and its price does not include any internet or cellular data service.',\n 'Apart from that warranty, the hardware is provided as is, and our liability for it is limited to the amount you paid for it.',\n]\n\n/**\n * How a buyer agreed to the terms of sale: at the booth on the register\n * tablet or the customer display, by the receipt-and-sign notice, or ONLINE\n * (AGL-4038) by ticking the terms and business use at checkout, in the\n * platform's own store or on the Hardware card.\n */\nexport type PosHardwareTermsMethod = 'tablet' | 'display' | 'notice' | 'online'\n\n/** `hardwareTermsAcceptance` on a register sale, and `termsAcceptance` on the hardware order. */\nexport interface PosHardwareTermsAcceptance {\n version: string\n sections: string\n method: PosHardwareTermsMethod\n atMs: number\n /** The register user who handed the tablet over or put the terms on the display; null for a notice. */\n staffUid: string | null\n /** The address and browser of the device the buyer accepted on; null for a notice. */\n ip: string | null\n userAgent: string | null\n /**\n * The buyer confirmed they are buying for use in a business (AGL-4038):\n * asked on its own at an online checkout, beside the terms. Absent on an\n * acceptance at the booth, where the terms the buyer reads say so.\n */\n businessUse?: boolean\n}\n\nconst METHODS: readonly PosHardwareTermsMethod[] = ['tablet', 'display', 'notice', 'online']\n\n/** An acceptance as stored, or null for anything that is not one. */\nexport function posHardwareTermsAcceptanceOf(raw: unknown): PosHardwareTermsAcceptance | null {\n if (!raw || typeof raw !== 'object') return null\n const value = raw as Record<string, unknown>\n const method = String(value['method'] ?? '') as PosHardwareTermsMethod\n const atMs = Number(value['atMs'])\n if (!METHODS.includes(method) || !Number.isFinite(atMs) || atMs <= 0) return null\n const text = (field: string, max: number) =>\n typeof value[field] === 'string' && (value[field] as string) ? (value[field] as string).slice(0, max) : null\n return {\n version: text('version', 20) ?? POS_HARDWARE_TERMS_VERSION,\n sections: text('sections', 40) ?? POS_HARDWARE_TERMS_SECTIONS,\n method,\n atMs,\n staffUid: text('staffUid', 128),\n ip: text('ip', 100),\n userAgent: text('userAgent', 400),\n ...(value['businessUse'] === true ? { businessUse: true } : {}),\n }\n}\n\n/** A fresh acceptance of the current terms of sale. */\nexport function posHardwareTermsAcceptance(input: {\n method: PosHardwareTermsMethod\n atMs: number\n staffUid?: string | null\n ip?: string | null\n userAgent?: string | null\n}): PosHardwareTermsAcceptance {\n return {\n version: POS_HARDWARE_TERMS_VERSION,\n sections: POS_HARDWARE_TERMS_SECTIONS,\n method: input.method,\n atMs: input.atMs,\n staffUid: input.method === 'notice' ? null : (input.staffUid ?? null),\n ip: input.method === 'notice' ? null : (input.ip ?? null)?.slice(0, 100) ?? null,\n userAgent: input.method === 'notice' ? null : (input.userAgent ?? null)?.slice(0, 400) ?? null,\n }\n}\n\n/*==========================================\n * ACCEPTING THE TERMS OF SALE ONLINE (AGL-4038).\n *\n * A checkout that sells hardware, in the platform's own store or on the\n * Hardware card, asks two things beside the order: that the buyer accepts the\n * terms of sale (Terms 4.26–4.32, linked), and that they are buying for use\n * in a business. Both are required; a checkout without them is refused with\n * {@link POS_HARDWARE_TERMS_REQUIRED}. The acceptance rides the Checkout\n * Session's metadata ({@link posHardwareTermsMetadata}), because the order is\n * written only once Stripe says the session is paid, and the webhook writes\n * it onto the order as the booth's acceptance is.\n *=========================================*/\n\n/** The plain sentence a checkout without the acceptance is refused with. */\nexport const POS_HARDWARE_TERMS_REQUIRED =\n `To buy card reader hardware, accept the hardware terms of sale (Terms, Sections ${POS_HARDWARE_TERMS_SECTIONS}) and confirm you are buying it for your business.`\n\n/**\n * Whether a checkout request carries the buyer's acceptance: the request's\n * `hardwareTerms` says both `accepted` and `businessUse`, each literally true.\n */\nexport function posHardwareTermsConfirmed(raw: unknown): boolean {\n const value = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>\n return value['accepted'] === true && value['businessUse'] === true\n}\n\n/** The metadata keys an online acceptance rides the Checkout Session under. */\nconst TERMS_METADATA = {\n version: 'hardwareTermsVersion',\n businessUse: 'hardwareTermsBusinessUse',\n ip: 'hardwareTermsIp',\n userAgent: 'hardwareTermsUserAgent',\n} as const\n\n/**\n * An online acceptance as Checkout Session metadata, every value within\n * Stripe's 500-character limit. The caller prefixes each key as its params\n * need (`metadata[...]`). No time: the session's own creation is when the\n * buyer accepted, and a value that changed between two presses of one\n * attempt would make Stripe refuse the idempotent retry.\n */\nexport function posHardwareTermsMetadata(input: {\n ip?: string | null\n userAgent?: string | null\n}): Record<string, string> {\n return {\n [TERMS_METADATA.version]: POS_HARDWARE_TERMS_VERSION,\n [TERMS_METADATA.businessUse]: 'true',\n ...(input.ip ? { [TERMS_METADATA.ip]: String(input.ip).slice(0, 100) } : {}),\n ...(input.userAgent ? { [TERMS_METADATA.userAgent]: String(input.userAgent).slice(0, 400) } : {}),\n }\n}\n\n/**\n * The online acceptance a paid session's metadata carries, or null when it\n * carries none. `atMs` is when the session was created (Stripe's `created`,\n * in milliseconds), which is when the buyer pressed to pay having accepted.\n */\nexport function posHardwareTermsFromMetadata(metadata: unknown, atMs: number): PosHardwareTermsAcceptance | null {\n const value = (metadata && typeof metadata === 'object' ? metadata : {}) as Record<string, unknown>\n const version = typeof value[TERMS_METADATA.version] === 'string' ? (value[TERMS_METADATA.version] as string) : ''\n if (!version || !Number.isFinite(atMs) || atMs <= 0 || value[TERMS_METADATA.businessUse] !== 'true') return null\n const text = (field: string, max: number) =>\n typeof value[field] === 'string' && (value[field] as string) ? (value[field] as string).slice(0, max) : null\n return {\n version: version.slice(0, 20),\n sections: POS_HARDWARE_TERMS_SECTIONS,\n method: 'online',\n atMs,\n staffUid: null,\n ip: text(TERMS_METADATA.ip, 100),\n userAgent: text(TERMS_METADATA.userAgent, 400),\n businessUse: true,\n }\n}\n\n/** Whether a register sale sells hardware: marked when rung, or recorded since. */\nexport function isPosHardwareRegisterSale(order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined): boolean {\n return order?.hardwareSalePending === true || (typeof order?.hardwareOrderId === 'string' && Boolean(order.hardwareOrderId))\n}\n\n/**\n * The line every receipt of a register sale of hardware prints (Section\n * 4.28's fallback, printed whether or not the buyer also accepted\n * electronically): which terms the sale is made under, and that paying is\n * agreeing to them. Null on every other sale.\n */\nexport function posHardwareReceiptNotice(\n order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined,\n): string | null {\n if (!isPosHardwareRegisterSale(order)) return null\n return (\n `Card reader hardware on this receipt is sold under ${posHardwareTermsAddress()}, ` +\n `Sections ${POS_HARDWARE_TERMS_SECTIONS}. By paying for it you agree to those terms for this purchase.`\n )\n}\n\n/** A receipt footer with the terms notice after it, for a sale of hardware. */\nexport function withPosHardwareReceiptNotice(\n footer: string | null | undefined,\n order: { hardwareSalePending?: unknown; hardwareOrderId?: unknown } | null | undefined,\n): string {\n return [String(footer ?? '').trim(), posHardwareReceiptNotice(order)].filter(Boolean).join('\\n')\n}\n"],"names":["LEGAL_ORIGIN","POS_HARDWARE_TERMS_VERSION","POS_HARDWARE_TERMS_SECTIONS","posHardwareTermsUrl","posHardwareTermsAddress","URL","host","POS_HARDWARE_TERMS_SUMMARY","METHODS","posHardwareTermsAcceptanceOf","raw","value","text","method","String","atMs","Number","includes","isFinite","field","max","slice","version","sections","staffUid","ip","userAgent","businessUse","posHardwareTermsAcceptance","input","POS_HARDWARE_TERMS_REQUIRED","posHardwareTermsConfirmed","TERMS_METADATA","posHardwareTermsMetadata","posHardwareTermsFromMetadata","metadata","isPosHardwareRegisterSale","order","hardwareSalePending","hardwareOrderId","Boolean","posHardwareReceiptNotice","withPosHardwareReceiptNotice","footer","trim","filter","join"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,YAAY,QAAQ,+CAA8C;AAE3E;;;;;;;;;;;;;;;;;;;2CAmB2C,GAE3C,uEAAuE,GACvE,OAAO,MAAMC,6BAA6B,MAAK;AAE/C,uEAAuE,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,6EAA6E,GAC7E,OAAO,SAASwC,6BACdC,MAAiC,EACjCN,KAAsF;IAEtF,OAAO;QAACvB,OAAO6B,iBAAAA,SAAU,IAAIC,IAAI;QAAIH,yBAAyBJ;KAAO,CAACQ,MAAM,CAACL,SAASM,IAAI,CAAC;AAC7F"}
@@ -28,6 +28,14 @@ export declare const POS_HARDWARE_SHIP_COUNTRIES: readonly string[];
28
28
  /** The most of one item, and the most units, a single order may hold. */
29
29
  export declare const POS_HARDWARE_MAX_PER_LINE = 10;
30
30
  export declare const POS_HARDWARE_MAX_UNITS = 20;
31
+ /**
32
+ * The Stripe Tax code every hardware line carries (AGL-4038): "General -
33
+ * Tangible Goods" (https://docs.stripe.com/tax/tax-codes), the physical good
34
+ * a reader or an accessory is. Without it a line takes the account's default
35
+ * code, which is software as a service, and would be taxed as software.
36
+ * Stripe's list has no narrower code for a card reader.
37
+ */
38
+ export declare const POS_HARDWARE_TAX_CODE = "txcd_99999999";
31
39
  /** The env names the shop reads, named once for the reader and the docs. */
32
40
  export declare const POS_HARDWARE_ENV: {
33
41
  /** `true` releases the shop. Absent or anything else keeps it hidden. */
@@ -64,9 +72,16 @@ export type PosHardwareSkuId = 'stripe-reader-s710' | 'stripe-reader-s700' | 'st
64
72
  export interface PosHardwareSku {
65
73
  id: PosHardwareSkuId;
66
74
  kind: 'reader' | 'accessory';
67
- /** What Stripe's hardware shop calls it, for the staff member ordering it. */
75
+ /**
76
+ * What the supplier's hardware shop calls it, for the staff member ordering
77
+ * it. Staff-only: the merchant never sees it.
78
+ */
68
79
  stripeProductName: string;
69
- /** What the merchant sees. */
80
+ /**
81
+ * What the merchant sees, everywhere: shop, Hardware card, booth register,
82
+ * emails and receipts. A plain name with the model in brackets, never the
83
+ * maker's name; the record keeps the exact model in `sku` for support.
84
+ */
70
85
  displayName: string;
71
86
  /** One line on what it is for. */
72
87
  use: string;
@@ -100,6 +115,13 @@ export interface PosHardwareConfig {
100
115
  cents: number;
101
116
  }>;
102
117
  automaticTax: boolean;
118
+ /**
119
+ * The price each item is listed at in the platform's own store, in cents
120
+ * (AGL-4038), where the server read one: the shop then charges that, so
121
+ * the Hardware card and the store's product page quote one price
122
+ * ({@link posHardwareOfferUnitCents}). Never read from the environment.
123
+ */
124
+ listedCents?: Partial<Record<PosHardwareSkuId, number>>;
103
125
  }
104
126
  /**
105
127
  * The shop's configuration from the environment, or `null` while the shop is
@@ -142,6 +164,18 @@ export declare function normalizePosHardwareSerial(value: unknown): string;
142
164
  * margin) is `10000`. Whichever the business means, it is this one number.
143
165
  */
144
166
  export declare function posHardwareUnitCents(costCents: number, markupBps: number): number;
167
+ /**
168
+ * ONE PRICE FOR ONE ITEM (AGL-4038). The platform's own store lists the same
169
+ * readers on its product pages, at prices set on the products, and the
170
+ * Hardware card prices them from the environment, Stripe's cost plus the
171
+ * markup. Two sources would quote two prices for one reader. So the item's
172
+ * listed price is the price wherever it is listed, and the Hardware card
173
+ * charges exactly what the product page shows. It never sells below cost: a
174
+ * listed price under Stripe's cost is a mistake on the product, and the card
175
+ * keeps the marked-up price for it instead. An item the store does not list
176
+ * is priced from the environment as before.
177
+ */
178
+ export declare function posHardwareOfferUnitCents(config: Pick<PosHardwareConfig, 'costs' | 'markupBps' | 'listedCents'>, sku: PosHardwareSkuId): number;
145
179
  /** An item as the shop offers it: the merchant's price, never Stripe's. */
146
180
  export interface PosHardwareOffer {
147
181
  sku: PosHardwareSkuId;
@@ -177,7 +211,7 @@ export declare function pricePosHardwareCart(config: PosHardwareConfig, requeste
177
211
  export declare const POS_HARDWARE_METADATA_TYPE = "pos-hardware-order";
178
212
  export declare function encodePosHardwareLines(lines: readonly PosHardwareLine[]): string;
179
213
  export declare function decodePosHardwareLines(encoded: unknown): PosHardwareLine[] | null;
180
- export type PosHardwareOrderStatus = 'paid' | 'ordered' | 'shipped' | 'delivered' | 'registered' | 'canceled' | 'refunded';
214
+ export type PosHardwareOrderStatus = 'paid' | 'ordered' | 'received' | 'shipped' | 'delivered' | 'registered' | 'canceled' | 'refunded';
181
215
  export declare const POS_HARDWARE_ORDER_STATUSES: readonly PosHardwareOrderStatus[];
182
216
  export declare function isPosHardwareOrderStatus(value: unknown): value is PosHardwareOrderStatus;
183
217
  /** What the merchant reads on the Hardware card. */
@@ -191,6 +225,8 @@ export declare function nextPosHardwareStatus(status: PosHardwareOrderStatus): P
191
225
  * the hardware, which is a separate process this phase does not automate.
192
226
  */
193
227
  export declare function posHardwareRefundable(status: PosHardwareOrderStatus): boolean;
228
+ /** The statuses of an order that has not shipped yet, which a closure cancels and refunds. */
229
+ export declare const POS_HARDWARE_UNSHIPPED_STATUSES: readonly PosHardwareOrderStatus[];
194
230
  export interface PosHardwareAddress {
195
231
  line1: string;
196
232
  line2?: string;
@@ -237,18 +273,34 @@ export interface PosHardwareTaxLine {
237
273
  percentage: number | null;
238
274
  }
239
275
  /**
240
- * Where an order was sold (AGL-4038): the Hardware card's checkout, or the
241
- * platform's own register, in person. Absent on every order sold before the
242
- * in-person sale existed, which were all online; read it through
243
- * {@link posHardwareOrderSource}.
276
+ * Where an order was sold (AGL-4038): the Hardware card's checkout
277
+ * (`online`), the platform's own register, in person (`in_person`), or the
278
+ * platform's own online store, its product pages and cart (`storefront`).
279
+ * Absent on every order sold before the in-person sale existed, which were
280
+ * all from the Hardware card; read it through {@link posHardwareOrderSource}.
244
281
  */
245
- export type PosHardwareOrderSource = 'online' | 'in_person';
282
+ export type PosHardwareOrderSource = 'online' | 'in_person' | 'storefront';
246
283
  export declare function posHardwareOrderSource(order: {
247
284
  source?: unknown;
248
285
  } | null | undefined): PosHardwareOrderSource;
249
286
  /**
250
- * The register sale an in-person order came from: the platform's own store,
251
- * the register order and its number, and how it was rung.
287
+ * Whether an order was sold by the platform's own store (AGL-4038), at its
288
+ * register or online: paid into that store's own account, with the store's
289
+ * order behind it (`posSale`), and whose buyer may still be to attach. It is
290
+ * attached, refunded and counted on the tax return the same way either way.
291
+ */
292
+ export declare function isPosHardwareSellerStoreSale(order: {
293
+ source?: unknown;
294
+ } | null | undefined): boolean;
295
+ /** Whether an order is shipped to its buyer, rather than handed over at a register. */
296
+ export declare function posHardwareShips(order: {
297
+ source?: unknown;
298
+ } | null | undefined): boolean;
299
+ /**
300
+ * The store order an order sold by the platform's own store came from: the
301
+ * store, the order and its number, and how it was rung. For a `storefront`
302
+ * order it is the store's online order, with no register, and
303
+ * `paymentLinkSessionId` is the Checkout Session it was paid through.
252
304
  */
253
305
  export interface PosHardwareRegisterSale {
254
306
  hostId: string;
@@ -416,6 +468,8 @@ export interface PosHardwareOrder {
416
468
  updatedAtMs: number;
417
469
  paidAtMs: number;
418
470
  orderedAtMs?: number;
471
+ /** When the platform received it from the supplier (AGL-4038). */
472
+ receivedAtMs?: number;
419
473
  shippedAtMs?: number;
420
474
  deliveredAtMs?: number;
421
475
  registeredAtMs?: number;
@@ -437,9 +491,10 @@ export interface PosHardwareOrder {
437
491
  /** Whose an in-person order is, or that staff have still to say. */
438
492
  attachment?: PosHardwareAttachment;
439
493
  /**
440
- * How the buyer of an in-person order agreed to the terms of sale
441
- * (AGL-4038): copied from the register sale, or the receipt-and-sign
442
- * notice when they did not accept electronically.
494
+ * How the buyer agreed to the terms of sale (AGL-4038): for an in-person
495
+ * order, copied from the register sale, or the receipt-and-sign notice
496
+ * when they did not accept electronically; for an order paid online,
497
+ * ticked at checkout with business use confirmed (`online`).
443
498
  */
444
499
  termsAcceptance?: PosHardwareTermsAcceptance;
445
500
  /** Each reader of an in-person order, with its serial when one was taken. */
@@ -464,6 +519,21 @@ export interface PosHardwareOrder {
464
519
  export declare const POS_HARDWARE_STATUS_STAMP: Record<PosHardwareOrderStatus, keyof PosHardwareOrder>;
465
520
  /** The Hardware card's anchor: Checkout returns to it and the emails link at it. */
466
521
  export declare const POS_HARDWARE_ANCHOR = "pos-hardware";
522
+ /**
523
+ * What the point of sale adds to a reader (AGL-4038), for the prompt a
524
+ * workspace without it sees: anyone may buy readers, and a reader takes
525
+ * payments at the register, which comes with the point of sale.
526
+ */
527
+ export declare const POS_PLAN_ADDS = "registers that ring up sales, card payments on your readers, cash with change due, receipts and shift reports";
528
+ /**
529
+ * The prompt to add the point of sale (AGL-4038), never a refusal: on the
530
+ * Hardware card before anything has arrived, naming the orders that have
531
+ * arrived once one has, and at the register.
532
+ */
533
+ export declare function posPlanPrompt(where?: {
534
+ arrived?: readonly string[];
535
+ atRegister?: boolean;
536
+ }): string;
467
537
  /** The collection under `orgs/{orgId}`, named once. */
468
538
  export declare const POS_HARDWARE_ORDERS_COLLECTION = "hardwareOrders";
469
539
  /** The top-level collection of retained hardware sale records. */
@@ -523,6 +593,7 @@ export interface PosHardwareSaleRecord {
523
593
  updatedAtMs: number;
524
594
  paidAtMs: number | null;
525
595
  orderedAtMs: number | null;
596
+ receivedAtMs: number | null;
526
597
  shippedAtMs: number | null;
527
598
  deliveredAtMs: number | null;
528
599
  registeredAtMs: number | null;
@@ -535,8 +606,9 @@ export interface PosHardwareSaleRecord {
535
606
  posOrderId: string | null;
536
607
  /**
537
608
  * Where the money went: `platform` for the Hardware card's checkout, on
538
- * the platform's own Stripe account; `seller_store` for an in-person sale,
539
- * the selling store's own takings ({@link PosHardwarePaidTo}).
609
+ * the platform's own Stripe account; `seller_store` for a sale by the
610
+ * platform's own store, in person or online, the selling store's own
611
+ * takings ({@link PosHardwarePaidTo}).
540
612
  */
541
613
  paidTo: {
542
614
  account: 'platform';
@@ -628,3 +700,17 @@ export declare function posHardwareBuyerErasedPatch(order: Pick<PosHardwareOrder
628
700
  export declare const POS_HARDWARE_ORDER_ID: RegExp;
629
701
  /** Dollars and cents for the card and the emails. */
630
702
  export declare function formatPosHardwareCents(cents: number): string;
703
+ /**
704
+ * Every reader an order ships, one unit each (AGL-4038): the units it holds,
705
+ * or, for an order recorded before units were kept for shipped orders, one
706
+ * per reader on its lines with nothing recorded yet. Accessories have none.
707
+ */
708
+ export declare function posHardwareOrderUnits(order: Pick<PosHardwareOrder, 'units' | 'lines'>): PosHardwareUnit[];
709
+ /**
710
+ * Why an order may not ship yet, or null when it may (AGL-4038): every
711
+ * reader on it is set up first, its serial number recorded, so the buyer's
712
+ * reader is matched to its order the moment they pair it, if it was not
713
+ * registered to their store already. An order of accessories alone ships as
714
+ * it is.
715
+ */
716
+ export declare function posHardwareReadyToShip(order: Pick<PosHardwareOrder, 'units' | 'lines'>): string | null;
@@ -46,6 +46,13 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
46
46
  ];
47
47
  /** The most of one item, and the most units, a single order may hold. */ export const POS_HARDWARE_MAX_PER_LINE = 10;
48
48
  export const POS_HARDWARE_MAX_UNITS = 20;
49
+ /**
50
+ * The Stripe Tax code every hardware line carries (AGL-4038): "General -
51
+ * Tangible Goods" (https://docs.stripe.com/tax/tax-codes), the physical good
52
+ * a reader or an accessory is. Without it a line takes the account's default
53
+ * code, which is software as a service, and would be taxed as software.
54
+ * Stripe's list has no narrower code for a card reader.
55
+ */ export const POS_HARDWARE_TAX_CODE = 'txcd_99999999';
49
56
  /** The env names the shop reads, named once for the reader and the docs. */ export const POS_HARDWARE_ENV = {
50
57
  /** `true` releases the shop. Absent or anything else keeps it hidden. */ enabled: 'POS_HARDWARE_SHOP_ENABLED',
51
58
  /** JSON `{ "<sku>": <Stripe's price in cents> }`. */ prices: 'POS_HARDWARE_PRICES',
@@ -77,38 +84,39 @@ export const POS_HARDWARE_MAX_UNITS = 20;
77
84
  id: 'stripe-reader-s710',
78
85
  kind: 'reader',
79
86
  stripeProductName: 'Stripe Reader S710',
80
- displayName: 'Stripe Reader S710',
81
- // 4G needs Stripe's cellular service, billed monthly per reader, which a
82
- // store turns on for its S710s where it is offered (AGL-4038): the reader
83
- // alone does not bring a connection.
84
- use: 'Handheld for events and parking lots; 4G needs Stripe’s cellular service, billed monthly'
87
+ // Plain names with the model in brackets, no maker's name (AGL-4038).
88
+ // "4G-capable", never "with 4G": 4G is a separate per-store monthly
89
+ // service, turned on where it is offered, and the reader alone does not
90
+ // bring a connection.
91
+ displayName: 'Touchscreen reader, 4G-capable (S710)',
92
+ use: 'Handheld for events and parking lots, on Wi-Fi. 4G is a separate monthly service, where offered'
85
93
  },
86
94
  {
87
95
  id: 'stripe-reader-s700',
88
96
  kind: 'reader',
89
97
  stripeProductName: 'Stripe Reader S700',
90
- displayName: 'Stripe Reader S700',
98
+ displayName: 'Touchscreen reader (S700)',
91
99
  use: 'Handheld or countertop reader on Wi-Fi'
92
100
  },
93
101
  {
94
102
  id: 'stripe-reader-t600',
95
103
  kind: 'reader',
96
104
  stripeProductName: 'Stripe Reader T600',
97
- displayName: 'Stripe Reader T600',
105
+ displayName: 'Countertop reader (T600)',
98
106
  use: 'Countertop reader on Wi-Fi, or on Ethernet with the hub'
99
107
  },
100
108
  {
101
109
  id: 'bbpos-wisepos-e',
102
110
  kind: 'reader',
103
111
  stripeProductName: 'BBPOS WisePOS E',
104
- displayName: 'BBPOS WisePOS E',
112
+ displayName: 'Countertop reader (WisePOS E)',
105
113
  use: 'Countertop reader on Wi-Fi'
106
114
  },
107
115
  {
108
116
  id: 'stripe-reader-m2',
109
117
  kind: 'reader',
110
118
  stripeProductName: 'Stripe Reader M2',
111
- displayName: 'Stripe Reader M2',
119
+ displayName: 'Pocket reader (M2)',
112
120
  use: `Pairs with the ${PLATFORM_BRAND_NAME} POS app on your phone or tablet by Bluetooth`
113
121
  },
114
122
  {
@@ -143,7 +151,7 @@ export const POS_HARDWARE_MAX_UNITS = 20;
143
151
  id: 'stripe-reader-charger',
144
152
  kind: 'accessory',
145
153
  stripeProductName: 'Stripe Reader Charger',
146
- displayName: 'Charger for Stripe readers',
154
+ displayName: 'Charger for card readers',
147
155
  use: 'A spare wall charger'
148
156
  },
149
157
  {
@@ -291,6 +299,24 @@ export function isPosHardwareSkuId(value) {
291
299
  if (!Number.isSafeInteger(markupBps) || markupBps < 0) return costCents;
292
300
  return costCents + Math.floor((costCents * markupBps + 5000) / 10000);
293
301
  }
302
+ /**
303
+ * ONE PRICE FOR ONE ITEM (AGL-4038). The platform's own store lists the same
304
+ * readers on its product pages, at prices set on the products, and the
305
+ * Hardware card prices them from the environment, Stripe's cost plus the
306
+ * markup. Two sources would quote two prices for one reader. So the item's
307
+ * listed price is the price wherever it is listed, and the Hardware card
308
+ * charges exactly what the product page shows. It never sells below cost: a
309
+ * listed price under Stripe's cost is a mistake on the product, and the card
310
+ * keeps the marked-up price for it instead. An item the store does not list
311
+ * is priced from the environment as before.
312
+ */ export function posHardwareOfferUnitCents(config, sku) {
313
+ var _config_listedCents;
314
+ const cost = config.costs[sku];
315
+ if (cost === undefined) return 0;
316
+ const listed = (_config_listedCents = config.listedCents) == null ? void 0 : _config_listedCents[sku];
317
+ if (typeof listed === 'number' && Number.isSafeInteger(listed) && listed >= cost) return listed;
318
+ return posHardwareUnitCents(cost, config.markupBps);
319
+ }
294
320
  /** The items on offer, readers first, in catalog order. */ export function posHardwareOffers(config) {
295
321
  return POS_HARDWARE_SKUS.flatMap((sku)=>{
296
322
  const cost = config.costs[sku.id];
@@ -301,7 +327,7 @@ export function isPosHardwareSkuId(value) {
301
327
  kind: sku.kind,
302
328
  name: sku.displayName,
303
329
  use: sku.use,
304
- unitCents: posHardwareUnitCents(cost, config.markupBps)
330
+ unitCents: posHardwareOfferUnitCents(config, sku.id)
305
331
  }
306
332
  ];
307
333
  });
@@ -409,6 +435,7 @@ export function decodePosHardwareLines(encoded) {
409
435
  export const POS_HARDWARE_ORDER_STATUSES = [
410
436
  'paid',
411
437
  'ordered',
438
+ 'received',
412
439
  'shipped',
413
440
  'delivered',
414
441
  'registered',
@@ -421,6 +448,7 @@ export function isPosHardwareOrderStatus(value) {
421
448
  /** What the merchant reads on the Hardware card. */ export const POS_HARDWARE_STATUS_LABELS = {
422
449
  paid: 'Order received',
423
450
  ordered: 'Being prepared',
451
+ received: 'Being prepared',
424
452
  shipped: 'Shipped',
425
453
  delivered: 'Delivered',
426
454
  registered: 'Set up',
@@ -430,6 +458,7 @@ export function isPosHardwareOrderStatus(value) {
430
458
  /** What staff read on the orders page: where the order is in fulfillment. */ export const POS_HARDWARE_STAFF_STATUS_LABELS = {
431
459
  paid: 'Paid',
432
460
  ordered: 'Ordered from Stripe',
461
+ received: 'Received',
433
462
  shipped: 'Shipped',
434
463
  delivered: 'Delivered',
435
464
  registered: 'Registered',
@@ -437,12 +466,18 @@ export function isPosHardwareOrderStatus(value) {
437
466
  refunded: 'Refunded'
438
467
  };
439
468
  /**
440
- * The forward steps staff may move an order through. Canceling and refunding
441
- * are separate acts with their own rule ({@link posHardwareRefundable}),
442
- * because each returns money.
469
+ * The forward steps staff may move an order through (AGL-4038): ordered from
470
+ * the supplier, received at the platform, set up, shipped with tracking,
471
+ * delivered, and set up on the buyer's store. Setting it up is not a status
472
+ * of its own: it is each reader's serial number recorded and, where the
473
+ * buyer's store can take it, the reader registered to that store
474
+ * ({@link posHardwareReadyToShip}), which shipping waits for. Canceling and
475
+ * refunding are separate acts with their own rule
476
+ * ({@link posHardwareRefundable}), because each returns money.
443
477
  */ const NEXT_STATUS = {
444
478
  paid: 'ordered',
445
- ordered: 'shipped',
479
+ ordered: 'received',
480
+ received: 'shipped',
446
481
  shipped: 'delivered',
447
482
  delivered: 'registered'
448
483
  };
@@ -455,15 +490,33 @@ export function nextPosHardwareStatus(status) {
455
490
  * ships. Once a parcel is on its way the money comes back through a return of
456
491
  * the hardware, which is a separate process this phase does not automate.
457
492
  */ export function posHardwareRefundable(status) {
458
- return status === 'paid' || status === 'ordered';
493
+ return status === 'paid' || status === 'ordered' || status === 'received';
459
494
  }
495
+ /** The statuses of an order that has not shipped yet, which a closure cancels and refunds. */ export const POS_HARDWARE_UNSHIPPED_STATUSES = [
496
+ 'paid',
497
+ 'ordered',
498
+ 'received'
499
+ ];
460
500
  export function posHardwareOrderSource(order) {
461
- return (order == null ? void 0 : order.source) === 'in_person' ? 'in_person' : 'online';
501
+ return (order == null ? void 0 : order.source) === 'in_person' ? 'in_person' : (order == null ? void 0 : order.source) === 'storefront' ? 'storefront' : 'online';
502
+ }
503
+ /**
504
+ * Whether an order was sold by the platform's own store (AGL-4038), at its
505
+ * register or online: paid into that store's own account, with the store's
506
+ * order behind it (`posSale`), and whose buyer may still be to attach. It is
507
+ * attached, refunded and counted on the tax return the same way either way.
508
+ */ export function isPosHardwareSellerStoreSale(order) {
509
+ const source = posHardwareOrderSource(order);
510
+ return source === 'in_person' || source === 'storefront';
511
+ }
512
+ /** Whether an order is shipped to its buyer, rather than handed over at a register. */ export function posHardwareShips(order) {
513
+ return posHardwareOrderSource(order) !== 'in_person';
462
514
  }
463
515
  export const POS_HARDWARE_RETURN_REASON_MAX = 500;
464
516
  /** The timestamp field each status stamps when it is reached. */ export const POS_HARDWARE_STATUS_STAMP = {
465
517
  paid: 'paidAtMs',
466
518
  ordered: 'orderedAtMs',
519
+ received: 'receivedAtMs',
467
520
  shipped: 'shippedAtMs',
468
521
  delivered: 'deliveredAtMs',
469
522
  registered: 'registeredAtMs',
@@ -471,6 +524,27 @@ export const POS_HARDWARE_RETURN_REASON_MAX = 500;
471
524
  refunded: 'refundedAtMs'
472
525
  };
473
526
  /** The Hardware card's anchor: Checkout returns to it and the emails link at it. */ export const POS_HARDWARE_ANCHOR = 'pos-hardware';
527
+ /**
528
+ * What the point of sale adds to a reader (AGL-4038), for the prompt a
529
+ * workspace without it sees: anyone may buy readers, and a reader takes
530
+ * payments at the register, which comes with the point of sale.
531
+ */ export const POS_PLAN_ADDS = 'registers that ring up sales, card payments on your readers, cash with change due, receipts and shift reports';
532
+ /**
533
+ * The prompt to add the point of sale (AGL-4038), never a refusal: on the
534
+ * Hardware card before anything has arrived, naming the orders that have
535
+ * arrived once one has, and at the register.
536
+ */ export function posPlanPrompt(where = {}) {
537
+ var _where_arrived;
538
+ const arrived = (_where_arrived = where.arrived) != null ? _where_arrived : [];
539
+ if (where.atRegister) {
540
+ return `A card reader takes payments at the register, which comes with the point of sale: ${POS_PLAN_ADDS}. Add it to start selling.`;
541
+ }
542
+ if (arrived.length) {
543
+ const one = arrived.length === 1;
544
+ return `${arrived.join(', ')} ${one ? 'has' : 'have'} arrived. To take payments with ${one ? 'it' : 'them'}, add the point of sale: ${POS_PLAN_ADDS}.`;
545
+ }
546
+ return `You can buy readers on any plan. To take payments with them, add the point of sale: ${POS_PLAN_ADDS}.`;
547
+ }
474
548
  /** The collection under `orgs/{orgId}`, named once. */ export const POS_HARDWARE_ORDERS_COLLECTION = 'hardwareOrders';
475
549
  /*==========================================
476
550
  * THE SALE RECORD THE PLATFORM KEEPS (AGL-4038).
@@ -662,6 +736,7 @@ const textOrNull = (value)=>typeof value === 'string' && value.trim() ? value.tr
662
736
  updatedAtMs: (_ref2 = (_order_updatedAtMs = order.updatedAtMs) != null ? _order_updatedAtMs : order.createdAtMs) != null ? _ref2 : 0,
663
737
  paidAtMs: stampOrNull(order.paidAtMs),
664
738
  orderedAtMs: stampOrNull(order.orderedAtMs),
739
+ receivedAtMs: stampOrNull(order.receivedAtMs),
665
740
  shippedAtMs: stampOrNull(order.shippedAtMs),
666
741
  deliveredAtMs: stampOrNull(order.deliveredAtMs),
667
742
  registeredAtMs: stampOrNull(order.registeredAtMs),
@@ -694,7 +769,7 @@ const textOrNull = (value)=>typeof value === 'string' && value.trim() ? value.tr
694
769
  /** Where a sale's money went, picked by name: never a buyer detail. */ function salePaidTo(order) {
695
770
  var _paidTo_hostId, _paidTo_orgId;
696
771
  const paidTo = order.paidTo;
697
- if (posHardwareOrderSource(order) !== 'in_person' || (paidTo == null ? void 0 : paidTo.account) !== 'seller_store') {
772
+ if (!isPosHardwareSellerStoreSale(order) || (paidTo == null ? void 0 : paidTo.account) !== 'seller_store') {
698
773
  return {
699
774
  account: 'platform'
700
775
  };
@@ -766,5 +841,40 @@ const textOrNull = (value)=>typeof value === 'string' && value.trim() ? value.tr
766
841
  currency: 'USD'
767
842
  }).format(value / 100);
768
843
  }
844
+ /**
845
+ * Every reader an order ships, one unit each (AGL-4038): the units it holds,
846
+ * or, for an order recorded before units were kept for shipped orders, one
847
+ * per reader on its lines with nothing recorded yet. Accessories have none.
848
+ */ export function posHardwareOrderUnits(order) {
849
+ var _order_lines;
850
+ if (Array.isArray(order.units) && order.units.length) return order.units;
851
+ const units = [];
852
+ for (const line of (_order_lines = order.lines) != null ? _order_lines : []){
853
+ var _posHardwareSku;
854
+ if (((_posHardwareSku = posHardwareSku(line.sku)) == null ? void 0 : _posHardwareSku.kind) !== 'reader') continue;
855
+ for(let index = 0; index < line.quantity; index += 1){
856
+ units.push({
857
+ sku: line.sku,
858
+ serialNumber: null,
859
+ readerId: null,
860
+ hostId: null,
861
+ registeredAtMs: null
862
+ });
863
+ }
864
+ }
865
+ return units;
866
+ }
867
+ /**
868
+ * Why an order may not ship yet, or null when it may (AGL-4038): every
869
+ * reader on it is set up first, its serial number recorded, so the buyer's
870
+ * reader is matched to its order the moment they pair it, if it was not
871
+ * registered to their store already. An order of accessories alone ships as
872
+ * it is.
873
+ */ export function posHardwareReadyToShip(order) {
874
+ const units = posHardwareOrderUnits(order);
875
+ const missing = units.filter((unit)=>!unit.serialNumber).length;
876
+ if (!missing) return null;
877
+ return missing === units.length && units.length === 1 ? 'Set the reader up first: record its serial number.' : `Set every reader up first: ${missing} of ${units.length} still need a serial number.`;
878
+ }
769
879
 
770
880
  //# sourceMappingURL=pos-hardware.js.map