@owlmeans/server-payment 0.1.20-rc.1 → 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.
- 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
|
@@ -50,10 +50,10 @@ Event actions: `mail` (step = mail kind), `computed` (the meter reading and the
|
|
|
50
50
|
`cancel-scheduled`, `observers` (step = `consent`/`withdrawal`/`cancellation`), `lock`,
|
|
51
51
|
`lock-mismatch`, `relock`, `unlock` (detail: `from`, `by`, `reason`, the deleted `profile`),
|
|
52
52
|
`duplicate`, `checkout-terms-fallback` (`recordKind: 'checkout'`, `recordId` = the entity,
|
|
53
|
-
`externalId` = the session created without the checkbox, `ok: false`, detail: the
|
|
53
|
+
`externalId` = the session created without the checkbox, `ok: false`, detail: the paygate's `message`,
|
|
54
54
|
`code`, `param`, `mode`, `productSku`, `planSku`; `error` when the retry failed too).
|
|
55
55
|
|
|
56
|
-
`PurchaseRecord.termsAccepted` is
|
|
56
|
+
`PurchaseRecord.termsAccepted` is the completed session's own terms acceptance (`CheckoutSnapshot.termsAccepted`) and
|
|
57
57
|
nothing else; `confirmationMailAt` is the one claim of the purchase confirmation.
|
|
58
58
|
|
|
59
59
|
Accessors (`paymentAccessOf(ctx)`, `src/access.ts`): `billingProfiles`, `purchases`, `consumerConsents`,
|
|
@@ -128,7 +128,7 @@ unrefunded and rounded in the consumer's favour.
|
|
|
128
128
|
## Cancellation, step by step
|
|
129
129
|
|
|
130
130
|
1. Policy and `mechanisms.cancellation`; managed.
|
|
131
|
-
2. Resolve the subscription: in-app `subscriptionId`, a contract, else the entitling
|
|
131
|
+
2. Resolve the subscription: in-app `subscriptionId`, a contract, else the entitling paygate
|
|
132
132
|
subscription (none → `CancellationUnavailable('no-subscription')`, ended → `'ended'`); public the
|
|
133
133
|
contract + e-mail, else the only organization whose paygate customer has the e-mail.
|
|
134
134
|
3. Decide: extraordinary → `review` (paygate untouched); ordinary and live →
|
package/build/access/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type Stripe from 'stripe';
|
|
2
1
|
import type { PaymentService } from '@owlmeans/payment';
|
|
3
|
-
import type { BillingProfileResource, CompletionObserver, ConsumerConsentResource, ConsumerDeclarationResource, ConsumerEventResource, ConsumerMailPluginConfig, ConsumerRightsService, EntitlementService, FingerprintResource, GatewayService, PaygateCustomerResource, PaymentFulfillmentResource, PaymentGrantResource, PaymentSubscriptionRecord, PaymentSubscriptionResource, PaymentUsageCounterResource, PaymentUsageResource, PaymentWebhookResource,
|
|
2
|
+
import type { BillingProfileResource, CompletionObserver, ConsumerConsentResource, ConsumerDeclarationResource, ConsumerEventResource, ConsumerMailPluginConfig, ConsumerRightsService, EntitlementService, FingerprintResource, GatewayService, PaygateCustomerResource, PaymentFulfillmentResource, PaymentGrantResource, PaymentSubscriptionRecord, PaymentSubscriptionResource, PaymentUsageCounterResource, PaymentUsageResource, PaymentWebhookResource, PurchaseResource } from '../types.js';
|
|
3
|
+
import type { PaygateRegistry } from '../paygate/types.js';
|
|
4
4
|
import type { EntitlementGrantHelper } from '../grants/types.js';
|
|
5
|
-
/** What one context holds for payments: its services, its resources, its plugin configs and its
|
|
5
|
+
/** What one context holds for payments: its services, its resources, its plugin configs and its paygates. */
|
|
6
6
|
export interface PaymentAccess {
|
|
7
7
|
payment: () => PaymentService;
|
|
8
8
|
gateway: () => GatewayService;
|
|
@@ -32,21 +32,12 @@ export interface PaymentAccess {
|
|
|
32
32
|
consumerRights: (alias?: string) => ConsumerRightsService;
|
|
33
33
|
/** The consumer-rights service, or `null` in a process that registered none. */
|
|
34
34
|
consumerRightsOf: (alias?: string) => ConsumerRightsService | null;
|
|
35
|
-
stripeConfig: () => Promise<StripePluginConfig>;
|
|
36
|
-
/** The portal branding declared with `portalBranding`, or `null`. */
|
|
37
|
-
portalBrandingConfig: () => Promise<PortalBrandingConfig | null>;
|
|
38
35
|
/** The consumer-rights mail options declared with `declareConsumerRights`, or `null`. */
|
|
39
36
|
consumerMailConfig: () => Promise<ConsumerMailPluginConfig | null>;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
* readers, the stored webhook endpoints and the test doubles are written for. The installed SDK is typed
|
|
45
|
-
* for a newer one, so a read of a field the newer version moved (a subscription's period, an invoice's
|
|
46
|
-
* subscription) is cast at the seam until the readers are migrated — the pin is what keeps the shapes
|
|
47
|
-
* the code parses and the shapes Stripe sends the same.
|
|
48
|
-
*/
|
|
49
|
-
stripeClient: () => Promise<Stripe>;
|
|
37
|
+
/** A backend-only plugin config record by id (a provider's own settings), or `null`. */
|
|
38
|
+
pluginConfig: <T>(id: string) => Promise<T | null>;
|
|
39
|
+
/** The paygates of the registered payment providers (`paygatesOf`). */
|
|
40
|
+
paygates: () => PaygateRegistry;
|
|
50
41
|
/** The entity's highest-ranked entitling subscription of one product. */
|
|
51
42
|
activeSubscription: (entityId: string, productSku: string) => Promise<PaymentSubscriptionRecord | null>;
|
|
52
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/access/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/access/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACV,sBAAsB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,2BAA2B,EAChG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E,MAAM,qBAAqB,CAAA;IAC3C,qEAAqE;IACrE,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,qBAAqB,CAAA;IACzD,gFAAgF;IAChF,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,qBAAqB,GAAG,IAAI,CAAA;IAClE,yFAAyF;IACzF,kBAAkB,EAAE,MAAM,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAA;IAClE,wFAAwF;IACxF,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAClD,uEAAuE;IACvE,QAAQ,EAAE,MAAM,eAAe,CAAA;IAC/B,yEAAyE;IACzE,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CACxG"}
|
package/build/access.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAejE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAMtD,eAAO,MAAM,iBAAiB,QAAS,UAAU,KAAG,aA2DnD,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,eAAe,8EAAwC,CAAA"}
|
package/build/access.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Stripe from 'stripe';
|
|
2
1
|
import { PLUGINS } from '@owlmeans/config';
|
|
3
2
|
import { memoHelper } from '@owlmeans/context';
|
|
4
3
|
import { DEFAULT_ALIAS as PAYMENT_SERVICE, ENTITLING_STATUSES } from '@owlmeans/payment';
|
|
5
|
-
import { CONSUMER_RIGHTS_MAIL_PLUGIN_CONFIG, CONSUMER_RIGHTS_SERVICE, ENTITLEMENT_SERVICE, GATEWAY_SERVICE, PAYMENT_OBSERVER, RES_BILLING_PROFILE, RES_CONSUMER_CONSENT, RES_CONSUMER_DECLARATION, RES_CONSUMER_EVENT, RES_PAYGATE_CUSTOMER, RES_PAYMENT_FINGERPRINT, RES_PAYMENT_FULFILLMENT, RES_PAYMENT_GRANT, RES_PAYMENT_PURCHASE, RES_PAYMENT_SUBSCRIPTION, RES_PAYMENT_USAGE, RES_PAYMENT_USAGE_COUNTER, RES_PAYMENT_WEBHOOK,
|
|
4
|
+
import { CONSUMER_RIGHTS_MAIL_PLUGIN_CONFIG, CONSUMER_RIGHTS_SERVICE, ENTITLEMENT_SERVICE, GATEWAY_SERVICE, PAYMENT_OBSERVER, RES_BILLING_PROFILE, RES_CONSUMER_CONSENT, RES_CONSUMER_DECLARATION, RES_CONSUMER_EVENT, RES_PAYGATE_CUSTOMER, RES_PAYMENT_FINGERPRINT, RES_PAYMENT_FULFILLMENT, RES_PAYMENT_GRANT, RES_PAYMENT_PURCHASE, RES_PAYMENT_SUBSCRIPTION, RES_PAYMENT_USAGE, RES_PAYMENT_USAGE_COUNTER, RES_PAYMENT_WEBHOOK, } from './consts.js';
|
|
6
5
|
import { entitlementGrantsOf } from './grants.js';
|
|
6
|
+
import { paygatesOf } from './paygate/registry.js';
|
|
7
7
|
export const makePaymentAccess = (ctx) => {
|
|
8
8
|
const hasService = (alias) => ctx.hasService?.(alias) === true;
|
|
9
9
|
const hasResource = (alias) => ctx.hasResource?.(alias) === true;
|
|
@@ -30,11 +30,9 @@ export const makePaymentAccess = (ctx) => {
|
|
|
30
30
|
const consumerEvents = () => ctx.resource(RES_CONSUMER_EVENT);
|
|
31
31
|
const consumerRights = (alias = CONSUMER_RIGHTS_SERVICE) => ctx.service(alias);
|
|
32
32
|
const consumerRightsOf = (alias = CONSUMER_RIGHTS_SERVICE) => hasService(alias) ? ctx.service(alias) : null;
|
|
33
|
-
const stripeConfig = async () => await plugins().get(STRIPE_PLUGIN_CONFIG);
|
|
34
|
-
const portalBrandingConfig = async () => await plugins().load(STRIPE_PORTAL_PLUGIN_CONFIG);
|
|
35
33
|
const consumerMailConfig = async () => await plugins().load(CONSUMER_RIGHTS_MAIL_PLUGIN_CONFIG);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
34
|
+
const pluginConfig = async (id) => await plugins().load(id);
|
|
35
|
+
const paygates = () => paygatesOf(ctx);
|
|
38
36
|
const activeSubscription = async (entityId, productSku) => await subscriptions().load({
|
|
39
37
|
entityId, productSku, status: [...ENTITLING_STATUSES],
|
|
40
38
|
}, { sort: [{ field: 'rank', order: 'desc' }, { field: 'createdAt', order: 'desc' }] });
|
|
@@ -42,8 +40,8 @@ export const makePaymentAccess = (ctx) => {
|
|
|
42
40
|
payment, gateway, gatewayOf, observer, entitlements, paygateCustomers, subscriptions, fulfillments,
|
|
43
41
|
paymentWebhooks, usageEvents, usageCounters, fingerprints, grantRecords, grantRecordsOf, grants, billingProfiles,
|
|
44
42
|
purchases, consumerConsents,
|
|
45
|
-
consumerDeclarations, consumerEvents, consumerRights, consumerRightsOf,
|
|
46
|
-
|
|
43
|
+
consumerDeclarations, consumerEvents, consumerRights, consumerRightsOf, consumerMailConfig, pluginConfig, paygates,
|
|
44
|
+
activeSubscription,
|
|
47
45
|
};
|
|
48
46
|
};
|
|
49
47
|
/** The payment access of a context — one per context. */
|
package/build/access.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,C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AC,CAAA;IAEvF,OAAO;QACL,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY;QAClG,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe;QAChH,SAAS,EAAE,gBAAgB;QAC3B,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ;QAClH,kBAAkB;KACnB,CAAA;AACH,CAAC,CAAA;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Forget every sync fingerprint and bring
|
|
3
|
-
* in any managed process, `bootstrap: false` included: the webhook URL and the rows follow
|
|
4
|
-
* gateway's `webhookService` and `owner`, so every process of the owner converges on one state.
|
|
2
|
+
* Forget every sync fingerprint and bring every paygate back to the declared catalogue, portal and
|
|
3
|
+
* webhook — in any managed process, `bootstrap: false` included: the webhook URL and the rows follow
|
|
4
|
+
* the gateway's `webhookService` and `owner`, so every process of the owner converges on one state.
|
|
5
5
|
*/
|
|
6
6
|
export declare const resync: import("@owlmeans/server-entrypoint").BoundEntrypointHandler<import("@owlmeans/entrypoint").EntrypointProtocol<{}, import("../types.js").ResyncResult>>;
|
|
7
7
|
//# sourceMappingURL=resync.d.ts.map
|
package/build/actions/resync.js
CHANGED
|
@@ -2,12 +2,12 @@ import { PaygateError } from '@owlmeans/payment';
|
|
|
2
2
|
import { handlers } from '@owlmeans/server-api';
|
|
3
3
|
import { paymentAccessOf } from '../access.js';
|
|
4
4
|
import { paymentGate } from '../protocol.js';
|
|
5
|
-
import {
|
|
5
|
+
import { paygateBootstrapOf } from '../bootstrap.js';
|
|
6
6
|
const bind = handlers();
|
|
7
7
|
/**
|
|
8
|
-
* Forget every sync fingerprint and bring
|
|
9
|
-
* in any managed process, `bootstrap: false` included: the webhook URL and the rows follow
|
|
10
|
-
* gateway's `webhookService` and `owner`, so every process of the owner converges on one state.
|
|
8
|
+
* Forget every sync fingerprint and bring every paygate back to the declared catalogue, portal and
|
|
9
|
+
* webhook — in any managed process, `bootstrap: false` included: the webhook URL and the rows follow
|
|
10
|
+
* the gateway's `webhookService` and `owner`, so every process of the owner converges on one state.
|
|
11
11
|
*/
|
|
12
12
|
export const resync = bind.request(paymentGate.resync, async (_request, context) => {
|
|
13
13
|
const paymentAccess = paymentAccessOf(context);
|
|
@@ -15,7 +15,7 @@ export const resync = bind.request(paymentGate.resync, async (_request, context)
|
|
|
15
15
|
if (!service.managed)
|
|
16
16
|
throw new PaygateError('unmanaged');
|
|
17
17
|
await paymentAccess.fingerprints().clear();
|
|
18
|
-
await
|
|
18
|
+
await paygateBootstrapOf(context).bootstrap({ force: true });
|
|
19
19
|
return { ok: true };
|
|
20
20
|
});
|
|
21
21
|
//# sourceMappingURL=resync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resync.js","sourceRoot":"","sources":["../../src/actions/resync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"resync.js","sourceRoot":"","sources":["../../src/actions/resync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,IAAI,GAAG,QAAQ,EAAW,CAAA;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;IACjF,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,CAAA;IACvC,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,CAAA;IACzD,MAAM,aAAa,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,CAAA;IAC1C,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AACrB,CAAC,CAAC,CAAA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A paygate delivery: the paygate named in the path must be registered (`UnknownPaygate`), and only a
|
|
3
|
+
* managed gateway receives one; the paygate verifies it against the `owner`'s secrets.
|
|
4
|
+
*/
|
|
2
5
|
export declare const webhook: import("@owlmeans/server-entrypoint").BoundEntrypointHandler<import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
3
6
|
params: import("../types.js").PaygateParams;
|
|
4
7
|
}, undefined>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,OAAO;;cAMlB,CAAA"}
|
package/build/actions/webhook.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { PaygateError, UnknownPaygate } from '@owlmeans/payment';
|
|
2
2
|
import { handlers } from '@owlmeans/server-api';
|
|
3
|
-
import { STRIPE_PAYGATE_ALIAS } from '../consts.js';
|
|
4
3
|
import { paymentAccessOf } from '../access.js';
|
|
5
4
|
import { paymentGate } from '../protocol.js';
|
|
5
|
+
import { paygatesOf } from '../paygate/registry.js';
|
|
6
6
|
import { webhookOf } from '../plugins/webhook-manager.js';
|
|
7
7
|
const bind = handlers();
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* A paygate delivery: the paygate named in the path must be registered (`UnknownPaygate`), and only a
|
|
10
|
+
* managed gateway receives one; the paygate verifies it against the `owner`'s secrets.
|
|
11
|
+
*/
|
|
9
12
|
export const webhook = bind.params(paymentGate.webhook, async ({ paygate }, context, request) => {
|
|
10
|
-
|
|
13
|
+
const target = paygatesOf(context).find(paygate);
|
|
14
|
+
if (target == null)
|
|
11
15
|
throw new UnknownPaygate(paygate);
|
|
12
16
|
const service = paymentAccessOf(context).gateway();
|
|
13
17
|
if (!service.managed)
|
|
14
18
|
throw new PaygateError('unmanaged');
|
|
15
|
-
await webhookOf(context).
|
|
19
|
+
await webhookOf(context).handleDelivery(target, request);
|
|
16
20
|
});
|
|
17
21
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/actions/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,MAAM,IAAI,GAAG,QAAQ,EAAW,CAAA;AAEhC;;;GAGG;AACH,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,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChD,IAAI,MAAM,IAAI,IAAI;QAAE,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;IAClD,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,MAAM,IAAI,YAAY,CAAC,WAAW,CAAC,CAAA;IACzD,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC,CAAC,CAAA"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
/** What brings
|
|
4
|
-
export interface
|
|
1
|
+
import type { PaygateBootstrapOptions } from '../types.js';
|
|
2
|
+
import type { Paygate } from '../paygate/types.js';
|
|
3
|
+
/** What brings every registered paygate to a deployment's declaration. */
|
|
4
|
+
export interface PaygateBootstrapHelper {
|
|
5
5
|
/**
|
|
6
|
-
* Bring
|
|
7
|
-
*
|
|
6
|
+
* Bring every registered paygate to what this deployment declares (`bootstrapPaygate`, in
|
|
7
|
+
* registration order).
|
|
8
8
|
*
|
|
9
9
|
* The webhook URL and the owner key come from the context's gateway (`webhookService`, `owner`), so
|
|
10
10
|
* every process of one deployment — the one bootstrapping at boot, a `resync`, an application's
|
|
11
11
|
* forced maintenance run — computes the same URL and rows; each step is fingerprinted, so running it
|
|
12
12
|
* from any of them is idempotent.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
bootstrap: (opts?: PaygateBootstrapOptions) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* One paygate, each step on its own so one failing does not block the others: products and prices
|
|
17
|
+
* (`catalogue`), the customer-portal configuration (`portal`), the webhook endpoint (`webhook`) — a
|
|
18
|
+
* capability the paygate lacks is skipped.
|
|
19
|
+
*/
|
|
20
|
+
bootstrapPaygate: (paygate: Paygate, opts?: PaygateBootstrapOptions) => Promise<void>;
|
|
15
21
|
}
|
|
16
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bootstrap/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtF"}
|
package/build/bootstrap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const
|
|
4
|
-
/** The
|
|
5
|
-
export declare const
|
|
2
|
+
import type { PaygateBootstrapHelper } from './bootstrap/types.js';
|
|
3
|
+
export declare const makePaygateBootstrapHelper: (ctx: ApiContext) => PaygateBootstrapHelper;
|
|
4
|
+
/** The paygate bootstrap of a context — one per context. */
|
|
5
|
+
export declare const paygateBootstrapOf: (target: ApiContext<import("@owlmeans/server-api").Config>) => PaygateBootstrapHelper;
|
|
6
6
|
//# sourceMappingURL=bootstrap.d.ts.map
|
package/build/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAKjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAKlE,eAAO,MAAM,0BAA0B,QAAS,UAAU,KAAG,sBA2B5D,CAAA;AAED,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,uFAAiD,CAAA"}
|
package/build/bootstrap.js
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
import { memoHelper } from '@owlmeans/context';
|
|
2
2
|
import { log } from './log.js';
|
|
3
3
|
import { productSyncOf } from './sync.js';
|
|
4
|
-
import {
|
|
4
|
+
import { paygatesOf } from './paygate/registry.js';
|
|
5
5
|
import { webhookOf } from './plugins/webhook-manager.js';
|
|
6
|
-
export const
|
|
7
|
-
const
|
|
6
|
+
export const makePaygateBootstrapHelper = (ctx) => {
|
|
7
|
+
const bootstrapPaygate = async (paygate, opts = {}) => {
|
|
8
8
|
const steps = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
...(paygate.catalogue != null
|
|
10
|
+
? [['products', async () => await productSyncOf(ctx).syncProducts(paygate)]] : []),
|
|
11
|
+
...(paygate.portal != null
|
|
12
|
+
? [['portal', async () => await paygate.portal?.ensureConfiguration(webhookOf(ctx).deploymentOf(paygate.id), opts)]]
|
|
13
|
+
: []),
|
|
14
|
+
...(paygate.webhook != null
|
|
15
|
+
? [['webhook', async () => await webhookOf(ctx).ensureWebhookEndpoint(paygate, opts)]] : []),
|
|
12
16
|
];
|
|
13
17
|
for (const [name, step] of steps) {
|
|
14
18
|
try {
|
|
15
19
|
await step();
|
|
16
20
|
}
|
|
17
21
|
catch (error) {
|
|
18
|
-
log.error('
|
|
22
|
+
log.error('Paygate bootstrap step failed', { step: name, paygate: paygate.id, error });
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
const bootstrap = async (opts = {}) => {
|
|
27
|
+
for (const paygate of paygatesOf(ctx).all()) {
|
|
28
|
+
await bootstrapPaygate(paygate, opts);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return { bootstrap, bootstrapPaygate };
|
|
23
32
|
};
|
|
24
|
-
/** The
|
|
25
|
-
export const
|
|
33
|
+
/** The paygate bootstrap of a context — one per context. */
|
|
34
|
+
export const paygateBootstrapOf = memoHelper.oncePer(makePaygateBootstrapHelper);
|
|
26
35
|
//# sourceMappingURL=bootstrap.js.map
|
package/build/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,EAAE,GAAG,E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YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;YACxF,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,KAAK,EAAE,IAAI,GAA4B,EAAE,EAAiB,EAAE;QAC5E,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YAC5C,MAAM,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAA;AACxC,CAAC,CAAA;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAA"}
|
|
@@ -26,12 +26,12 @@ export interface CatalogueHelper {
|
|
|
26
26
|
* Empty when the plan is not of one of `productSkus`.
|
|
27
27
|
*/
|
|
28
28
|
entitlementsOf: (entityId: string, productSkus?: string[]) => Promise<PermissionSet[]>;
|
|
29
|
-
/** Every product sold through
|
|
30
|
-
|
|
29
|
+
/** Every product with a plan sold through a paygate, with the plans it sells there (`planHelper.isSoldThrough`). */
|
|
30
|
+
plansSoldThrough: (paygate: string) => Promise<Array<{
|
|
31
31
|
product: PaymentProduct;
|
|
32
32
|
plans: PaymentPlan[];
|
|
33
33
|
}>>;
|
|
34
|
-
/** The plan an amount/quantity checkout of a consumable product sells: the named one, else the first. */
|
|
34
|
+
/** The plan an amount/quantity checkout of a consumable product sells: the named one, else the first plan for sale. */
|
|
35
35
|
consumablePlanOf: (productSku: string, planSku?: string) => Promise<{
|
|
36
36
|
product: PaymentProduct;
|
|
37
37
|
plan: PaymentPlan;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/catalogue/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE7E,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC1D,mCAAmC;IACnC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACnE,4CAA4C;IAC5C,YAAY,EAAE,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;IAC1C,qFAAqF;IACrF,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC7C;;;;;;;;;OASG;IACH,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7E;;;OAGG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;IACtF,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/catalogue/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE7E,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC1D,mCAAmC;IACnC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACnE,4CAA4C;IAC5C,YAAY,EAAE,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;IAC1C,qFAAqF;IACrF,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC7C;;;;;;;;;OASG;IACH,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7E;;;OAGG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;IACtF,oHAAoH;IACpH,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC,CAAC,CAAA;IACxG,uHAAuH;IACvH,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC,CAAA;CACpH"}
|
package/build/catalogue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../src/catalogue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../src/catalogue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AASjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAK3D,eAAO,MAAM,mBAAmB,QAAS,UAAU,KAAG,eAmHrD,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,WAAW,gFAA0C,CAAA"}
|
package/build/catalogue.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ENTITLING_STATUSES, PlanRequired, ProductError, promoHelper } from '@owlmeans/payment';
|
|
2
2
|
import { memoHelper } from '@owlmeans/context';
|
|
3
|
-
import { STRIPE_PAYGATE_ALIAS } from './consts.js';
|
|
4
3
|
import { paymentAccessOf } from './access.js';
|
|
5
4
|
import { planHelper } from './plan.js';
|
|
6
5
|
import { subscriptionHelper } from './subscription.js';
|
|
@@ -78,15 +77,12 @@ export const makeCatalogueHelper = (ctx) => {
|
|
|
78
77
|
.filter(set => promoHelper.promoActive(set.promo, subscription?.createdAt, at))
|
|
79
78
|
.map(({ promo: _promo, ...set }) => set);
|
|
80
79
|
};
|
|
81
|
-
const
|
|
80
|
+
const plansSoldThrough = async (paygate) => {
|
|
82
81
|
const products = await access.payment().products();
|
|
83
82
|
const result = [];
|
|
84
83
|
for (const product of products) {
|
|
85
|
-
if (!(product.gateways ?? []).includes(STRIPE_PAYGATE_ALIAS)) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
84
|
const plans = (await access.payment().allPlans(product.sku))
|
|
89
|
-
.filter(plan => planHelper.isSoldThrough(product, plan,
|
|
85
|
+
.filter(plan => planHelper.isSoldThrough(product, plan, paygate));
|
|
90
86
|
if (plans.length > 0) {
|
|
91
87
|
result.push({ product, plans });
|
|
92
88
|
}
|
|
@@ -96,7 +92,7 @@ export const makeCatalogueHelper = (ctx) => {
|
|
|
96
92
|
const consumablePlanOf = async (productSku, planSku) => {
|
|
97
93
|
const product = await access.payment().product(productSku);
|
|
98
94
|
const plans = (await access.payment().allPlans(product.sku))
|
|
99
|
-
.filter(plan => planHelper.
|
|
95
|
+
.filter(plan => planHelper.isForSale(product, plan));
|
|
100
96
|
if (planSku != null && !plans.some(plan => plan.sku === planSku)) {
|
|
101
97
|
throw new ProductError(`plan:${planSku}`);
|
|
102
98
|
}
|
|
@@ -106,7 +102,7 @@ export const makeCatalogueHelper = (ctx) => {
|
|
|
106
102
|
return { product, plan };
|
|
107
103
|
};
|
|
108
104
|
return {
|
|
109
|
-
findPlan, findProduct, catalogPlans, freePlanOf, resolveEffectivePlan, entitlementsOf,
|
|
105
|
+
findPlan, findProduct, catalogPlans, freePlanOf, resolveEffectivePlan, entitlementsOf, plansSoldThrough,
|
|
110
106
|
consumablePlanOf,
|
|
111
107
|
};
|
|
112
108
|
};
|
package/build/catalogue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogue.js","sourceRoot":"","sources":["../src/catalogue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"catalogue.js","sourceRoot":"","sources":["../src/catalogue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,GAAG,EAAE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ams } from '../types.js';
|
|
2
|
+
/** The checkout of a context, through any registered paygate. */
|
|
3
|
+
export interface CheckoutHelper {
|
|
4
|
+
/**
|
|
5
|
+
* A paygate checkout URL: an amount or quantity purchase of a consumable product, or a subscription
|
|
6
|
+
* to `planSku` (else the product's first recurring plan). The paygate is `params.paygate`, else the
|
|
7
|
+
* first registered one the plan is for sale through (`paygatesOf(ctx).forSale`); a plan no paygate
|
|
8
|
+
* sells is refused (`ProductError('plan:<sku>')`). A free plan is never checked out.
|
|
9
|
+
*
|
|
10
|
+
* With a consumer-rights policy: a locked billing country overrides the declared one (another is
|
|
11
|
+
* `BillingCountryLocked`); the charge currency is the profile's, else the region's; an amount
|
|
12
|
+
* checkout is narrowed by the checkout plugins (`CheckoutLimitExceeded`) and charged without FX
|
|
13
|
+
* when its policy currency is the charge currency; a subscription needs a fresh start request
|
|
14
|
+
* bound to its plan; the terms checkbox and the legal submit texts come from the copy.
|
|
15
|
+
*
|
|
16
|
+
* Under the paygate's customer e-mail lock the session's customer carries `params.email`
|
|
17
|
+
* (required, else `PaygateError('customer-email')`), so the paygate shows it read-only.
|
|
18
|
+
*/
|
|
19
|
+
createCheckoutLink: (params: CreateLinkParams, plugins?: readonly CheckoutPlugin[]) => Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/checkout/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnE,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/checkout/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
2
|
+
import type { CheckoutHelper } from './checkout/types.js';
|
|
3
|
+
export declare const makeCheckoutHelper: (ctx: ApiContext) => CheckoutHelper;
|
|
4
|
+
/** The checkout of a context — one per context. */
|
|
5
|
+
export declare const checkoutOf: (target: ApiContext<import("@owlmeans/server-api").Config>) => CheckoutHelper;
|
|
6
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAiBjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAkDzD,eAAO,MAAM,kBAAkB,QAAS,UAAU,KAAG,cAkVpD,CAAA;AAED,mDAAmD;AACnD,eAAO,MAAM,UAAU,+EAAyC,CAAA"}
|