@owlmeans/server-payment 0.1.21 → 0.2.0-alpha.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 (296) hide show
  1. package/README.md +52 -54
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/server-payment/SKILL.md +272 -330
  4. package/agent-meta/skills/server-payment/parts/reference.md +3 -3
  5. package/build/access/types.d.ts +7 -16
  6. package/build/access/types.d.ts.map +1 -1
  7. package/build/access.d.ts.map +1 -1
  8. package/build/access.js +6 -8
  9. package/build/access.js.map +1 -1
  10. package/build/actions/resync.d.ts +3 -3
  11. package/build/actions/resync.js +5 -5
  12. package/build/actions/resync.js.map +1 -1
  13. package/build/actions/webhook.d.ts +4 -1
  14. package/build/actions/webhook.d.ts.map +1 -1
  15. package/build/actions/webhook.js +8 -4
  16. package/build/actions/webhook.js.map +1 -1
  17. package/build/bootstrap/types.d.ts +13 -7
  18. package/build/bootstrap/types.d.ts.map +1 -1
  19. package/build/bootstrap.d.ts +4 -4
  20. package/build/bootstrap.d.ts.map +1 -1
  21. package/build/bootstrap.js +19 -10
  22. package/build/bootstrap.js.map +1 -1
  23. package/build/catalogue/types.d.ts +3 -3
  24. package/build/catalogue/types.d.ts.map +1 -1
  25. package/build/catalogue.d.ts.map +1 -1
  26. package/build/catalogue.js +4 -8
  27. package/build/catalogue.js.map +1 -1
  28. package/build/checkout/types.d.ts +21 -0
  29. package/build/checkout/types.d.ts.map +1 -0
  30. package/build/{plugins/stripe → checkout}/types.js.map +1 -1
  31. package/build/checkout.d.ts +6 -0
  32. package/build/checkout.d.ts.map +1 -0
  33. package/build/checkout.js +374 -0
  34. package/build/checkout.js.map +1 -0
  35. package/build/config.d.ts +10 -16
  36. package/build/config.d.ts.map +1 -1
  37. package/build/config.js +18 -59
  38. package/build/config.js.map +1 -1
  39. package/build/consts.d.ts +3 -49
  40. package/build/consts.d.ts.map +1 -1
  41. package/build/consts.js +3 -61
  42. package/build/consts.js.map +1 -1
  43. package/build/consumer/cancellation/types.d.ts +6 -4
  44. package/build/consumer/cancellation/types.d.ts.map +1 -1
  45. package/build/consumer/cancellation.d.ts.map +1 -1
  46. package/build/consumer/cancellation.js +11 -5
  47. package/build/consumer/cancellation.js.map +1 -1
  48. package/build/consumer/capture/types.d.ts +8 -12
  49. package/build/consumer/capture/types.d.ts.map +1 -1
  50. package/build/consumer/capture.d.ts.map +1 -1
  51. package/build/consumer/capture.js +48 -53
  52. package/build/consumer/capture.js.map +1 -1
  53. package/build/consumer/index.d.ts +4 -0
  54. package/build/consumer/index.d.ts.map +1 -1
  55. package/build/consumer/index.js +2 -0
  56. package/build/consumer/index.js.map +1 -1
  57. package/build/consumer/reconcile.d.ts.map +1 -1
  58. package/build/consumer/reconcile.js +82 -72
  59. package/build/consumer/reconcile.js.map +1 -1
  60. package/build/consumer/records/types.d.ts +4 -4
  61. package/build/consumer/records/types.d.ts.map +1 -1
  62. package/build/consumer/records.d.ts.map +1 -1
  63. package/build/consumer/records.js +16 -13
  64. package/build/consumer/records.js.map +1 -1
  65. package/build/consumer/service.d.ts +2 -2
  66. package/build/consumer/service.d.ts.map +1 -1
  67. package/build/consumer/service.js +28 -21
  68. package/build/consumer/service.js.map +1 -1
  69. package/build/consumer/types.d.ts +1 -4
  70. package/build/consumer/types.d.ts.map +1 -1
  71. package/build/consumer/types.local.d.ts +1 -9
  72. package/build/consumer/types.local.d.ts.map +1 -1
  73. package/build/consumer/withdrawal/types.d.ts +14 -12
  74. package/build/consumer/withdrawal/types.d.ts.map +1 -1
  75. package/build/consumer/withdrawal.d.ts.map +1 -1
  76. package/build/consumer/withdrawal.js +55 -71
  77. package/build/consumer/withdrawal.js.map +1 -1
  78. package/build/index.d.ts +12 -6
  79. package/build/index.d.ts.map +1 -1
  80. package/build/index.js +7 -4
  81. package/build/index.js.map +1 -1
  82. package/build/paygate/providers.d.ts +13 -0
  83. package/build/paygate/providers.d.ts.map +1 -0
  84. package/build/paygate/providers.js +38 -0
  85. package/build/paygate/providers.js.map +1 -0
  86. package/build/paygate/registry.d.ts +6 -0
  87. package/build/paygate/registry.d.ts.map +1 -0
  88. package/build/paygate/registry.js +37 -0
  89. package/build/paygate/registry.js.map +1 -0
  90. package/build/paygate/types.d.ts +577 -0
  91. package/build/paygate/types.d.ts.map +1 -0
  92. package/build/{plugins/session → paygate}/types.js.map +1 -1
  93. package/build/plan/types.d.ts +6 -1
  94. package/build/plan/types.d.ts.map +1 -1
  95. package/build/plan.d.ts.map +1 -1
  96. package/build/plan.js +16 -2
  97. package/build/plan.js.map +1 -1
  98. package/build/plugins/checkout-policy/types.d.ts +5 -3
  99. package/build/plugins/checkout-policy/types.d.ts.map +1 -1
  100. package/build/plugins/checkout-policy.d.ts.map +1 -1
  101. package/build/plugins/checkout-policy.js +5 -3
  102. package/build/plugins/checkout-policy.js.map +1 -1
  103. package/build/plugins/consts.local.d.ts +8 -10
  104. package/build/plugins/consts.local.d.ts.map +1 -1
  105. package/build/plugins/consts.local.js +2 -19
  106. package/build/plugins/consts.local.js.map +1 -1
  107. package/build/plugins/customer-lock/types.d.ts +2 -2
  108. package/build/plugins/customer-lock/types.d.ts.map +1 -1
  109. package/build/plugins/customer-lock.js +2 -2
  110. package/build/plugins/customer-lock.js.map +1 -1
  111. package/build/plugins/estimate/cache.js +1 -1
  112. package/build/plugins/estimate/cache.js.map +1 -1
  113. package/build/plugins/estimate/types.d.ts +10 -10
  114. package/build/plugins/estimate/types.d.ts.map +1 -1
  115. package/build/plugins/estimate.d.ts.map +1 -1
  116. package/build/plugins/estimate.js +48 -122
  117. package/build/plugins/estimate.js.map +1 -1
  118. package/build/plugins/events/types.d.ts +17 -10
  119. package/build/plugins/events/types.d.ts.map +1 -1
  120. package/build/plugins/events.d.ts +6 -5
  121. package/build/plugins/events.d.ts.map +1 -1
  122. package/build/plugins/events.js +162 -173
  123. package/build/plugins/events.js.map +1 -1
  124. package/build/plugins/fx/types.d.ts +10 -21
  125. package/build/plugins/fx/types.d.ts.map +1 -1
  126. package/build/plugins/fx.d.ts +1 -1
  127. package/build/plugins/fx.d.ts.map +1 -1
  128. package/build/plugins/fx.js +17 -54
  129. package/build/plugins/fx.js.map +1 -1
  130. package/build/plugins/portal/types.d.ts +8 -37
  131. package/build/plugins/portal/types.d.ts.map +1 -1
  132. package/build/plugins/portal.d.ts.map +1 -1
  133. package/build/plugins/portal.js +38 -208
  134. package/build/plugins/portal.js.map +1 -1
  135. package/build/plugins/refunds/types.d.ts +11 -11
  136. package/build/plugins/refunds/types.d.ts.map +1 -1
  137. package/build/plugins/refunds.d.ts.map +1 -1
  138. package/build/plugins/refunds.js +14 -39
  139. package/build/plugins/refunds.js.map +1 -1
  140. package/build/plugins/snapshot/types.d.ts +11 -0
  141. package/build/plugins/snapshot/types.d.ts.map +1 -0
  142. package/build/plugins/snapshot/types.js +2 -0
  143. package/build/plugins/snapshot/types.js.map +1 -0
  144. package/build/plugins/snapshot.d.ts +4 -0
  145. package/build/plugins/snapshot.d.ts.map +1 -0
  146. package/build/plugins/snapshot.js +19 -0
  147. package/build/plugins/snapshot.js.map +1 -0
  148. package/build/plugins/subscriptions/types.d.ts +17 -17
  149. package/build/plugins/subscriptions/types.d.ts.map +1 -1
  150. package/build/plugins/subscriptions.d.ts +4 -4
  151. package/build/plugins/subscriptions.d.ts.map +1 -1
  152. package/build/plugins/subscriptions.js +69 -77
  153. package/build/plugins/subscriptions.js.map +1 -1
  154. package/build/plugins/types.local.d.ts +9 -43
  155. package/build/plugins/types.local.d.ts.map +1 -1
  156. package/build/plugins/webhook-manager/types.d.ts +15 -43
  157. package/build/plugins/webhook-manager/types.d.ts.map +1 -1
  158. package/build/plugins/webhook-manager.d.ts +3 -3
  159. package/build/plugins/webhook-manager.d.ts.map +1 -1
  160. package/build/plugins/webhook-manager.js +21 -199
  161. package/build/plugins/webhook-manager.js.map +1 -1
  162. package/build/protocol.d.ts +1 -1
  163. package/build/protocol.d.ts.map +1 -1
  164. package/build/protocol.js +1 -1
  165. package/build/protocol.js.map +1 -1
  166. package/build/service.d.ts +11 -11
  167. package/build/service.d.ts.map +1 -1
  168. package/build/service.js +59 -23
  169. package/build/service.js.map +1 -1
  170. package/build/sync/types.d.ts +17 -13
  171. package/build/sync/types.d.ts.map +1 -1
  172. package/build/sync.d.ts.map +1 -1
  173. package/build/sync.js +22 -122
  174. package/build/sync.js.map +1 -1
  175. package/build/types.d.ts +46 -101
  176. package/build/types.d.ts.map +1 -1
  177. package/build/utils/types.d.ts +0 -8
  178. package/build/utils/types.d.ts.map +1 -1
  179. package/build/utils.d.ts +1 -4
  180. package/build/utils.d.ts.map +1 -1
  181. package/build/utils.js +1 -15
  182. package/build/utils.js.map +1 -1
  183. package/package.json +20 -22
  184. package/src/access/types.ts +7 -16
  185. package/src/access.ts +7 -15
  186. package/src/actions/resync.ts +5 -5
  187. package/src/actions/webhook.ts +8 -4
  188. package/src/bootstrap/types.ts +13 -7
  189. package/src/bootstrap.ts +23 -13
  190. package/src/catalogue/types.ts +3 -3
  191. package/src/catalogue.ts +4 -8
  192. package/src/checkout/types.ts +21 -0
  193. package/src/checkout.ts +414 -0
  194. package/src/config.ts +19 -66
  195. package/src/consts.ts +3 -69
  196. package/src/consumer/cancellation/types.ts +6 -4
  197. package/src/consumer/cancellation.ts +13 -7
  198. package/src/consumer/capture/types.ts +8 -12
  199. package/src/consumer/capture.ts +50 -59
  200. package/src/consumer/index.ts +4 -0
  201. package/src/consumer/reconcile.ts +69 -68
  202. package/src/consumer/records/types.ts +4 -4
  203. package/src/consumer/records.ts +19 -14
  204. package/src/consumer/service.ts +35 -22
  205. package/src/consumer/types.local.ts +1 -8
  206. package/src/consumer/types.ts +1 -4
  207. package/src/consumer/withdrawal/types.ts +14 -12
  208. package/src/consumer/withdrawal.ts +61 -77
  209. package/src/index.ts +12 -6
  210. package/src/paygate/providers.ts +48 -0
  211. package/src/paygate/registry.ts +53 -0
  212. package/src/paygate/types.ts +640 -0
  213. package/src/plan/types.ts +6 -1
  214. package/src/plan.ts +21 -3
  215. package/src/plugins/checkout-policy/types.ts +5 -3
  216. package/src/plugins/checkout-policy.ts +6 -5
  217. package/src/plugins/consts.local.ts +2 -26
  218. package/src/plugins/customer-lock/types.ts +2 -2
  219. package/src/plugins/customer-lock.ts +2 -2
  220. package/src/plugins/estimate/cache.ts +1 -1
  221. package/src/plugins/estimate/types.ts +10 -10
  222. package/src/plugins/estimate.ts +52 -128
  223. package/src/plugins/events/types.ts +17 -9
  224. package/src/plugins/events.ts +172 -190
  225. package/src/plugins/fx/types.ts +10 -23
  226. package/src/plugins/fx.ts +28 -64
  227. package/src/plugins/portal/types.ts +8 -38
  228. package/src/plugins/portal.ts +48 -229
  229. package/src/plugins/refunds/types.ts +11 -11
  230. package/src/plugins/refunds.ts +16 -40
  231. package/src/plugins/snapshot/types.ts +11 -0
  232. package/src/plugins/snapshot.ts +22 -0
  233. package/src/plugins/subscriptions/types.ts +17 -17
  234. package/src/plugins/subscriptions.ts +81 -81
  235. package/src/plugins/types.local.ts +9 -33
  236. package/src/plugins/webhook-manager/types.ts +15 -43
  237. package/src/plugins/webhook-manager.ts +24 -220
  238. package/src/protocol.ts +1 -1
  239. package/src/service.ts +66 -30
  240. package/src/sync/types.ts +17 -13
  241. package/src/sync.ts +25 -143
  242. package/src/types.ts +47 -97
  243. package/src/utils/types.ts +0 -9
  244. package/src/utils.ts +2 -20
  245. package/tests/capabilities.spec.ts +219 -0
  246. package/tests/entitlement.spec.ts +4 -4
  247. package/tests/gate-handlers.spec.ts +6 -6
  248. package/tests/gate.spec.ts +2 -2
  249. package/tests/grants.spec.ts +2 -2
  250. package/tests/internal-plan.spec.ts +2 -2
  251. package/tests/limit-gate.spec.ts +2 -2
  252. package/tests/paygates.spec.ts +132 -0
  253. package/tests/protocol.spec.ts +4 -5
  254. package/tests/usage.spec.ts +2 -2
  255. package/tests/webhook.spec.ts +137 -0
  256. package/build/plugins/session/types.d.ts +0 -34
  257. package/build/plugins/session/types.d.ts.map +0 -1
  258. package/build/plugins/session.d.ts +0 -4
  259. package/build/plugins/session.d.ts.map +0 -1
  260. package/build/plugins/session.js +0 -71
  261. package/build/plugins/session.js.map +0 -1
  262. package/build/plugins/status.d.ts +0 -8
  263. package/build/plugins/status.d.ts.map +0 -1
  264. package/build/plugins/status.js +0 -21
  265. package/build/plugins/status.js.map +0 -1
  266. package/build/plugins/stripe/types.d.ts +0 -20
  267. package/build/plugins/stripe/types.d.ts.map +0 -1
  268. package/build/plugins/stripe.d.ts +0 -6
  269. package/build/plugins/stripe.d.ts.map +0 -1
  270. package/build/plugins/stripe.js +0 -518
  271. package/build/plugins/stripe.js.map +0 -1
  272. package/src/plugins/session/types.ts +0 -30
  273. package/src/plugins/session.ts +0 -86
  274. package/src/plugins/status.ts +0 -22
  275. package/src/plugins/stripe/types.ts +0 -20
  276. package/src/plugins/stripe.ts +0 -571
  277. package/tests/checkout-consumer.spec.ts +0 -366
  278. package/tests/checkout-locks.spec.ts +0 -161
  279. package/tests/checkout-plugins.spec.ts +0 -164
  280. package/tests/checkout.spec.ts +0 -313
  281. package/tests/consumer-events.spec.ts +0 -215
  282. package/tests/consumer-fixtures.ts +0 -141
  283. package/tests/consumer-ops.spec.ts +0 -361
  284. package/tests/consumer-rights.integration.spec.ts +0 -147
  285. package/tests/consumer-rights.spec.ts +0 -606
  286. package/tests/context.ts +0 -110
  287. package/tests/estimate.spec.ts +0 -350
  288. package/tests/events.spec.ts +0 -367
  289. package/tests/fake-stripe.ts +0 -1004
  290. package/tests/gateway-options.spec.ts +0 -180
  291. package/tests/portal.spec.ts +0 -202
  292. package/tests/sync.spec.ts +0 -114
  293. package/tests/usage.integration.spec.ts +0 -165
  294. package/tests/webhook-manager.spec.ts +0 -149
  295. /package/build/{plugins/session → checkout}/types.js +0 -0
  296. /package/build/{plugins/stripe → paygate}/types.js +0 -0
