@owlmeans/server-payment 0.1.18-rc.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.
- package/README.md +55 -0
- package/agent-meta/manifest.json +16 -0
- package/agent-meta/skills/server-payment/SKILL.md +80 -0
- package/build/actions/index.d.ts +3 -0
- package/build/actions/index.d.ts.map +1 -0
- package/build/actions/index.js +3 -0
- package/build/actions/index.js.map +1 -0
- package/build/actions/resync.d.ts +2 -0
- package/build/actions/resync.d.ts.map +1 -0
- package/build/actions/resync.js +11 -0
- package/build/actions/resync.js.map +1 -0
- package/build/actions/webhook.d.ts +4 -0
- package/build/actions/webhook.d.ts.map +1 -0
- package/build/actions/webhook.js +11 -0
- package/build/actions/webhook.js.map +1 -0
- package/build/config.d.ts +8 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +46 -0
- package/build/config.js.map +1 -0
- package/build/consts.d.ts +26 -0
- package/build/consts.d.ts.map +1 -0
- package/build/consts.js +33 -0
- package/build/consts.js.map +1 -0
- package/build/entrypoints.d.ts +5 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +10 -0
- package/build/entrypoints.js.map +1 -0
- package/build/gate.d.ts +10 -0
- package/build/gate.d.ts.map +1 -0
- package/build/gate.js +37 -0
- package/build/gate.js.map +1 -0
- package/build/index.d.ts +12 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +11 -0
- package/build/index.js.map +1 -0
- package/build/model.d.ts +6 -0
- package/build/model.d.ts.map +1 -0
- package/build/model.js +33 -0
- package/build/model.js.map +1 -0
- package/build/observer.d.ts +4 -0
- package/build/observer.d.ts.map +1 -0
- package/build/observer.js +24 -0
- package/build/observer.js.map +1 -0
- package/build/plugins/events.d.ts +16 -0
- package/build/plugins/events.d.ts.map +1 -0
- package/build/plugins/events.js +195 -0
- package/build/plugins/events.js.map +1 -0
- package/build/plugins/stripe.d.ts +14 -0
- package/build/plugins/stripe.d.ts.map +1 -0
- package/build/plugins/stripe.js +166 -0
- package/build/plugins/stripe.js.map +1 -0
- package/build/resource.d.ts +6 -0
- package/build/resource.d.ts.map +1 -0
- package/build/resource.js +32 -0
- package/build/resource.js.map +1 -0
- package/build/service.d.ts +4 -0
- package/build/service.d.ts.map +1 -0
- package/build/service.js +35 -0
- package/build/service.js.map +1 -0
- package/build/sync.d.ts +5 -0
- package/build/sync.d.ts.map +1 -0
- package/build/sync.js +93 -0
- package/build/sync.js.map +1 -0
- package/build/types.d.ts +189 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/utils.d.ts +14 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +18 -0
- package/build/utils.js.map +1 -0
- package/package.json +54 -0
- package/src/actions/index.ts +2 -0
- package/src/actions/resync.ts +13 -0
- package/src/actions/webhook.ts +12 -0
- package/src/config.ts +53 -0
- package/src/consts.ts +47 -0
- package/src/entrypoints.ts +10 -0
- package/src/gate.ts +51 -0
- package/src/index.ts +13 -0
- package/src/model.ts +37 -0
- package/src/observer.ts +27 -0
- package/src/plugins/events.ts +181 -0
- package/src/plugins/stripe.ts +183 -0
- package/src/resource.ts +51 -0
- package/src/service.ts +35 -0
- package/src/sync.ts +97 -0
- package/src/types.ts +157 -0
- package/src/utils.ts +33 -0
- package/tests/checkout.spec.ts +135 -0
- package/tests/gate.spec.ts +97 -0
- package/tests/protocol.spec.ts +20 -0
- package/tests/tsconfig.json +5 -0
- package/tsconfig.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @owlmeans/server-payment
|
|
2
|
+
|
|
3
|
+
Public server-side payment primitives for OwlMeans applications. The package registers payment
|
|
4
|
+
resources, the entitlement gate, protocol-bound webhook/resync entrypoints, and a Stripe gateway
|
|
5
|
+
supporting amount-priced consumables, quantity-priced consumables, and subscriptions.
|
|
6
|
+
|
|
7
|
+
Applications declare products and plans during configuration, mount `paymentGateEntrypoints`, and
|
|
8
|
+
register completion callbacks on the payment observer. Amount policies are validated at declaration
|
|
9
|
+
time. Stripe Checkout is always authoritative: completion is idempotent by session id and an
|
|
10
|
+
amount checkout is fulfilled only after its paid currency and subtotal match its signed-in metadata.
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { CheckoutPricingMode, PlanDuration, ProductType } from '@owlmeans/payment'
|
|
14
|
+
import {
|
|
15
|
+
appendPaymentGatewayService, declarePaymentPlan, declarePaymentProduct, observer,
|
|
16
|
+
} from '@owlmeans/server-payment'
|
|
17
|
+
|
|
18
|
+
declarePaymentProduct(cfg, {
|
|
19
|
+
sku: 'app-credits', type: ProductType.Consumable, services: ['app'], gateways: ['stripe'],
|
|
20
|
+
name: 'Credits',
|
|
21
|
+
})
|
|
22
|
+
declarePaymentPlan(cfg, {
|
|
23
|
+
productSku: 'app-credits', sku: 'app-credit-unit', duration: PlanDuration.Consumable,
|
|
24
|
+
price: 0.02, pricingMode: CheckoutPricingMode.Amount,
|
|
25
|
+
amountPolicy: {
|
|
26
|
+
currency: 'usd', minimumMinor: 500, maximumMinor: 50_000, defaultMinor: 1_000,
|
|
27
|
+
presetsMinor: [1_000, 2_000, 5_000, 10_000], fixedMinor: 0, rateBps: 200,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
appendPaymentGatewayService(context)
|
|
32
|
+
observer(context).onTopUp(async completion => {
|
|
33
|
+
if (completion.mode === 'amount') await credit(completion.entityId, completion.amountMinor)
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Mount `paymentGateEntrypoints` in the server entrypoint list. `gateway(context).createLink(...)`
|
|
38
|
+
accepts the stable organization `entityId` only after the application has resolved it at its
|
|
39
|
+
authenticated boundary; public protocol bodies use `entitySlug`.
|
|
40
|
+
|
|
41
|
+
<!-- owlmeans:agent-guidance:start -->
|
|
42
|
+
## Agent guidance
|
|
43
|
+
|
|
44
|
+
This package ships embedded agent skills under `agent-meta/`. After installing your
|
|
45
|
+
`@owlmeans/*` packages, run the OwlMeans agent-skills installer to place them into
|
|
46
|
+
your project's skill store (`.agents/skills/`):
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.16
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The embedded files are version-matched to this package release. Do not edit them
|
|
53
|
+
directly — they are regenerated on each publish. To contribute guidance edits,
|
|
54
|
+
open a PR against the source monorepo.
|
|
55
|
+
<!-- owlmeans:agent-guidance:end -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 2,
|
|
3
|
+
"package": "@owlmeans/server-payment",
|
|
4
|
+
"version": "0.1.18-rc.0",
|
|
5
|
+
"generatedAt": "2026-09-12T12:32:46.376Z",
|
|
6
|
+
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
|
+
"entries": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "skill",
|
|
10
|
+
"name": "server-payment",
|
|
11
|
+
"category": "package-specific",
|
|
12
|
+
"file": "skills/server-payment/SKILL.md",
|
|
13
|
+
"canonicalPath": ".agents/skills/server-payment/SKILL.md"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: server-payment
|
|
3
|
+
description: Public in-process Stripe gateway for OwlMeans backends — amount and quantity checkout, subscriptions, protocol-bound webhook routes, product sync, fulfillment observers and entitlement gates. Use when wiring @owlmeans/server-payment or changing Stripe payment behavior.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
7
|
+
|
|
8
|
+
# @owlmeans/server-payment
|
|
9
|
+
|
|
10
|
+
Public MIT package in the common monorepo. It embeds Stripe into an application backend; the
|
|
11
|
+
consumer owns products, credit conversion and entitlement side effects. It persists customers,
|
|
12
|
+
subscriptions/fulfilled sessions and sync fingerprints in Mongo.
|
|
13
|
+
|
|
14
|
+
## Wiring
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
stripeSecrets(cfg, { api: '/secrets/stripe-key', webhook: '/secrets/stripe-webhook' })
|
|
18
|
+
declarePaymentProduct(cfg, { sku: 'credits', type: ProductType.Consumable,
|
|
19
|
+
services: ['app'], name: 'Credits', taxCode: 'txcd_10103000' })
|
|
20
|
+
declarePaymentPlan(cfg, { productSku: 'credits', sku: 'credits-unit',
|
|
21
|
+
duration: PlanDuration.Consumable, price: 0.02,
|
|
22
|
+
pricingMode: CheckoutPricingMode.Amount, amountPolicy })
|
|
23
|
+
|
|
24
|
+
appendPaymentGatewayService(context)
|
|
25
|
+
export const appEntrypoints = [...paymentGateEntrypoints]
|
|
26
|
+
observer(context).onTopUp(async completion => { /* append an idempotent ledger event */ })
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`declarePaymentPlan` validates amount and quantity policies immediately. An amount plan requires
|
|
30
|
+
`amountPolicy`; a quantity/legacy plan may declare `quantityPolicy` or the legacy min/default/max
|
|
31
|
+
fields. `gateway(ctx).createLink(...)` takes the stable internal `entityId`; an authenticated public
|
|
32
|
+
handler must resolve that id from its request entity before calling the in-process service.
|
|
33
|
+
|
|
34
|
+
## Checkout modes
|
|
35
|
+
|
|
36
|
+
- `Amount`: validate `amountMinor`, compute `chargeAmountMinor`, create one inline
|
|
37
|
+
`price_data` item for the synchronized Stripe Product, quantity 1, tax-exclusive, with no
|
|
38
|
+
adjustable quantity and no promotion codes. No reusable Stripe Price is created; a superseded
|
|
39
|
+
quantity Price under the plan lookup key is deactivated.
|
|
40
|
+
- `Quantity`: load the reusable Stripe Price and create an adjustable item from the quantity
|
|
41
|
+
policy. This remains supported so existing consumers and already-open Checkout sessions work.
|
|
42
|
+
- Subscription: reusable recurring Stripe Price, quantity 1, with billing portal management.
|
|
43
|
+
|
|
44
|
+
Every session enables automatic tax, billing address and tax-id collection. Amount metadata carries
|
|
45
|
+
pricing mode, net amount, adjusted pre-tax subtotal, currency, product, plan, service and owner.
|
|
46
|
+
|
|
47
|
+
## Fulfillment
|
|
48
|
+
|
|
49
|
+
Handle both `checkout.session.completed` and `checkout.session.async_payment_succeeded`, but grant
|
|
50
|
+
nothing until `payment_status === 'paid'`. Amount fulfillment compares Stripe currency and actual
|
|
51
|
+
`amount_subtotal` with the server-created metadata. Completion is discriminated:
|
|
52
|
+
|
|
53
|
+
- `{ mode: 'amount', amountMinor, chargeAmountMinor, currency, ... }`
|
|
54
|
+
- `{ mode: 'quantity', units, ... }`
|
|
55
|
+
|
|
56
|
+
The session id is `externalId`. A pending fulfillment record is created before calling observers
|
|
57
|
+
and gets `fulfilledAt` only after they succeed; observer failures escape so Stripe retries. Consumer
|
|
58
|
+
callbacks must still use `externalId` as their own append-only event key, covering a crash after the
|
|
59
|
+
side effect and before `fulfilledAt`. A session without pricing-mode metadata is a legacy quantity
|
|
60
|
+
session and remains fulfillable.
|
|
61
|
+
|
|
62
|
+
Subscription observers receive `{ isNew, status, capabilities, limits, ... }`. One-time bundles go
|
|
63
|
+
behind `isNew` and use an idempotent external event key. Status updates and entitlement provisioning
|
|
64
|
+
must be safe to repeat.
|
|
65
|
+
|
|
66
|
+
## Protocols and security
|
|
67
|
+
|
|
68
|
+
`paymentGate` is an immutable protocol tree. `paymentGateEntrypoints` binds its base, webhook, and
|
|
69
|
+
resync declarations directly with `bind(protocol, handler)`; the webhook is public because Stripe
|
|
70
|
+
signature verification requires the untouched raw body, while resync carries the ED25519 guard.
|
|
71
|
+
Never put an application auth guard on the Stripe webhook.
|
|
72
|
+
|
|
73
|
+
`appendPaymentGatewayService` also registers `ENTITLEMENT_GATE`. Paid capabilities belong on shared
|
|
74
|
+
route declarations through `entitled(...)`, not in handlers. The gate fails closed when the
|
|
75
|
+
subscription store cannot be read.
|
|
76
|
+
|
|
77
|
+
## External docs
|
|
78
|
+
|
|
79
|
+
- https://docs.stripe.com/api/checkout/sessions/create — Checkout accepts inline `price_data` with integer minor-unit `unit_amount`; automatic tax is enabled on the Session and amount items are tax-exclusive.
|
|
80
|
+
- https://docs.stripe.com/checkout/fulfillment — Fulfillment must be idempotent, check payment state and support delayed-payment success events rather than trusting completion alone.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resync.d.ts","sourceRoot":"","sources":["../../src/actions/resync.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,MAAM,0JAIjB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { handlers } from '@owlmeans/server-api';
|
|
2
|
+
import { paymentGate } from '../consts.js';
|
|
3
|
+
import { fingerprints } from '../utils.js';
|
|
4
|
+
import { initialize } from '../sync.js';
|
|
5
|
+
const bind = handlers();
|
|
6
|
+
export const resync = bind.request(paymentGate.resync, async (_request, context) => {
|
|
7
|
+
await fingerprints(context).clear();
|
|
8
|
+
await initialize(context);
|
|
9
|
+
return { ok: true };
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=resync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resync.js","sourceRoot":"","sources":["../../src/actions/resync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,MAAM,IAAI,GAAG,QAAQ,EAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;IACjF,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;IACnC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAA;IACzB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AACrB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO;;cAGlB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UnknownPaygate } from '@owlmeans/payment';
|
|
2
|
+
import { handlers } from '@owlmeans/server-api';
|
|
3
|
+
import { paymentGate, STRIPE_PAYGATE_ALIAS } from '../consts.js';
|
|
4
|
+
import { stripePlugin } from '../plugins/stripe.js';
|
|
5
|
+
const bind = handlers();
|
|
6
|
+
export const webhook = bind.params(paymentGate.webhook, async ({ paygate }, context, request) => {
|
|
7
|
+
if (paygate !== STRIPE_PAYGATE_ALIAS)
|
|
8
|
+
throw new UnknownPaygate(paygate);
|
|
9
|
+
await stripePlugin.handleWebhook(request, context);
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGnD,MAAM,IAAI,GAAG,QAAQ,EAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC9F,IAAI,OAAO,KAAK,oBAAoB;QAAE,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;IACvE,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config, PaymentPlanDef, PaymentProductDef } from './types.js';
|
|
2
|
+
export declare const declarePaymentProduct: (cfg: Config, def: PaymentProductDef) => void;
|
|
3
|
+
export declare const declarePaymentPlan: (cfg: Config, def: PaymentPlanDef) => void;
|
|
4
|
+
export declare const stripeSecrets: (cfg: Config, paths: {
|
|
5
|
+
api: string;
|
|
6
|
+
webhook: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAe,cAAc,EAAkB,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAExG,eAAO,MAAM,qBAAqB,QAAS,MAAM,OAAO,iBAAiB,KAAG,IAS3E,CAAA;AAED,eAAO,MAAM,kBAAkB,QAAS,MAAM,OAAO,cAAc,KAAG,IA4BrE,CAAA;AAED,eAAO,MAAM,aAAa,QAAS,MAAM,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,IAEpF,CAAA"}
|
package/build/config.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { toConfigRecord } from '@owlmeans/server-app';
|
|
2
|
+
import { plugin } from '@owlmeans/config';
|
|
3
|
+
import { assertAmountCheckoutPolicy, assertQuantityCheckoutPolicy, CheckoutPricingMode, PLAN_RECORD_PREFIX, PLAN_RECORD_TYPE, PlanStatus, PRODUCT_RECORD_PREFIX, PRODUCT_RECORD_TYPE, } from '@owlmeans/payment';
|
|
4
|
+
import { STRIPE_PAYGATE_ALIAS, STRIPE_PLUGIN_CONFIG } from './consts.js';
|
|
5
|
+
export const declarePaymentProduct = (cfg, def) => {
|
|
6
|
+
cfg.records = cfg.records ?? [];
|
|
7
|
+
const product = {
|
|
8
|
+
type: def.type, sku: def.sku, title: def.name, description: def.description,
|
|
9
|
+
defaultLng: def.defaultLng ?? 'en', services: def.services,
|
|
10
|
+
gateways: def.gateways ?? [STRIPE_PAYGATE_ALIAS], capabilities: def.capabilities,
|
|
11
|
+
taxCode: def.taxCode, unitLabel: def.unitLabel,
|
|
12
|
+
};
|
|
13
|
+
cfg.records.push({ ...toConfigRecord(product), recordType: PRODUCT_RECORD_TYPE, id: `${PRODUCT_RECORD_PREFIX}:${def.sku}` });
|
|
14
|
+
};
|
|
15
|
+
export const declarePaymentPlan = (cfg, def) => {
|
|
16
|
+
cfg.records = cfg.records ?? [];
|
|
17
|
+
const pricingMode = def.pricingMode;
|
|
18
|
+
if (pricingMode === CheckoutPricingMode.Amount) {
|
|
19
|
+
if (def.amountPolicy == null)
|
|
20
|
+
throw new TypeError(`Amount checkout plan '${def.sku}' requires amountPolicy`);
|
|
21
|
+
assertAmountCheckoutPolicy(def.amountPolicy);
|
|
22
|
+
}
|
|
23
|
+
const quantityPolicy = def.quantityPolicy ?? (def.minQuantity != null || def.maxQuantity != null || def.defaultQuantity != null
|
|
24
|
+
? {
|
|
25
|
+
minimum: def.minQuantity ?? 1,
|
|
26
|
+
maximum: def.maxQuantity ?? Math.max(100_000, def.minQuantity ?? 1),
|
|
27
|
+
default: def.defaultQuantity ?? def.minQuantity ?? 1,
|
|
28
|
+
}
|
|
29
|
+
: undefined);
|
|
30
|
+
if (quantityPolicy != null)
|
|
31
|
+
assertQuantityCheckoutPolicy(quantityPolicy);
|
|
32
|
+
const plan = {
|
|
33
|
+
productSku: def.productSku, sku: def.sku, status: PlanStatus.Active,
|
|
34
|
+
duration: def.duration, price: def.price, currency: def.currency ?? def.amountPolicy?.currency ?? 'usd',
|
|
35
|
+
order: def.order ?? 0, title: def.title ?? def.sku, capabilities: def.capabilities,
|
|
36
|
+
limits: def.limits, recurring: def.recurring, pricingMode, amountPolicy: def.amountPolicy,
|
|
37
|
+
quantityPolicy,
|
|
38
|
+
minQuantity: quantityPolicy?.minimum, maxQuantity: quantityPolicy?.maximum,
|
|
39
|
+
defaultQuantity: quantityPolicy?.default,
|
|
40
|
+
};
|
|
41
|
+
cfg.records.push({ ...toConfigRecord(plan), recordType: PLAN_RECORD_TYPE, id: `${PLAN_RECORD_PREFIX}:${def.sku}` });
|
|
42
|
+
};
|
|
43
|
+
export const stripeSecrets = (cfg, paths) => {
|
|
44
|
+
plugin(cfg, { api: paths.api, webhook: paths.webhook }, STRIPE_PLUGIN_CONFIG);
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EACL,0BAA0B,EAAE,4BAA4B,EAAE,mBAAmB,EAC7E,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,EAAE,qBAAqB,EAAE,mBAAmB,GAC7F,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAW,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,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,EAAE,GAAG,kBAAkB,IAAI,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,KAAuC,EAAQ,EAAE;IAC1F,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,oBAAoB,CAAC,CAAA;AAC/E,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const STRIPE_PAYGATE_ALIAS = "stripe";
|
|
2
|
+
export declare const STRIPE_PLUGIN_CONFIG = "_external:stripe";
|
|
3
|
+
export declare const STRIPE_SIGNATURE = "Stripe-Signature";
|
|
4
|
+
export declare const GATEWAY_SERVICE = "payment-gateway";
|
|
5
|
+
export declare const PAYMENT_OBSERVER = "payment-observer";
|
|
6
|
+
export declare const RES_PAYGATE_CUSTOMER = "payment-paygate-customer";
|
|
7
|
+
export declare const RES_PAYMENT_SUBSCRIPTION = "payment-subscription";
|
|
8
|
+
export declare const RES_PAYMENT_FINGERPRINT = "payment-fingerprint";
|
|
9
|
+
export declare const COMPLETION_TOP_UP = "top-up";
|
|
10
|
+
export declare const COMPLETION_SUBSCRIPTION = "subscription";
|
|
11
|
+
export interface PaygateParams {
|
|
12
|
+
paygate: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ResyncResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Embedded gateway protocol tree; the alias strings are private adapter details. */
|
|
18
|
+
export declare const paymentGate: {
|
|
19
|
+
readonly base: import("@owlmeans/entrypoint").EntrypointProtocol<{}, undefined>;
|
|
20
|
+
readonly webhook: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
21
|
+
params: PaygateParams;
|
|
22
|
+
}, undefined>;
|
|
23
|
+
readonly resync: import("@owlmeans/entrypoint").EntrypointProtocol<{}, ResyncResult>;
|
|
24
|
+
};
|
|
25
|
+
export declare const paymentGateProtocols: import("@owlmeans/entrypoint").EntrypointProtocolDeclaration[];
|
|
26
|
+
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAC5C,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AACtD,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AAClD,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAChD,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AAClD,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAC9D,eAAO,MAAM,wBAAwB,yBAAyB,CAAA;AAC9D,eAAO,MAAM,uBAAuB,wBAAwB,CAAA;AAC5D,eAAO,MAAM,iBAAiB,WAAW,CAAA;AACzC,eAAO,MAAM,uBAAuB,iBAAiB,CAAA;AAErD,MAAM,WAAW,aAAa;IAAG,OAAO,EAAE,MAAM,CAAA;CAAE;AAClD,MAAM,WAAW,YAAY;IAAG,EAAE,EAAE,OAAO,CAAA;CAAE;AAe7C,qFAAqF;AACrF,eAAO,MAAM,WAAW;;;;;;CAWd,CAAA;AAEV,eAAO,MAAM,oBAAoB,gEAAyB,CAAA"}
|
package/build/consts.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { contract, protocol, protocols, schema, typed } from '@owlmeans/entrypoint';
|
|
2
|
+
import { backend, route, RouteMethod } from '@owlmeans/route';
|
|
3
|
+
import { GUARD_ED25519 } from '@owlmeans/server-app';
|
|
4
|
+
export const STRIPE_PAYGATE_ALIAS = 'stripe';
|
|
5
|
+
export const STRIPE_PLUGIN_CONFIG = '_external:stripe';
|
|
6
|
+
export const STRIPE_SIGNATURE = 'Stripe-Signature';
|
|
7
|
+
export const GATEWAY_SERVICE = 'payment-gateway';
|
|
8
|
+
export const PAYMENT_OBSERVER = 'payment-observer';
|
|
9
|
+
export const RES_PAYGATE_CUSTOMER = 'payment-paygate-customer';
|
|
10
|
+
export const RES_PAYMENT_SUBSCRIPTION = 'payment-subscription';
|
|
11
|
+
export const RES_PAYMENT_FINGERPRINT = 'payment-fingerprint';
|
|
12
|
+
export const COMPLETION_TOP_UP = 'top-up';
|
|
13
|
+
export const COMPLETION_SUBSCRIPTION = 'subscription';
|
|
14
|
+
const PaygateParamsSchema = schema({
|
|
15
|
+
type: 'object', properties: { paygate: { type: 'string' } }, required: ['paygate'],
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
});
|
|
18
|
+
const ResyncResultSchema = schema({
|
|
19
|
+
type: 'object', properties: { ok: { type: 'boolean' } }, required: ['ok'],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
});
|
|
22
|
+
const aliases = {
|
|
23
|
+
base: 'payment-gate', webhook: 'payment-gate:webhook', resync: 'payment-gate:resync',
|
|
24
|
+
};
|
|
25
|
+
const base = protocol(route(aliases.base, '/payment-gate', backend()), contract());
|
|
26
|
+
/** Embedded gateway protocol tree; the alias strings are private adapter details. */
|
|
27
|
+
export const paymentGate = {
|
|
28
|
+
base,
|
|
29
|
+
webhook: protocol(route(aliases.webhook, '/webhook/:paygate', backend({ parent: base, method: RouteMethod.POST })), contract.request({ params: PaygateParamsSchema }, typed())),
|
|
30
|
+
resync: protocol(route(aliases.resync, '/resync', backend({ parent: base, method: RouteMethod.POST })), contract(ResyncResultSchema), { guards: GUARD_ED25519 }),
|
|
31
|
+
};
|
|
32
|
+
export const paymentGateProtocols = protocols(paymentGate);
|
|
33
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,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AC5E,CAAA;AACV,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;AAElF,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI;IACJ,OAAO,EAAE,QAAQ,CACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EAChG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAa,CAAC,CACtE;IACD,MAAM,EAAE,QAAQ,CACd,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,EACrF,QAAQ,CAAC,kBAAkB,CAAC,EAC5B,EAAE,MAAM,EAAE,aAAa,EAAE,CAC1B;CACO,CAAA;AAEV,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Runtime-local bindings for the shared immutable payment-gateway protocol tree. */
|
|
2
|
+
export declare const paymentGateEntrypoints: (import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
3
|
+
params: import("./consts.js").PaygateParams;
|
|
4
|
+
}, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, undefined>> | import("@owlmeans/server-entrypoint").ServerProtocolEntrypoint<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("./consts.js").ResyncResult>>)[];
|
|
5
|
+
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,eAAO,MAAM,sBAAsB;;gTAIlC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { bind } from '@owlmeans/server-entrypoint';
|
|
2
|
+
import { paymentGate } from './consts.js';
|
|
3
|
+
import { resync, webhook } from './actions/index.js';
|
|
4
|
+
/** Runtime-local bindings for the shared immutable payment-gateway protocol tree. */
|
|
5
|
+
export const paymentGateEntrypoints = [
|
|
6
|
+
bind(paymentGate.base),
|
|
7
|
+
bind(paymentGate.webhook, webhook),
|
|
8
|
+
bind(paymentGate.resync, resync),
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=entrypoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEpD,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACtB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC;IAClC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;CACjC,CAAA"}
|
package/build/gate.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AbstractRequest, GateService } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { PermissionSet } from '@owlmeans/auth';
|
|
3
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
4
|
+
export interface EntitlementGateOptions {
|
|
5
|
+
productSkus?: string[];
|
|
6
|
+
resolveEntity?: (req: AbstractRequest) => string | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const entitlementsOf: (ctx: ApiContext, entityId: string, productSkus?: string[]) => Promise<PermissionSet[]>;
|
|
9
|
+
export declare const makeEntitlementGate: (alias?: string, opts?: EntitlementGateOptions) => GateService;
|
|
10
|
+
//# sourceMappingURL=gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAExE,OAAO,KAAK,EAAQ,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEzD,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjE,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,MAAM,GAAG,IAAI,CAAA;CACxD;AAED,eAAO,MAAM,cAAc,QACpB,UAAU,YAAY,MAAM,gBAAgB,MAAM,EAAE,KACxD,OAAO,CAAC,aAAa,EAAE,CAKzB,CAAA;AAKD,eAAO,MAAM,mBAAmB,WACvB,MAAM,SAA4B,sBAAsB,KAC9D,WAsBF,CAAA"}
|
package/build/gate.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createLazyService } from '@owlmeans/context';
|
|
2
|
+
import { AuthForbidden, entitySlugOf } from '@owlmeans/auth';
|
|
3
|
+
import { ENTITLEMENT_GATE, hasEntitlement, SubscriptionStatus } from '@owlmeans/payment';
|
|
4
|
+
import { subscriptions } from './utils.js';
|
|
5
|
+
export const entitlementsOf = async (ctx, entityId, productSkus) => {
|
|
6
|
+
const { items } = await subscriptions(ctx).list({
|
|
7
|
+
entityId, status: [SubscriptionStatus.Active, SubscriptionStatus.Trial], productSku: productSkus,
|
|
8
|
+
}, { size: 0 });
|
|
9
|
+
return items.flatMap(record => record.capabilities ?? []);
|
|
10
|
+
};
|
|
11
|
+
const defaultEntity = (req) => req.entity?.id ?? entitySlugOf(req.auth) ?? null;
|
|
12
|
+
export const makeEntitlementGate = (alias = ENTITLEMENT_GATE, opts) => {
|
|
13
|
+
const service = createLazyService(alias, {
|
|
14
|
+
assert: async (req, _, params) => {
|
|
15
|
+
await service.ready();
|
|
16
|
+
const ctx = service.assertCtx();
|
|
17
|
+
if (req.auth == null)
|
|
18
|
+
throw new AuthForbidden('auth');
|
|
19
|
+
const entityId = (opts?.resolveEntity ?? defaultEntity)(req);
|
|
20
|
+
if (entityId == null || entityId === '')
|
|
21
|
+
throw new AuthForbidden('entity');
|
|
22
|
+
let capabilities;
|
|
23
|
+
try {
|
|
24
|
+
capabilities = await entitlementsOf(ctx, entityId, opts?.productSkus);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error(`entitlement gate: cannot read subscriptions for "${entityId}"`, error);
|
|
28
|
+
throw new AuthForbidden('entitlement');
|
|
29
|
+
}
|
|
30
|
+
if (!params.some(param => hasEntitlement(capabilities, param))) {
|
|
31
|
+
throw new AuthForbidden('entitlement');
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return service;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,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A;YAE1E,IAAI,YAA6B,CAAA;YACjC,IAAI,CAAC;gBACH,YAAY,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;YACvE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,oDAAoD,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAA;gBACrF,MAAM,IAAI,aAAa,CAAC,aAAa,CAAC,CAAA;YACxC,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC/D,MAAM,IAAI,aAAa,CAAC,aAAa,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type * from './types.js';
|
|
2
|
+
export * from './consts.js';
|
|
3
|
+
export * from './config.js';
|
|
4
|
+
export * from './resource.js';
|
|
5
|
+
export * from './observer.js';
|
|
6
|
+
export * from './service.js';
|
|
7
|
+
export * from './gate.js';
|
|
8
|
+
export * from './entrypoints.js';
|
|
9
|
+
export { initialize as syncPaymentProducts, planLookupKey } from './sync.js';
|
|
10
|
+
export { amountCheckoutLineItem } from './plugins/stripe.js';
|
|
11
|
+
export { payment, gateway, observer, paygateCustomers, subscriptions, fingerprints, activeSubscription, } from './utils.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EACL,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,GAC9F,MAAM,YAAY,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './consts.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './resource.js';
|
|
4
|
+
export * from './observer.js';
|
|
5
|
+
export * from './service.js';
|
|
6
|
+
export * from './gate.js';
|
|
7
|
+
export * from './entrypoints.js';
|
|
8
|
+
export { initialize as syncPaymentProducts, planLookupKey } from './sync.js';
|
|
9
|
+
export { amountCheckoutLineItem } from './plugins/stripe.js';
|
|
10
|
+
export { payment, gateway, observer, paygateCustomers, subscriptions, fingerprints, activeSubscription, } from './utils.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EACL,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,GAC9F,MAAM,YAAY,CAAA"}
|
package/build/model.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSONSchemaType } from 'ajv';
|
|
2
|
+
import type { FingerprintRecord, PaygateCustomerRecord, PaymentSubscriptionRecord } from './types.js';
|
|
3
|
+
export declare const PaygateCustomerSchema: JSONSchemaType<PaygateCustomerRecord>;
|
|
4
|
+
export declare const PaymentSubscriptionSchema: JSONSchemaType<PaymentSubscriptionRecord>;
|
|
5
|
+
export declare const FingerprintSchema: JSONSchemaType<FingerprintRecord>;
|
|
6
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAGzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAErG,eAAO,MAAM,qBAAqB,EASlB,cAAc,CAAC,qBAAqB,CAAC,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAWtB,cAAc,CAAC,yBAAyB,CAAC,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAOd,cAAc,CAAC,iBAAiB,CAAC,CAAA"}
|
package/build/model.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PermissionSetSchema } from '@owlmeans/auth';
|
|
2
|
+
import { LimitConfigSchema } from '@owlmeans/payment';
|
|
3
|
+
export const PaygateCustomerSchema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
properties: {
|
|
6
|
+
id: { type: 'string', nullable: true }, paygate: { type: 'string' }, externalId: { type: 'string' },
|
|
7
|
+
entityId: { type: 'string', nullable: true }, profileId: { type: 'string', nullable: true },
|
|
8
|
+
email: { type: 'string', nullable: true }, name: { type: 'string', nullable: true },
|
|
9
|
+
taxId: { type: 'string', nullable: true },
|
|
10
|
+
},
|
|
11
|
+
required: ['paygate', 'externalId'], additionalProperties: true,
|
|
12
|
+
};
|
|
13
|
+
export const PaymentSubscriptionSchema = {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
id: { type: 'string', nullable: true }, sku: { type: 'string' }, productSku: { type: 'string' },
|
|
17
|
+
entityId: { type: 'string' }, service: { type: 'string' }, paygate: { type: 'string' },
|
|
18
|
+
externalId: { type: 'string' }, status: { type: 'string' }, kind: { type: 'string' },
|
|
19
|
+
capabilities: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
20
|
+
limits: { type: 'object', nullable: true, additionalProperties: LimitConfigSchema, required: [] },
|
|
21
|
+
},
|
|
22
|
+
required: ['sku', 'productSku', 'entityId', 'service', 'paygate', 'externalId', 'status', 'kind'],
|
|
23
|
+
additionalProperties: true,
|
|
24
|
+
};
|
|
25
|
+
export const FingerprintSchema = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
id: { type: 'string', nullable: true }, sku: { type: 'string' }, hash: { type: 'string' },
|
|
29
|
+
productId: { type: 'string', nullable: true },
|
|
30
|
+
},
|
|
31
|
+
required: ['sku', 'hash'], additionalProperties: true,
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,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E,iBAA0B,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC3G;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC;IACjG,oBAAoB,EAAE,IAAI;CAC6B,CAAA;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzF,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC9C;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,oBAAoB,EAAE,IAAI;CACN,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompletionObserver, Config, Context } from './types.js';
|
|
2
|
+
export declare const makeCompletionObserverService: (alias?: string) => CompletionObserver;
|
|
3
|
+
export declare const appendCompletionObserver: <C extends Config, T extends Context<C>>(ctx: T, alias?: string) => T;
|
|
4
|
+
//# sourceMappingURL=observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAuC,MAAM,YAAY,CAAA;AAE1G,eAAO,MAAM,6BAA6B,WACjC,MAAM,KACZ,kBAaF,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACxE,CAAC,UAAS,MAAM,KACpB,CAGF,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createLazyService } from '@owlmeans/context';
|
|
2
|
+
import { PAYMENT_OBSERVER } from './consts.js';
|
|
3
|
+
export const makeCompletionObserverService = (alias = PAYMENT_OBSERVER) => {
|
|
4
|
+
const topUpCallbacks = [];
|
|
5
|
+
const subscriptionCallbacks = [];
|
|
6
|
+
return createLazyService(alias, {
|
|
7
|
+
onTopUp: cb => { topUpCallbacks.push(cb); },
|
|
8
|
+
onSubscription: cb => { subscriptionCallbacks.push(cb); },
|
|
9
|
+
propagateTopUp: async (completion, ctx) => {
|
|
10
|
+
for (const callback of topUpCallbacks)
|
|
11
|
+
await callback(completion, ctx);
|
|
12
|
+
},
|
|
13
|
+
propagateSubscription: async (completion, ctx) => {
|
|
14
|
+
for (const callback of subscriptionCallbacks)
|
|
15
|
+
await callback(completion, ctx);
|
|
16
|
+
},
|
|
17
|
+
}, service => async () => { service.initialized = true; });
|
|
18
|
+
};
|
|
19
|
+
export const appendCompletionObserver = (ctx, alias = PAYMENT_OBSERVER) => {
|
|
20
|
+
if (!ctx.hasService(alias))
|
|
21
|
+
ctx.registerService(makeCompletionObserverService(alias));
|
|
22
|
+
return ctx;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=observer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer.js","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,KAAK,GAAW,gBAAgB,EACZ,EAAE;IACtB,MAAM,cAAc,GAAoB,EAAE,CAAA;IAC1C,MAAM,qBAAqB,GAA2B,EAAE,CAAA;IACxD,OAAO,iBAAiB,CAAqB,KAAK,EAAE;QAClD,OAAO,EAAE,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC;QAC1C,cAAc,EAAE,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC;QACxD,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE;YACxC,KAAK,MAAM,QAAQ,IAAI,cAAc;gBAAE,MAAM,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QACxE,CAAC;QACD,qBAAqB,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE;YAC/C,KAAK,MAAM,QAAQ,IAAI,qBAAqB;gBAAE,MAAM,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAC/E,CAAC;KACF,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAA,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAAM,EAAE,KAAK,GAAW,gBAAgB,EACrC,EAAE;IACL,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,GAAG,CAAC,eAAe,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAA;IACrF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type Stripe from 'stripe';
|
|
2
|
+
import { SubscriptionStatus } from '@owlmeans/payment';
|
|
3
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
4
|
+
export declare const createEventHandler: (context: ApiContext, stripe: Stripe) => {
|
|
5
|
+
process: (event: Stripe.Event) => Promise<void>;
|
|
6
|
+
'customer.created': (event: Stripe.CustomerCreatedEvent) => Promise<void>;
|
|
7
|
+
'customer.updated': (event: Stripe.CustomerUpdatedEvent) => Promise<void>;
|
|
8
|
+
'checkout.session.completed': (event: Stripe.CheckoutSessionCompletedEvent) => Promise<void>;
|
|
9
|
+
'checkout.session.async_payment_succeeded': (event: Stripe.CheckoutSessionAsyncPaymentSucceededEvent) => Promise<void>;
|
|
10
|
+
'customer.subscription.created': (event: Stripe.CustomerSubscriptionCreatedEvent) => Promise<void>;
|
|
11
|
+
'customer.subscription.updated': (event: Stripe.CustomerSubscriptionUpdatedEvent) => Promise<void>;
|
|
12
|
+
'customer.subscription.deleted': (event: Stripe.CustomerSubscriptionDeletedEvent) => Promise<void>;
|
|
13
|
+
_upsertCustomer: (customer: Stripe.Customer) => Promise<void>;
|
|
14
|
+
_syncSubscription: (pgSubscription: Stripe.Subscription, forced?: SubscriptionStatus) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/plugins/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,EAC4C,kBAAkB,EACpE,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAuCjE,eAAO,MAAM,kBAAkB,YAAa,UAAU,UAAU,MAAM;qBAmE3C,MAAM,CAAC,KAAK;gCAGD,MAAM,CAAC,oBAAoB;gCAC3B,MAAM,CAAC,oBAAoB;0CACjB,MAAM,CAAC,6BAA6B;wDACtB,MAAM,CAAC,yCAAyC;6CAE3D,MAAM,CAAC,gCAAgC;6CACvC,MAAM,CAAC,gCAAgC;6CACvC,MAAM,CAAC,gCAAgC;gCAGpD,MAAM,CAAC,QAAQ;wCAgBP,MAAM,CAAC,YAAY,WAAW,kBAAkB;CAwC7F,CAAA"}
|