@owlmeans/server-payment 0.1.22-rc.0 → 0.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -54
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-payment/SKILL.md +272 -330
- package/agent-meta/skills/server-payment/parts/reference.md +3 -3
- package/build/access/types.d.ts +7 -16
- package/build/access/types.d.ts.map +1 -1
- package/build/access.d.ts.map +1 -1
- package/build/access.js +6 -8
- package/build/access.js.map +1 -1
- package/build/actions/resync.d.ts +3 -3
- package/build/actions/resync.js +5 -5
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +4 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +8 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/bootstrap/types.d.ts +13 -7
- package/build/bootstrap/types.d.ts.map +1 -1
- package/build/bootstrap.d.ts +4 -4
- package/build/bootstrap.d.ts.map +1 -1
- package/build/bootstrap.js +19 -10
- package/build/bootstrap.js.map +1 -1
- package/build/catalogue/types.d.ts +3 -3
- package/build/catalogue/types.d.ts.map +1 -1
- package/build/catalogue.d.ts.map +1 -1
- package/build/catalogue.js +4 -8
- package/build/catalogue.js.map +1 -1
- package/build/checkout/types.d.ts +21 -0
- package/build/checkout/types.d.ts.map +1 -0
- package/build/{plugins/stripe → checkout}/types.js.map +1 -1
- package/build/checkout.d.ts +6 -0
- package/build/checkout.d.ts.map +1 -0
- package/build/checkout.js +374 -0
- package/build/checkout.js.map +1 -0
- package/build/config.d.ts +10 -16
- package/build/config.d.ts.map +1 -1
- package/build/config.js +18 -59
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +3 -49
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +3 -61
- package/build/consts.js.map +1 -1
- package/build/consumer/cancellation/types.d.ts +6 -4
- package/build/consumer/cancellation/types.d.ts.map +1 -1
- package/build/consumer/cancellation.d.ts.map +1 -1
- package/build/consumer/cancellation.js +11 -5
- package/build/consumer/cancellation.js.map +1 -1
- package/build/consumer/capture/types.d.ts +8 -12
- package/build/consumer/capture/types.d.ts.map +1 -1
- package/build/consumer/capture.d.ts.map +1 -1
- package/build/consumer/capture.js +48 -53
- package/build/consumer/capture.js.map +1 -1
- package/build/consumer/index.d.ts +4 -0
- package/build/consumer/index.d.ts.map +1 -1
- package/build/consumer/index.js +2 -0
- package/build/consumer/index.js.map +1 -1
- package/build/consumer/reconcile.d.ts.map +1 -1
- package/build/consumer/reconcile.js +82 -72
- package/build/consumer/reconcile.js.map +1 -1
- package/build/consumer/records/types.d.ts +4 -4
- package/build/consumer/records/types.d.ts.map +1 -1
- package/build/consumer/records.d.ts.map +1 -1
- package/build/consumer/records.js +16 -13
- package/build/consumer/records.js.map +1 -1
- package/build/consumer/service.d.ts +2 -2
- package/build/consumer/service.d.ts.map +1 -1
- package/build/consumer/service.js +28 -21
- package/build/consumer/service.js.map +1 -1
- package/build/consumer/types.d.ts +1 -4
- package/build/consumer/types.d.ts.map +1 -1
- package/build/consumer/types.local.d.ts +1 -9
- package/build/consumer/types.local.d.ts.map +1 -1
- package/build/consumer/withdrawal/types.d.ts +14 -12
- package/build/consumer/withdrawal/types.d.ts.map +1 -1
- package/build/consumer/withdrawal.d.ts.map +1 -1
- package/build/consumer/withdrawal.js +55 -71
- package/build/consumer/withdrawal.js.map +1 -1
- package/build/index.d.ts +12 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -4
- package/build/index.js.map +1 -1
- package/build/paygate/providers.d.ts +13 -0
- package/build/paygate/providers.d.ts.map +1 -0
- package/build/paygate/providers.js +38 -0
- package/build/paygate/providers.js.map +1 -0
- package/build/paygate/registry.d.ts +6 -0
- package/build/paygate/registry.d.ts.map +1 -0
- package/build/paygate/registry.js +37 -0
- package/build/paygate/registry.js.map +1 -0
- package/build/paygate/types.d.ts +577 -0
- package/build/paygate/types.d.ts.map +1 -0
- package/build/{plugins/session → paygate}/types.js.map +1 -1
- package/build/plan/types.d.ts +6 -1
- package/build/plan/types.d.ts.map +1 -1
- package/build/plan.d.ts.map +1 -1
- package/build/plan.js +16 -2
- package/build/plan.js.map +1 -1
- package/build/plugins/checkout-policy/types.d.ts +5 -3
- package/build/plugins/checkout-policy/types.d.ts.map +1 -1
- package/build/plugins/checkout-policy.d.ts.map +1 -1
- package/build/plugins/checkout-policy.js +5 -3
- package/build/plugins/checkout-policy.js.map +1 -1
- package/build/plugins/consts.local.d.ts +8 -10
- package/build/plugins/consts.local.d.ts.map +1 -1
- package/build/plugins/consts.local.js +2 -19
- package/build/plugins/consts.local.js.map +1 -1
- package/build/plugins/customer-lock/types.d.ts +2 -2
- package/build/plugins/customer-lock/types.d.ts.map +1 -1
- package/build/plugins/customer-lock.js +2 -2
- package/build/plugins/customer-lock.js.map +1 -1
- package/build/plugins/estimate/cache.js +1 -1
- package/build/plugins/estimate/cache.js.map +1 -1
- package/build/plugins/estimate/types.d.ts +10 -10
- package/build/plugins/estimate/types.d.ts.map +1 -1
- package/build/plugins/estimate.d.ts.map +1 -1
- package/build/plugins/estimate.js +48 -122
- package/build/plugins/estimate.js.map +1 -1
- package/build/plugins/events/types.d.ts +17 -10
- package/build/plugins/events/types.d.ts.map +1 -1
- package/build/plugins/events.d.ts +6 -5
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +162 -173
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx/types.d.ts +10 -21
- package/build/plugins/fx/types.d.ts.map +1 -1
- package/build/plugins/fx.d.ts +1 -1
- package/build/plugins/fx.d.ts.map +1 -1
- package/build/plugins/fx.js +17 -54
- package/build/plugins/fx.js.map +1 -1
- package/build/plugins/portal/types.d.ts +8 -37
- package/build/plugins/portal/types.d.ts.map +1 -1
- package/build/plugins/portal.d.ts.map +1 -1
- package/build/plugins/portal.js +38 -208
- package/build/plugins/portal.js.map +1 -1
- package/build/plugins/refunds/types.d.ts +11 -11
- package/build/plugins/refunds/types.d.ts.map +1 -1
- package/build/plugins/refunds.d.ts.map +1 -1
- package/build/plugins/refunds.js +14 -39
- package/build/plugins/refunds.js.map +1 -1
- package/build/plugins/snapshot/types.d.ts +11 -0
- package/build/plugins/snapshot/types.d.ts.map +1 -0
- package/build/plugins/snapshot/types.js +2 -0
- package/build/plugins/snapshot/types.js.map +1 -0
- package/build/plugins/snapshot.d.ts +4 -0
- package/build/plugins/snapshot.d.ts.map +1 -0
- package/build/plugins/snapshot.js +19 -0
- package/build/plugins/snapshot.js.map +1 -0
- package/build/plugins/subscriptions/types.d.ts +17 -17
- package/build/plugins/subscriptions/types.d.ts.map +1 -1
- package/build/plugins/subscriptions.d.ts +4 -4
- package/build/plugins/subscriptions.d.ts.map +1 -1
- package/build/plugins/subscriptions.js +69 -77
- package/build/plugins/subscriptions.js.map +1 -1
- package/build/plugins/types.local.d.ts +9 -43
- package/build/plugins/types.local.d.ts.map +1 -1
- package/build/plugins/webhook-manager/types.d.ts +15 -43
- package/build/plugins/webhook-manager/types.d.ts.map +1 -1
- package/build/plugins/webhook-manager.d.ts +3 -3
- package/build/plugins/webhook-manager.d.ts.map +1 -1
- package/build/plugins/webhook-manager.js +21 -199
- package/build/plugins/webhook-manager.js.map +1 -1
- package/build/protocol.d.ts +1 -1
- package/build/protocol.d.ts.map +1 -1
- package/build/protocol.js +1 -1
- package/build/protocol.js.map +1 -1
- package/build/service.d.ts +11 -11
- package/build/service.d.ts.map +1 -1
- package/build/service.js +59 -23
- package/build/service.js.map +1 -1
- package/build/sync/types.d.ts +17 -13
- package/build/sync/types.d.ts.map +1 -1
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +22 -122
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +46 -101
- package/build/types.d.ts.map +1 -1
- package/build/utils/types.d.ts +0 -8
- package/build/utils/types.d.ts.map +1 -1
- package/build/utils.d.ts +1 -4
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +1 -15
- package/build/utils.js.map +1 -1
- package/package.json +20 -22
- package/src/access/types.ts +7 -16
- package/src/access.ts +7 -15
- package/src/actions/resync.ts +5 -5
- package/src/actions/webhook.ts +8 -4
- package/src/bootstrap/types.ts +13 -7
- package/src/bootstrap.ts +23 -13
- package/src/catalogue/types.ts +3 -3
- package/src/catalogue.ts +4 -8
- package/src/checkout/types.ts +21 -0
- package/src/checkout.ts +414 -0
- package/src/config.ts +19 -66
- package/src/consts.ts +3 -69
- package/src/consumer/cancellation/types.ts +6 -4
- package/src/consumer/cancellation.ts +13 -7
- package/src/consumer/capture/types.ts +8 -12
- package/src/consumer/capture.ts +50 -59
- package/src/consumer/index.ts +4 -0
- package/src/consumer/reconcile.ts +69 -68
- package/src/consumer/records/types.ts +4 -4
- package/src/consumer/records.ts +19 -14
- package/src/consumer/service.ts +35 -22
- package/src/consumer/types.local.ts +1 -8
- package/src/consumer/types.ts +1 -4
- package/src/consumer/withdrawal/types.ts +14 -12
- package/src/consumer/withdrawal.ts +61 -77
- package/src/index.ts +12 -6
- package/src/paygate/providers.ts +48 -0
- package/src/paygate/registry.ts +53 -0
- package/src/paygate/types.ts +640 -0
- package/src/plan/types.ts +6 -1
- package/src/plan.ts +21 -3
- package/src/plugins/checkout-policy/types.ts +5 -3
- package/src/plugins/checkout-policy.ts +6 -5
- package/src/plugins/consts.local.ts +2 -26
- package/src/plugins/customer-lock/types.ts +2 -2
- package/src/plugins/customer-lock.ts +2 -2
- package/src/plugins/estimate/cache.ts +1 -1
- package/src/plugins/estimate/types.ts +10 -10
- package/src/plugins/estimate.ts +52 -128
- package/src/plugins/events/types.ts +17 -9
- package/src/plugins/events.ts +172 -190
- package/src/plugins/fx/types.ts +10 -23
- package/src/plugins/fx.ts +28 -64
- package/src/plugins/portal/types.ts +8 -38
- package/src/plugins/portal.ts +48 -229
- package/src/plugins/refunds/types.ts +11 -11
- package/src/plugins/refunds.ts +16 -40
- package/src/plugins/snapshot/types.ts +11 -0
- package/src/plugins/snapshot.ts +22 -0
- package/src/plugins/subscriptions/types.ts +17 -17
- package/src/plugins/subscriptions.ts +81 -81
- package/src/plugins/types.local.ts +9 -33
- package/src/plugins/webhook-manager/types.ts +15 -43
- package/src/plugins/webhook-manager.ts +24 -220
- package/src/protocol.ts +1 -1
- package/src/service.ts +66 -30
- package/src/sync/types.ts +17 -13
- package/src/sync.ts +25 -143
- package/src/types.ts +47 -97
- package/src/utils/types.ts +0 -9
- package/src/utils.ts +2 -20
- package/tests/capabilities.spec.ts +219 -0
- package/tests/entitlement.spec.ts +4 -4
- package/tests/gate-handlers.spec.ts +6 -6
- package/tests/gate.spec.ts +2 -2
- package/tests/grants.spec.ts +2 -2
- package/tests/internal-plan.spec.ts +2 -2
- package/tests/limit-gate.spec.ts +2 -2
- package/tests/paygates.spec.ts +132 -0
- package/tests/protocol.spec.ts +4 -5
- package/tests/usage.spec.ts +2 -2
- package/tests/webhook.spec.ts +137 -0
- package/build/plugins/session/types.d.ts +0 -34
- package/build/plugins/session/types.d.ts.map +0 -1
- package/build/plugins/session.d.ts +0 -4
- package/build/plugins/session.d.ts.map +0 -1
- package/build/plugins/session.js +0 -71
- package/build/plugins/session.js.map +0 -1
- package/build/plugins/status.d.ts +0 -8
- package/build/plugins/status.d.ts.map +0 -1
- package/build/plugins/status.js +0 -21
- package/build/plugins/status.js.map +0 -1
- package/build/plugins/stripe/types.d.ts +0 -20
- package/build/plugins/stripe/types.d.ts.map +0 -1
- package/build/plugins/stripe.d.ts +0 -6
- package/build/plugins/stripe.d.ts.map +0 -1
- package/build/plugins/stripe.js +0 -518
- package/build/plugins/stripe.js.map +0 -1
- package/src/plugins/session/types.ts +0 -30
- package/src/plugins/session.ts +0 -86
- package/src/plugins/status.ts +0 -22
- package/src/plugins/stripe/types.ts +0 -20
- package/src/plugins/stripe.ts +0 -571
- package/tests/checkout-consumer.spec.ts +0 -366
- package/tests/checkout-locks.spec.ts +0 -161
- package/tests/checkout-plugins.spec.ts +0 -164
- package/tests/checkout.spec.ts +0 -313
- package/tests/consumer-events.spec.ts +0 -215
- package/tests/consumer-fixtures.ts +0 -141
- package/tests/consumer-ops.spec.ts +0 -361
- package/tests/consumer-rights.integration.spec.ts +0 -147
- package/tests/consumer-rights.spec.ts +0 -606
- package/tests/context.ts +0 -110
- package/tests/estimate.spec.ts +0 -350
- package/tests/events.spec.ts +0 -367
- package/tests/fake-stripe.ts +0 -1004
- package/tests/gateway-options.spec.ts +0 -180
- package/tests/portal.spec.ts +0 -202
- package/tests/sync.spec.ts +0 -114
- package/tests/usage.integration.spec.ts +0 -165
- package/tests/webhook-manager.spec.ts +0 -149
- /package/build/{plugins/session → checkout}/types.js +0 -0
- /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
|
|
4
|
-
(amount and quantity checkout, subscriptions, the customer portal
|
|
5
|
-
|
|
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
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
80
|
-
| `bootstrap` | `manage` | whether this process runs the bootstrap at boot; a forced one (`resync`, `
|
|
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.
|
|
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
|
|
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`, `
|
|
128
|
-
`originHelper`) and helpers bound to one context, reached through their accessor —
|
|
129
|
-
`
|
|
130
|
-
`
|
|
131
|
-
`
|
|
132
|
-
|
|
133
|
-
|
|
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
|
|
148
|
-
(`POST /payment-gate/webhook/:paygate
|
|
149
|
-
|
|
150
|
-
Ed25519-guarded repairs — `resync` (products, portal, webhook endpoint
|
|
151
|
-
(re-reads every live
|
|
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
|
|
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.
|
|
179
|
+
npx @owlmeans/agent-skills@^0.2.0-alpha.2
|
|
182
180
|
```
|
|
183
181
|
|
|
184
182
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/server-payment",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"version": "0.2.0-alpha.1",
|
|
5
|
+
"generatedAt": "2026-11-12T14:18:05.466Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|