package/README.md CHANGED
@@ -1,22 +1,21 @@
1
1
  # @owlmeans/server-payment
2
2
 
3
- Server-side payments for OwlMeans applications: a Stripe gateway embedded in the backend
4
- (amount and quantity checkout, subscriptions, the customer portal), a subscription store that
5
- understands the whole Stripe lifecycle, a usage ledger for counted plan limits, the entitlement
3
+ Server-side payments for OwlMeans applications: a provider-agnostic paygate host embedded in the
4
+ backend (amount and quantity checkout, subscriptions, the customer portal, refunds and disputes,
5
+ price estimates), a subscription store that understands a paygate subscription's whole lifecycle, the
6
+ EU consumer-rights records and functions, a usage ledger for counted plan limits, the entitlement
6
7
  service that resolves what an organization entity may do, and the two gate services that refuse a
7
8
  request before its handler runs. The contracts — plans, limits, promos, the entitlement view, the
8
- refusal errors — live in `@owlmeans/payment`.
9
+ refusal errors — live in `@owlmeans/payment`. A paygate is a payment provider package registered in
10
+ the context: the host names none and depends on none.
9
11
 
10
12
  ## Declare the catalogue
11
13
 
12
14
  ```typescript
13
15
  import { CheckoutPricingMode, LimitKind, LimitWindow, PlanDuration, ProductType } from '@owlmeans/payment'
14
- import {
15
- declarePaymentPlan, declarePaymentProduct, portalBranding, stripeSecrets,
16
- } from '@owlmeans/server-payment'
16
+ import { declarePaymentPlan, declarePaymentPricing, declarePaymentProduct } from '@owlmeans/server-payment'
17
17
 
18
- stripeSecrets(cfg, { api: '/secrets/stripe-key' }) // `webhook` is an optional override
19
- portalBranding(cfg, { returnUrl: 'https://app.example.com/billing', headline: 'Example' })
18
+ declarePaymentPricing(cfg, { tax: { automatic: true, collectTaxId: true, estimate: false }, currency: { estimate: false } })
20
19
 
21
20
  declarePaymentProduct(cfg, { sku: 'app-plans', type: ProductType.Service, services: ['app'], name: 'Plans' })
22
21
  declarePaymentPlan(cfg, {
@@ -42,16 +41,18 @@ declarePaymentPlan(cfg, {
42
41
 
43
42
  `declarePaymentPlan` validates each declaration before recording it;
44
43
  `makePlanDeclarationsModel(cfg).assertPlans()` checks the catalogue as a whole (one free plan per
45
- rank, no two paid plans of a product at one rank) and runs when the gateway initializes. A limit key
46
- may use a different kind on different plans — each kind keeps its own counter window, so a lifetime
47
- count still sticks to the entity when it moves to a monthly plan.
44
+ rank, no two paid plans of a product at one rank) and runs when the gateway initializes. A plan is
45
+ sold through the paygates its `gateways` (else its product's) name — neither declared means every
46
+ registered paygate. `declarePaymentPricing` takes the browser-safe policy only (`tax`, `currency`);
47
+ a provider declares its own settings through its own package.
48
48
 
49
49
  ## Wire the services
50
50
 
51
51
  ```typescript
52
52
  import { appendPaymentGatewayService, paymentAccessOf, paymentGateEntrypoints } from '@owlmeans/server-payment'
53
53
 
54
- appendPaymentGatewayService(context) // the process that owns Stripe
54
+ appendMyProvider(context) // a provider package's `append…`: registers its paygate, every process
55
+ appendPaymentGatewayService(context) // the process that talks to the paygates
55
56
  appendPaymentGatewayService(context, { manage: false }) // a process that only reads entitlements
56
57
  // several managed processes on one database — the same `owner` and `webhookService` in each:
57
58
  appendPaymentGatewayService(context, { owner: 'app-api', webhookService: 'app-hooks' }) // receives the webhook
@@ -66,44 +67,34 @@ paid.onDispute(async event => { /* … */ })
66
67
  paid.onPaymentFailed(async event => { /* notify */ })
67
68
  ```
68
69
 
69
- A managed gateway brings Stripe to the declared state at boot — products and prices, one
70
- customer-portal configuration, one webhook endpoint at this deployment's public URL (its signing
71
- secret stored in `payment-webhook`) — and each step is fingerprinted, so an unchanged deployment
72
- makes no Stripe call.
70
+ Payment providers register into a lazy service (`ensurePaymentProviders(ctx).register(provider)`);
71
+ `paygatesOf(ctx)` binds each once per context. A provider implements `PaymentProvider { id, features,
72
+ bind(ctx) }`: `customers` and `checkout` are required, `subscriptions`, `payments` (and
73
+ `creditNotes`), `webhook`, `catalogue`, `portal`, `tax` and `fx` optional — the host reacts to each
74
+ absence in a defined way (no recurring plans without `subscriptions`, review instead of a refund
75
+ without `payments`, `PortalUnavailable('paygate')` without `portal`, …). A declared policy feature a
76
+ registered paygate lacks fails the boot, and so does a managed, bootstrapping gateway without any
77
+ provider.
78
+
79
+ A managed gateway brings every paygate to the declared state at boot — products and prices, its
80
+ customer-portal configuration, one webhook endpoint at this deployment's public URL — each step
81
+ fingerprinted, so an unchanged deployment makes no paygate call.
73
82
 
74
83
  Three gateway options place that state when a deployment runs several processes:
75
84
 
76
85
  | Option | Default | Decides |
77
86
  |---|---|---|
78
- | `webhookService` | `cfg.service` | the `cfg.services` alias whose host and base form the webhook URL — also the portal's deployment key |
79
- | `owner` | `cfg.service` | the key of the `payment-webhook` rows, the signing-secret lookup, the `portal:<owner>` fingerprint and the Stripe labels |
80
- | `bootstrap` | `manage` | whether this process runs the bootstrap at boot; a forced one (`resync`, `stripeBootstrapOf(ctx).bootstrapStripe(stripe, { force: true })`) runs in any managed process |
87
+ | `webhookService` | `cfg.service` | the `cfg.services` alias whose host and base form the webhook URL (`/payment-gate/webhook/<paygate>`) — also the portal's deployment key |
88
+ | `owner` | `cfg.service` | the key of the `payment-webhook` rows, the signing-secret lookup and the paygate's own labels |
89
+ | `bootstrap` | `manage` | whether this process runs the bootstrap at boot; a forced one (`resync`, `paygateBootstrapOf(ctx).bootstrap({ force: true })`) runs in any managed process |
81
90
 
82
91
  Give every process of the database the same `owner` and `webhookService` (the process that receives
83
- the webhook), and keep `bootstrap` on that receiver only. Changing `webhookService` moves the
84
- endpoint on the next bootstrap: created at the new URL, the endpoint of the owner's former URL
85
- deleted, a new portal configuration for the new deployment key.
86
-
87
- Several deployments of one application may share a Stripe account (typically every test-mode
88
- deployment), each with its own database and URL — and a deployment's identity is its webhook URL,
89
- even an undeliverable local one.
90
-
91
- - **Webhook endpoint.** A deployment owns exactly the endpoint at its own URL: it deletes an
92
- endpoint only when its own `payment-webhook` rows name it — the endpoint of a URL it has moved away
93
- from — and never one it merely finds at another URL, whatever its metadata says. The endpoint of a
94
- retired deployment is removed by hand in the Stripe dashboard; one deleted from outside comes back
95
- on the next forced `resync`.
96
- - **Portal configuration.** Each deployment has its own, tagged
97
- `{ owlmeans: 'payment', service: <owner>, deployment: <webhook URL> }`. It updates the configuration its
98
- `portal:<owner>` fingerprint row names, unless that one is tagged for another deployment, and
99
- without a row adopts only a configuration carrying exactly its own tag. Stripe cannot delete a
100
- portal configuration, so one a deployment can no longer identify stays in the account and a new
101
- one is created.
92
+ the webhook), and keep `bootstrap` on that receiver only.
102
93
 
103
94
  ## Use it
104
95
 
105
96
  ```typescript
106
- const payments = paymentAccessOf(ctx) // the services, resources and settings of one context
97
+ const payments = paymentAccessOf(ctx) // the services, resources, settings and paygates of one context
107
98
 
108
99
  // Checkout and the portal (in-process; resolve the stable entityId at your authenticated boundary)
109
100
  const url = await payments.gateway().createLink(ctx, { productSku: 'app-plans', planSku: 'pro-monthly', entityId, service: 'app', successUrl })
@@ -124,13 +115,14 @@ await payments.entitlements().reconcileOccupancy(entityId, 'seats', liveSeatCoun
124
115
  ```
125
116
 
126
117
  The package's functionality comes as objects: pure helpers with a ready instance (`planHelper`,
127
- `subscriptionHelper`, `checkoutPolicyHelper`, `stripeSessionHelper`, `consumerFormatHelper`,
128
- `originHelper`) and helpers bound to one context, reached through their accessor — `paymentAccessOf(ctx)`,
129
- `catalogueOf(ctx)`, `usageOf(ctx)`, `subscriptionCommitOf(ctx)`, `productSyncOf(ctx)`,
130
- `stripeBootstrapOf(ctx)`, `reconcileOf(ctx)`, `checkoutPluginsOf(ctx)`, `stripeCheckoutOf(ctx)`,
131
- `stripeSubscriptionsOf(ctx)`, `portalOf(ctx)`, `webhookOf(ctx)`, `estimateOf(ctx)`, `consumerMailOf(ctx)`.
132
- The former free functions (`gateway`, `reconcileAll`, `webhookUrlOf`, …) remain as
133
- deprecated delegates.
118
+ `subscriptionHelper`, `checkoutPolicyHelper`, `checkoutSnapshotHelper`, `consumerFormatHelper`,
119
+ `originHelper`) and helpers bound to one context, reached through their accessor —
120
+ `paymentAccessOf(ctx)`, `paygatesOf(ctx)`, `catalogueOf(ctx)`, `usageOf(ctx)`,
121
+ `subscriptionCommitOf(ctx)`, `productSyncOf(ctx)`, `paygateBootstrapOf(ctx)`, `reconcileOf(ctx)`,
122
+ `checkoutPluginsOf(ctx)`, `checkoutOf(ctx)`, `paygateSubscriptionsOf(ctx)`, `paymentEventsOf(ctx)`,
123
+ `portalOf(ctx)`, `webhookOf(ctx)`, `estimateOf(ctx)`, `fxOf(ctx)`, `captureOf(ctx)`,
124
+ `consumerRecordsOf(ctx)`, `consumerMailOf(ctx)`. The former free functions (`gateway`,
125
+ `reconcileAll`, `webhookUrlOf`, …) remain as deprecated delegates.
134
126
 
135
127
  Routes declare what they need; the gates refuse before the handler:
136
128
 
@@ -144,11 +136,12 @@ The limit gate never consumes; the handler does.
144
136
 
145
137
  ## Routes
146
138
 
147
- `paymentGateEntrypoints` binds the immutable `paymentGate` tree: the public Stripe webhook
148
- (`POST /payment-gate/webhook/:paygate`, verified by signature over the raw body; a missing or
149
- unverifiable signature is a `PaygateSignatureError`, answered 400), and two
150
- Ed25519-guarded repairs — `resync` (products, portal, webhook endpoint) and `resyncSubscriptions`
151
- (re-reads every live Stripe subscription, answering `{ scanned, updated }`).
139
+ `paymentGateEntrypoints` binds the immutable `paymentGate` tree: the public webhook
140
+ (`POST /payment-gate/webhook/:paygate` — the paygate must be registered, else `UnknownPaygate`; it
141
+ verifies the signature over the raw body, a missing or unverifiable one is a `PaygateSignatureError`,
142
+ answered 400), and two Ed25519-guarded repairs — `resync` (products, portal, webhook endpoint of every
143
+ paygate) and `resyncSubscriptions` (re-reads every live paygate subscription, answering
144
+ `{ scanned, updated }`).
152
145
 
153
146
  An application that declares the gate itself — its own aliases, pinned to the service that receives
154
147
  the webhook — binds its declarations to the same actions instead, and registers nothing of
@@ -167,9 +160,14 @@ export const hookBindings = [
167
160
  ```
168
161
 
169
162
  Each handler runs in the context of the entrypoint it is bound to. The declarations keep
170
- `paymentGate`'s paths (the webhook URL registered with Stripe is formed from them), contracts and
163
+ `paymentGate`'s paths (the webhook URL a paygate is pointed at is formed from them), contracts and
171
164
  guards; bind each with `bind` — `bindAll` pairs a handler only with the declaration it was made for.
172
165
 
166
+ ## Testing
167
+
168
+ `@owlmeans/test-payment` builds a real server context over in-memory resources with a fake paygate
169
+ (`makeFakeContext`, `makeFakePaygate`) — what this package's own specs run on.
170
+
173
171
  <!-- owlmeans:agent-guidance:start -->
174
172
  ## Agent guidance
175
173
 
@@ -178,7 +176,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
178
176
  your project's skill store (`.agents/skills/`):
179
177
 
180
178
  ```sh
181
- npx @owlmeans/agent-skills@^0.1.21
179
+ npx @owlmeans/agent-skills@^0.2.0-alpha.0
182
180
  ```
183
181
 
184
182
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 3,
3
3
  "package": "@owlmeans/server-payment",
4
- "version": "0.1.21",
5
- "generatedAt": "2026-11-05T11:16:21.547Z",
4
+ "version": "0.2.0-alpha.0",
5
+ "generatedAt": "2026-11-09T19:44:59.523Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {