@owlmeans/server-payment 0.1.18-rc.3 → 0.1.18-rc.30
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 +146 -25
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-payment/SKILL.md +593 -53
- package/build/actions/index.d.ts +1 -0
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +1 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/resync-subscriptions.d.ts +3 -0
- package/build/actions/resync-subscriptions.d.ts.map +1 -0
- package/build/actions/resync-subscriptions.js +6 -0
- package/build/actions/resync-subscriptions.js.map +1 -0
- package/build/actions/resync.d.ts +6 -1
- package/build/actions/resync.d.ts.map +1 -1
- package/build/actions/resync.js +12 -4
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +2 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +9 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/config.d.ts +60 -5
- package/build/config.d.ts.map +1 -1
- package/build/config.js +248 -5
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +74 -16
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +86 -23
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +94 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +44 -0
- package/build/consts.local.js.map +1 -0
- package/build/consumer/capture.d.ts +61 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +300 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/consts.local.d.ts +10 -0
- package/build/consumer/consts.local.d.ts.map +1 -0
- package/build/consumer/consts.local.js +11 -0
- package/build/consumer/consts.local.js.map +1 -0
- package/build/consumer/format.d.ts +27 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +81 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +21 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +173 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +7 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail.d.ts +27 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +314 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/origin.d.ts +14 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +46 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile.d.ts +12 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +316 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records.d.ts +108 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +299 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +44 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +771 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/types.d.ts +87 -0
- package/build/consumer/types.d.ts.map +1 -0
- package/build/consumer/types.js +2 -0
- package/build/consumer/types.js.map +1 -0
- package/build/consumer/types.local.d.ts +25 -0
- package/build/consumer/types.local.d.ts.map +1 -0
- package/build/consumer/types.local.js +2 -0
- package/build/consumer/types.local.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +34 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +247 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/entitlement.d.ts +10 -0
- package/build/entitlement.d.ts.map +1 -0
- package/build/entitlement.js +69 -0
- package/build/entitlement.js.map +1 -0
- package/build/entrypoints.d.ts +19 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +16 -4
- package/build/entrypoints.js.map +1 -1
- package/build/gate.d.ts +20 -6
- package/build/gate.d.ts.map +1 -1
- package/build/gate.js +59 -19
- package/build/gate.js.map +1 -1
- package/build/index.d.ts +20 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +17 -3
- package/build/index.js.map +1 -1
- package/build/limit.d.ts +11 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +48 -0
- package/build/limit.js.map +1 -0
- package/build/log.d.ts +3 -0
- package/build/log.d.ts.map +1 -0
- package/build/log.js +4 -0
- package/build/log.js.map +1 -0
- package/build/observer.d.ts +9 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +38 -12
- package/build/observer.js.map +1 -1
- package/build/plan.d.ts +33 -0
- package/build/plan.d.ts.map +1 -0
- package/build/plan.js +101 -0
- package/build/plan.js.map +1 -0
- package/build/plugins/checkout-plugins.d.ts +41 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +125 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/consts.local.d.ts +13 -0
- package/build/plugins/consts.local.d.ts.map +1 -0
- package/build/plugins/consts.local.js +22 -0
- package/build/plugins/consts.local.js.map +1 -0
- package/build/plugins/estimate.d.ts +18 -0
- package/build/plugins/estimate.d.ts.map +1 -0
- package/build/plugins/estimate.js +278 -0
- package/build/plugins/estimate.js.map +1 -0
- package/build/plugins/events.d.ts +31 -10
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +625 -136
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx.d.ts +28 -0
- package/build/plugins/fx.d.ts.map +1 -0
- package/build/plugins/fx.js +83 -0
- package/build/plugins/fx.js.map +1 -0
- package/build/plugins/portal.d.ts +40 -0
- package/build/plugins/portal.d.ts.map +1 -0
- package/build/plugins/portal.js +278 -0
- package/build/plugins/portal.js.map +1 -0
- package/build/plugins/refunds.d.ts +13 -0
- package/build/plugins/refunds.d.ts.map +1 -0
- package/build/plugins/refunds.js +80 -0
- package/build/plugins/refunds.js.map +1 -0
- package/build/plugins/stripe.d.ts +44 -4
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +559 -97
- package/build/plugins/stripe.js.map +1 -1
- package/build/plugins/types.d.ts +82 -0
- package/build/plugins/types.d.ts.map +1 -0
- package/build/plugins/types.js +2 -0
- package/build/plugins/types.js.map +1 -0
- package/build/plugins/types.local.d.ts +76 -0
- package/build/plugins/types.local.d.ts.map +1 -0
- package/build/plugins/types.local.js +2 -0
- package/build/plugins/types.local.js.map +1 -0
- package/build/plugins/webhook-manager.d.ts +54 -0
- package/build/plugins/webhook-manager.d.ts.map +1 -0
- package/build/plugins/webhook-manager.js +242 -0
- package/build/plugins/webhook-manager.js.map +1 -0
- package/build/reconcile.d.ts +15 -0
- package/build/reconcile.d.ts.map +1 -0
- package/build/reconcile.js +89 -0
- package/build/reconcile.js.map +1 -0
- package/build/resource.d.ts +12 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +98 -6
- package/build/resource.js.map +1 -1
- package/build/schemas.d.ts +15 -0
- package/build/schemas.d.ts.map +1 -0
- package/build/schemas.js +228 -0
- package/build/schemas.js.map +1 -0
- package/build/service.d.ts +42 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +193 -19
- package/build/service.js.map +1 -1
- package/build/subscription.d.ts +27 -0
- package/build/subscription.d.ts.map +1 -0
- package/build/subscription.js +179 -0
- package/build/subscription.js.map +1 -0
- package/build/sync.d.ts +28 -1
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +208 -32
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +1258 -36
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +27 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/usage.d.ts +52 -0
- package/build/usage.d.ts.map +1 -0
- package/build/usage.js +373 -0
- package/build/usage.js.map +1 -0
- package/build/utils.d.ts +70 -2
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +105 -7
- package/build/utils.js.map +1 -1
- package/package.json +21 -16
- package/src/actions/index.ts +1 -0
- package/src/actions/resync-subscriptions.ts +9 -0
- package/src/actions/resync.ts +11 -4
- package/src/actions/webhook.ts +8 -4
- package/src/config.ts +268 -9
- package/src/consts.local.ts +62 -0
- package/src/consts.ts +100 -36
- package/src/consumer/capture.ts +335 -0
- package/src/consumer/consts.local.ts +18 -0
- package/src/consumer/format.ts +90 -0
- package/src/consumer/handlers.ts +200 -0
- package/src/consumer/index.ts +6 -0
- package/src/consumer/mail.ts +354 -0
- package/src/consumer/origin.ts +61 -0
- package/src/consumer/reconcile.ts +326 -0
- package/src/consumer/records.ts +357 -0
- package/src/consumer/service.ts +855 -0
- package/src/consumer/types.local.ts +22 -0
- package/src/consumer/types.ts +98 -0
- package/src/consumer/withdrawal.ts +273 -0
- package/src/entitlement.ts +84 -0
- package/src/entrypoints.ts +17 -4
- package/src/gate.ts +72 -26
- package/src/index.ts +27 -3
- package/src/limit.ts +54 -0
- package/src/log.ts +4 -0
- package/src/observer.ts +44 -11
- package/src/plan.ts +124 -0
- package/src/plugins/checkout-plugins.ts +145 -0
- package/src/plugins/consts.local.ts +30 -0
- package/src/plugins/estimate.ts +319 -0
- package/src/plugins/events.ts +674 -121
- package/src/plugins/fx.ts +101 -0
- package/src/plugins/portal.ts +313 -0
- package/src/plugins/refunds.ts +93 -0
- package/src/plugins/stripe.ts +613 -98
- package/src/plugins/types.local.ts +62 -0
- package/src/plugins/types.ts +87 -0
- package/src/plugins/webhook-manager.ts +278 -0
- package/src/reconcile.ts +102 -0
- package/src/resource.ts +145 -7
- package/src/schemas.ts +247 -0
- package/src/service.ts +217 -20
- package/src/subscription.ts +208 -0
- package/src/sync.ts +240 -30
- package/src/types.local.ts +20 -0
- package/src/types.ts +1367 -32
- package/src/usage.ts +443 -0
- package/src/utils.ts +175 -14
- package/tests/checkout-consumer.spec.ts +367 -0
- package/tests/checkout-locks.spec.ts +160 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/checkout.spec.ts +204 -91
- package/tests/consumer-events.spec.ts +217 -0
- package/tests/consumer-fixtures.ts +132 -0
- package/tests/consumer-ops.spec.ts +351 -0
- package/tests/consumer-rights.integration.spec.ts +149 -0
- package/tests/consumer-rights.spec.ts +577 -0
- package/tests/context.ts +109 -0
- package/tests/entitlement.spec.ts +139 -0
- package/tests/estimate.spec.ts +274 -0
- package/tests/events.spec.ts +356 -0
- package/tests/fake-stripe.ts +975 -0
- package/tests/gate-handlers.spec.ts +120 -0
- package/tests/gate.spec.ts +62 -72
- package/tests/gateway-options.spec.ts +181 -0
- package/tests/limit-gate.spec.ts +68 -0
- package/tests/portal.spec.ts +200 -0
- package/tests/protocol.spec.ts +17 -3
- package/tests/sync.spec.ts +114 -0
- package/tests/usage.integration.spec.ts +101 -0
- package/tests/usage.spec.ts +171 -0
- package/tests/webhook-manager.spec.ts +152 -0
- package/build/model.d.ts +0 -6
- package/build/model.d.ts.map +0 -1
- package/build/model.js +0 -33
- package/build/model.js.map +0 -1
- package/src/model.ts +0 -37
package/build/consts.d.ts
CHANGED
|
@@ -1,25 +1,83 @@
|
|
|
1
|
+
import { INTERNAL_PAYGATE, LIMIT_GATE } from '@owlmeans/payment';
|
|
2
|
+
export { INTERNAL_PAYGATE, LIMIT_GATE };
|
|
1
3
|
export declare const STRIPE_PAYGATE_ALIAS = "stripe";
|
|
2
4
|
export declare const STRIPE_PLUGIN_CONFIG = "_external:stripe";
|
|
5
|
+
export declare const STRIPE_PORTAL_PLUGIN_CONFIG = "_external:stripe-portal";
|
|
6
|
+
/** Stripe-only pricing settings (FX Quotes API version, the unspecified-price migration switch) — never advertised to the browser, unlike the `PricingPolicy` record itself. */
|
|
7
|
+
export declare const STRIPE_PRICING_PLUGIN_CONFIG = "_external:stripe-pricing";
|
|
3
8
|
export declare const STRIPE_SIGNATURE = "Stripe-Signature";
|
|
9
|
+
/**
|
|
10
|
+
* The FX Quotes API is a Stripe PREVIEW endpoint as of this writing: it answers only a
|
|
11
|
+
* `Stripe-Version` header naming a preview version, never the SDK's pinned stable one. Verify this
|
|
12
|
+
* string against https://docs.stripe.com/api/fx_quotes/create before relying on it, and override it
|
|
13
|
+
* with `declarePaymentPricing({ stripe: { fxApiVersion } })` once Stripe moves the API or renames
|
|
14
|
+
* the preview.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The Stripe API version every client of this package is pinned to (the one stripe-node 17 defaulted to).
|
|
18
|
+
* Moving it re-creates the stored webhook endpoints with their payload shapes, so it moves together with
|
|
19
|
+
* the readers of `current_period_*`, an invoice's subscription and a credit note's refund.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STRIPE_PINNED_API_VERSION = "2025-02-24.acacia";
|
|
22
|
+
export declare const STRIPE_FX_QUOTES_API_VERSION = "2025-07-30.preview";
|
|
4
23
|
export declare const GATEWAY_SERVICE = "payment-gateway";
|
|
5
24
|
export declare const PAYMENT_OBSERVER = "payment-observer";
|
|
25
|
+
export declare const ENTITLEMENT_SERVICE = "payment-entitlement";
|
|
6
26
|
export declare const RES_PAYGATE_CUSTOMER = "payment-paygate-customer";
|
|
7
27
|
export declare const RES_PAYMENT_SUBSCRIPTION = "payment-subscription";
|
|
28
|
+
export declare const RES_PAYMENT_FULFILLMENT = "payment-fulfillment";
|
|
29
|
+
export declare const RES_PAYMENT_WEBHOOK = "payment-webhook";
|
|
30
|
+
export declare const RES_PAYMENT_USAGE = "payment-usage";
|
|
31
|
+
export declare const RES_PAYMENT_USAGE_COUNTER = "payment-usage-counter";
|
|
8
32
|
export declare const RES_PAYMENT_FINGERPRINT = "payment-fingerprint";
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
/** One per organization: the billing country fixed at the first purchase. */
|
|
34
|
+
export declare const RES_BILLING_PROFILE = "payment-billing-profile";
|
|
35
|
+
/** One per paid checkout (a top-up, a subscription's first invoice): the contract and its window. */
|
|
36
|
+
export declare const RES_PAYMENT_PURCHASE = "payment-purchase";
|
|
37
|
+
/** Append-only: express consents to early performance and subscription start requests. */
|
|
38
|
+
export declare const RES_CONSUMER_CONSENT = "payment-consumer-consent";
|
|
39
|
+
/** Append-only: withdrawal and cancellation declarations. */
|
|
40
|
+
export declare const RES_CONSUMER_DECLARATION = "payment-consumer-declaration";
|
|
41
|
+
/** Append-only: every execution and audit step of the consumer-rights flows. */
|
|
42
|
+
export declare const RES_CONSUMER_EVENT = "payment-consumer-event";
|
|
43
|
+
export declare const CONSUMER_RIGHTS_SERVICE = "payment-consumer-rights";
|
|
44
|
+
/** The consumer-rights mail options (trader, sender, archive copies) — never advertised. */
|
|
45
|
+
export declare const CONSUMER_RIGHTS_MAIL_PLUGIN_CONFIG = "_external:payment-consumer-mail";
|
|
46
|
+
/** Stripe's own bounds of a Checkout Session's `expires_at`, from now. */
|
|
47
|
+
export declare const STRIPE_SESSION_TTL_MIN_SECONDS: number;
|
|
48
|
+
export declare const STRIPE_SESSION_TTL_MAX_SECONDS: number;
|
|
49
|
+
/** How far back `reconcile` looks for completed sessions that have no purchase row. */
|
|
50
|
+
export declare const PURCHASE_BACKFILL_DAYS = 16;
|
|
51
|
+
/** Top-level domains that never receive mail (RFC 2606 / 6761) — e2e addresses are recorded as skipped. */
|
|
52
|
+
export declare const RESERVED_MAIL_TLDS: readonly string[];
|
|
53
|
+
/** The purchase id prefix of a Stripe purchase: `stripe:<session id>` or `stripe:<subscription id>`. */
|
|
54
|
+
export declare const PURCHASE_ID_PREFIX = "stripe";
|
|
55
|
+
/**
|
|
56
|
+
* The contract reference alphabet: digits and capitals without the look-alikes 0/O, 1/I/L, so a
|
|
57
|
+
* reference read aloud or typed from paper is never ambiguous.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CONTRACT_REF_ALPHABET = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
|
|
60
|
+
/** Fingerprint sku prefix of a portal configuration: `portal:<owner>` (the gateway's `owner`). */
|
|
61
|
+
export declare const FINGERPRINT_PORTAL = "portal";
|
|
62
|
+
/**
|
|
63
|
+
* The metadata every Stripe object this package creates carries (`{ owlmeans: 'payment', service }`,
|
|
64
|
+
* `service` valued with the gateway's `owner`). It labels the object for an operator; several
|
|
65
|
+
* deployments of one owner share it, so it never decides on its own that an object belongs to this
|
|
66
|
+
* deployment.
|
|
67
|
+
*/
|
|
68
|
+
export declare const STRIPE_OWNER_KEY = "owlmeans";
|
|
69
|
+
export declare const STRIPE_OWNER_VALUE = "payment";
|
|
70
|
+
/**
|
|
71
|
+
* The metadata key naming the ONE deployment a portal configuration belongs to, valued with that
|
|
72
|
+
* deployment's webhook URL (`webhookUrlOf`). Only an exact match lets a deployment adopt a
|
|
73
|
+
* configuration it holds no fingerprint row for.
|
|
74
|
+
*/
|
|
75
|
+
export declare const STRIPE_DEPLOYMENT_KEY = "deployment";
|
|
76
|
+
/**
|
|
77
|
+
* Every Stripe event the managed webhook endpoint subscribes to.
|
|
78
|
+
*
|
|
79
|
+
* `invoice.upcoming` is enabled although nothing handles it (it carries no invoice id and nothing
|
|
80
|
+
* is due), so an application can observe it without a Stripe dashboard change.
|
|
81
|
+
*/
|
|
82
|
+
export declare const WEBHOOK_EVENTS: readonly string[];
|
|
25
83
|
//# sourceMappingURL=consts.d.ts.map
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,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CAAA;AAE1D,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAA+D,CAAA;AAE/G,wGAAwG;AACxG,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,oCAAoC,CAAA;AAEtE,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAa,CAAA;AAC1C,eAAO,MAAM,kBAAkB,YAAY,CAAA;AAE3C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAY1C,CAAA"}
|
package/build/consts.js
CHANGED
|
@@ -1,32 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { GUARD_ED25519 } from '@owlmeans/server-app';
|
|
1
|
+
import { INTERNAL_PAYGATE, LIMIT_GATE } from '@owlmeans/payment';
|
|
2
|
+
export { INTERNAL_PAYGATE, LIMIT_GATE };
|
|
4
3
|
export const STRIPE_PAYGATE_ALIAS = 'stripe';
|
|
5
4
|
export const STRIPE_PLUGIN_CONFIG = '_external:stripe';
|
|
5
|
+
export const STRIPE_PORTAL_PLUGIN_CONFIG = '_external:stripe-portal';
|
|
6
|
+
/** Stripe-only pricing settings (FX Quotes API version, the unspecified-price migration switch) — never advertised to the browser, unlike the `PricingPolicy` record itself. */
|
|
7
|
+
export const STRIPE_PRICING_PLUGIN_CONFIG = '_external:stripe-pricing';
|
|
6
8
|
export const STRIPE_SIGNATURE = 'Stripe-Signature';
|
|
9
|
+
/**
|
|
10
|
+
* The FX Quotes API is a Stripe PREVIEW endpoint as of this writing: it answers only a
|
|
11
|
+
* `Stripe-Version` header naming a preview version, never the SDK's pinned stable one. Verify this
|
|
12
|
+
* string against https://docs.stripe.com/api/fx_quotes/create before relying on it, and override it
|
|
13
|
+
* with `declarePaymentPricing({ stripe: { fxApiVersion } })` once Stripe moves the API or renames
|
|
14
|
+
* the preview.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The Stripe API version every client of this package is pinned to (the one stripe-node 17 defaulted to).
|
|
18
|
+
* Moving it re-creates the stored webhook endpoints with their payload shapes, so it moves together with
|
|
19
|
+
* the readers of `current_period_*`, an invoice's subscription and a credit note's refund.
|
|
20
|
+
*/
|
|
21
|
+
export const STRIPE_PINNED_API_VERSION = '2025-02-24.acacia';
|
|
22
|
+
export const STRIPE_FX_QUOTES_API_VERSION = '2025-07-30.preview';
|
|
7
23
|
export const GATEWAY_SERVICE = 'payment-gateway';
|
|
8
24
|
export const PAYMENT_OBSERVER = 'payment-observer';
|
|
25
|
+
export const ENTITLEMENT_SERVICE = 'payment-entitlement';
|
|
9
26
|
export const RES_PAYGATE_CUSTOMER = 'payment-paygate-customer';
|
|
10
27
|
export const RES_PAYMENT_SUBSCRIPTION = 'payment-subscription';
|
|
28
|
+
export const RES_PAYMENT_FULFILLMENT = 'payment-fulfillment';
|
|
29
|
+
export const RES_PAYMENT_WEBHOOK = 'payment-webhook';
|
|
30
|
+
export const RES_PAYMENT_USAGE = 'payment-usage';
|
|
31
|
+
export const RES_PAYMENT_USAGE_COUNTER = 'payment-usage-counter';
|
|
11
32
|
export const RES_PAYMENT_FINGERPRINT = 'payment-fingerprint';
|
|
12
|
-
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
/** One per organization: the billing country fixed at the first purchase. */
|
|
34
|
+
export const RES_BILLING_PROFILE = 'payment-billing-profile';
|
|
35
|
+
/** One per paid checkout (a top-up, a subscription's first invoice): the contract and its window. */
|
|
36
|
+
export const RES_PAYMENT_PURCHASE = 'payment-purchase';
|
|
37
|
+
/** Append-only: express consents to early performance and subscription start requests. */
|
|
38
|
+
export const RES_CONSUMER_CONSENT = 'payment-consumer-consent';
|
|
39
|
+
/** Append-only: withdrawal and cancellation declarations. */
|
|
40
|
+
export const RES_CONSUMER_DECLARATION = 'payment-consumer-declaration';
|
|
41
|
+
/** Append-only: every execution and audit step of the consumer-rights flows. */
|
|
42
|
+
export const RES_CONSUMER_EVENT = 'payment-consumer-event';
|
|
43
|
+
export const CONSUMER_RIGHTS_SERVICE = 'payment-consumer-rights';
|
|
44
|
+
/** The consumer-rights mail options (trader, sender, archive copies) — never advertised. */
|
|
45
|
+
export const CONSUMER_RIGHTS_MAIL_PLUGIN_CONFIG = '_external:payment-consumer-mail';
|
|
46
|
+
/** Stripe's own bounds of a Checkout Session's `expires_at`, from now. */
|
|
47
|
+
export const STRIPE_SESSION_TTL_MIN_SECONDS = 30 * 60;
|
|
48
|
+
export const STRIPE_SESSION_TTL_MAX_SECONDS = 24 * 60 * 60;
|
|
49
|
+
/** How far back `reconcile` looks for completed sessions that have no purchase row. */
|
|
50
|
+
export const PURCHASE_BACKFILL_DAYS = 16;
|
|
51
|
+
/** Top-level domains that never receive mail (RFC 2606 / 6761) — e2e addresses are recorded as skipped. */
|
|
52
|
+
export const RESERVED_MAIL_TLDS = Object.freeze(['test', 'example', 'invalid', 'localhost']);
|
|
53
|
+
/** The purchase id prefix of a Stripe purchase: `stripe:<session id>` or `stripe:<subscription id>`. */
|
|
54
|
+
export const PURCHASE_ID_PREFIX = 'stripe';
|
|
55
|
+
/**
|
|
56
|
+
* The contract reference alphabet: digits and capitals without the look-alikes 0/O, 1/I/L, so a
|
|
57
|
+
* reference read aloud or typed from paper is never ambiguous.
|
|
58
|
+
*/
|
|
59
|
+
export const CONTRACT_REF_ALPHABET = '23456789ABCDEFGHJKMNPQRSTUVWXYZ';
|
|
60
|
+
/** Fingerprint sku prefix of a portal configuration: `portal:<owner>` (the gateway's `owner`). */
|
|
61
|
+
export const FINGERPRINT_PORTAL = 'portal';
|
|
62
|
+
/**
|
|
63
|
+
* The metadata every Stripe object this package creates carries (`{ owlmeans: 'payment', service }`,
|
|
64
|
+
* `service` valued with the gateway's `owner`). It labels the object for an operator; several
|
|
65
|
+
* deployments of one owner share it, so it never decides on its own that an object belongs to this
|
|
66
|
+
* deployment.
|
|
67
|
+
*/
|
|
68
|
+
export const STRIPE_OWNER_KEY = 'owlmeans';
|
|
69
|
+
export const STRIPE_OWNER_VALUE = 'payment';
|
|
70
|
+
/**
|
|
71
|
+
* The metadata key naming the ONE deployment a portal configuration belongs to, valued with that
|
|
72
|
+
* deployment's webhook URL (`webhookUrlOf`). Only an exact match lets a deployment adopt a
|
|
73
|
+
* configuration it holds no fingerprint row for.
|
|
74
|
+
*/
|
|
75
|
+
export const STRIPE_DEPLOYMENT_KEY = 'deployment';
|
|
76
|
+
/**
|
|
77
|
+
* Every Stripe event the managed webhook endpoint subscribes to.
|
|
78
|
+
*
|
|
79
|
+
* `invoice.upcoming` is enabled although nothing handles it (it carries no invoice id and nothing
|
|
80
|
+
* is due), so an application can observe it without a Stripe dashboard change.
|
|
81
|
+
*/
|
|
82
|
+
export const WEBHOOK_EVENTS = Object.freeze([
|
|
83
|
+
'checkout.session.completed', 'checkout.session.async_payment_succeeded',
|
|
84
|
+
'checkout.session.async_payment_failed', 'checkout.session.expired',
|
|
85
|
+
'customer.created', 'customer.updated', 'customer.deleted',
|
|
86
|
+
'customer.subscription.created', 'customer.subscription.updated', 'customer.subscription.deleted',
|
|
87
|
+
'customer.subscription.paused', 'customer.subscription.resumed', 'customer.subscription.trial_will_end',
|
|
88
|
+
'customer.subscription.pending_update_applied', 'customer.subscription.pending_update_expired',
|
|
89
|
+
'invoice.paid', 'invoice.payment_failed', 'invoice.payment_action_required', 'invoice.upcoming',
|
|
90
|
+
'invoice.marked_uncollectible', 'invoice.voided',
|
|
91
|
+
'charge.refunded', 'refund.created', 'refund.updated', 'refund.failed',
|
|
92
|
+
'charge.dispute.created', 'charge.dispute.closed', 'charge.dispute.funds_withdrawn',
|
|
93
|
+
'charge.dispute.funds_reinstated',
|
|
94
|
+
]);
|
|
32
95
|
//# sourceMappingURL=consts.js.map
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAA;AAEvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAA;AACtD,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAA;AACpE,gLAAgL;AAChL,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAA;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAElD;;;;;;GAMG;AACH;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAA;AAE5D,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAA;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAA;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,CAAA;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAA;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AAEtE,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAA;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAA;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC7D,4BAA4B,EAAE,0CAA0C;IACxE,uCAAuC,EAAE,0BAA0B;IACnE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB;IAC1D,+BAA+B,EAAE,+BAA+B,EAAE,+BAA+B;IACjG,8BAA8B,EAAE,+BAA+B,EAAE,sCAAsC;IACvG,8CAA8C,EAAE,8CAA8C;IAC9F,cAAc,EAAE,wBAAwB,EAAE,iCAAiC,EAAE,kBAAkB;IAC/F,8BAA8B,EAAE,gBAAgB;IAChD,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe;IACtE,wBAAwB,EAAE,uBAAuB,EAAE,gCAAgC;IACnF,iCAAiC;CAClC,CAAC,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SubscriptionStatus } from '@owlmeans/payment';
|
|
2
|
+
import type { PaymentSubscriptionRecord, SubscriptionChange } from './types.js';
|
|
3
|
+
export declare const LIMIT_KINDS: string[];
|
|
4
|
+
export declare const LIMIT_WINDOWS: string[];
|
|
5
|
+
export declare const CURRENCY: RegExp;
|
|
6
|
+
export declare const aliases: {
|
|
7
|
+
readonly base: 'payment-gate';
|
|
8
|
+
readonly webhook: 'payment-gate:webhook';
|
|
9
|
+
readonly resync: 'payment-gate:resync';
|
|
10
|
+
readonly resyncSubscriptions: 'payment-gate:resync-subscriptions';
|
|
11
|
+
};
|
|
12
|
+
export declare const str: {
|
|
13
|
+
readonly type: 'string';
|
|
14
|
+
};
|
|
15
|
+
export declare const optStr: {
|
|
16
|
+
readonly type: 'string';
|
|
17
|
+
readonly nullable: true;
|
|
18
|
+
};
|
|
19
|
+
export declare const num: {
|
|
20
|
+
readonly type: 'number';
|
|
21
|
+
};
|
|
22
|
+
export declare const optNum: {
|
|
23
|
+
readonly type: 'number';
|
|
24
|
+
readonly nullable: true;
|
|
25
|
+
};
|
|
26
|
+
export declare const optBool: {
|
|
27
|
+
readonly type: 'boolean';
|
|
28
|
+
readonly nullable: true;
|
|
29
|
+
};
|
|
30
|
+
export declare const date: import("ajv").JSONSchemaType<Date>;
|
|
31
|
+
export declare const id: {
|
|
32
|
+
readonly type: 'string';
|
|
33
|
+
readonly nullable: true;
|
|
34
|
+
};
|
|
35
|
+
/** The request evidence every consumer act carries (`RequestOrigin`). */
|
|
36
|
+
export declare const origin: {
|
|
37
|
+
readonly ip: {
|
|
38
|
+
readonly type: 'string';
|
|
39
|
+
readonly nullable: true;
|
|
40
|
+
};
|
|
41
|
+
readonly forwardedFor: {
|
|
42
|
+
readonly type: 'string';
|
|
43
|
+
readonly nullable: true;
|
|
44
|
+
};
|
|
45
|
+
readonly userAgent: {
|
|
46
|
+
readonly type: 'string';
|
|
47
|
+
readonly nullable: true;
|
|
48
|
+
};
|
|
49
|
+
readonly ipCountry: {
|
|
50
|
+
readonly type: 'string';
|
|
51
|
+
readonly nullable: true;
|
|
52
|
+
};
|
|
53
|
+
readonly acceptLanguage: {
|
|
54
|
+
readonly type: 'string';
|
|
55
|
+
readonly nullable: true;
|
|
56
|
+
};
|
|
57
|
+
readonly via: {
|
|
58
|
+
readonly type: 'string';
|
|
59
|
+
readonly nullable: true;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare const links: {
|
|
63
|
+
readonly type: 'object';
|
|
64
|
+
readonly properties: {
|
|
65
|
+
readonly billingTerms: {
|
|
66
|
+
readonly type: 'string';
|
|
67
|
+
};
|
|
68
|
+
readonly withdrawalInformation: {
|
|
69
|
+
readonly type: 'string';
|
|
70
|
+
readonly nullable: true;
|
|
71
|
+
};
|
|
72
|
+
readonly withdrawalForm: {
|
|
73
|
+
readonly type: 'string';
|
|
74
|
+
readonly nullable: true;
|
|
75
|
+
};
|
|
76
|
+
readonly withdrawalFunction: {
|
|
77
|
+
readonly type: 'string';
|
|
78
|
+
readonly nullable: true;
|
|
79
|
+
};
|
|
80
|
+
readonly cancellation: {
|
|
81
|
+
readonly type: 'string';
|
|
82
|
+
readonly nullable: true;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
readonly required: readonly ['billingTerms'];
|
|
86
|
+
readonly additionalProperties: false;
|
|
87
|
+
};
|
|
88
|
+
export declare const ENDED: readonly SubscriptionStatus[];
|
|
89
|
+
export declare const MATERIAL: Array<keyof PaymentSubscriptionRecord>;
|
|
90
|
+
/** The log event of a change observers were told about; every other change is `subscription.updated`. */
|
|
91
|
+
export declare const SUBSCRIPTION_LOG_EVENTS: Partial<Record<SubscriptionChange, string>>;
|
|
92
|
+
export declare const DAY_WINDOW: RegExp;
|
|
93
|
+
export declare const MONTH_WINDOW: RegExp;
|
|
94
|
+
//# sourceMappingURL=consts.local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE/E,eAAO,MAAM,WAAW,EAA+B,MAAM,EAAE,CAAA;AAE/D,eAAO,MAAM,aAAa,EAAiC,MAAM,EAAE,CAAA;AAEnE,eAAO,MAAM,QAAQ,QAAe,CAAA;AAEpC,eAAO,MAAM,OAAO;aAClB,IAAI,EAAE,cAAc;aACpB,OAAO,EAAE,sBAAsB;aAC/B,MAAM,EAAE,qBAAqB;aAC7B,mBAAmB,EAAE,mCAAm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
import { LimitKind, LimitWindow, SubscriptionStatus } from '@owlmeans/payment';
|
|
2
|
+
import { DateSchema } from '@owlmeans/auth';
|
|
3
|
+
export const LIMIT_KINDS = Object.values(LimitKind);
|
|
4
|
+
export const LIMIT_WINDOWS = Object.values(LimitWindow);
|
|
5
|
+
export const CURRENCY = /^[a-z]{3}$/;
|
|
6
|
+
export const aliases = {
|
|
7
|
+
base: 'payment-gate',
|
|
8
|
+
webhook: 'payment-gate:webhook',
|
|
9
|
+
resync: 'payment-gate:resync',
|
|
10
|
+
resyncSubscriptions: 'payment-gate:resync-subscriptions',
|
|
11
|
+
};
|
|
12
|
+
export const str = { type: 'string' };
|
|
13
|
+
export const optStr = { type: 'string', nullable: true };
|
|
14
|
+
export const num = { type: 'number' };
|
|
15
|
+
export const optNum = { type: 'number', nullable: true };
|
|
16
|
+
export const optBool = { type: 'boolean', nullable: true };
|
|
17
|
+
export const date = DateSchema;
|
|
18
|
+
export const id = { type: 'string', nullable: true };
|
|
19
|
+
/** The request evidence every consumer act carries (`RequestOrigin`). */
|
|
20
|
+
export const origin = {
|
|
21
|
+
ip: optStr, forwardedFor: optStr, userAgent: optStr, ipCountry: optStr, acceptLanguage: optStr, via: optStr,
|
|
22
|
+
};
|
|
23
|
+
export const links = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
billingTerms: str, withdrawalInformation: optStr, withdrawalForm: optStr, withdrawalFunction: optStr,
|
|
27
|
+
cancellation: optStr,
|
|
28
|
+
},
|
|
29
|
+
required: ['billingTerms'],
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
};
|
|
32
|
+
export const ENDED = [SubscriptionStatus.Canceled, SubscriptionStatus.Ended];
|
|
33
|
+
export const MATERIAL = [
|
|
34
|
+
'entityId', 'planSku', 'productSku', 'service', 'itemId', 'priceId', 'status', 'externalStatus', 'rank',
|
|
35
|
+
'periodStart', 'periodEnd', 'cancelAtPeriodEnd', 'canceledAt', 'endedAt', 'pausedAt', 'trialEnd',
|
|
36
|
+
'latestInvoiceId', 'customerId',
|
|
37
|
+
];
|
|
38
|
+
/** The log event of a change observers were told about; every other change is `subscription.updated`. */
|
|
39
|
+
export const SUBSCRIPTION_LOG_EVENTS = {
|
|
40
|
+
created: 'subscription.started', renewed: 'subscription.renewed', canceled: 'subscription.canceled',
|
|
41
|
+
};
|
|
42
|
+
export const DAY_WINDOW = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
43
|
+
export const MONTH_WINDOW = /^(\d{4})-(\d{2})$/;
|
|
44
|
+
//# sourceMappingURL=consts.local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAa,CAAA;AAE/D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAa,CAAA;AAEnE,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAA;AAEpC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sBAAsB;IAC/B,MAAM,EAAE,qBAAqB;IAC7B,mBAAmB,EAAE,mCAAmC;CAChD,CAAA;AAEV,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAW,CAAA;AAE9C,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAA;AAEjE,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAW,CAAA;AAE9C,MAAM,CAAC,MAAM,MAAM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AAuB,GAAgD;IAClF,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,uBAAuB;CACpG,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,2BAA2B,CAAA;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type Stripe from 'stripe';
|
|
2
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
3
|
+
import type { CapturedPurchase, InvoiceEvidence, SessionEvidence } from './types.js';
|
|
4
|
+
import type { PaymentSubscriptionRecord, PurchaseRecord } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* The buyer and totals of a Checkout Session. `presentment_details` (Adaptive Pricing) is not typed
|
|
7
|
+
* by the pinned SDK, hence the narrow accessor.
|
|
8
|
+
*/
|
|
9
|
+
declare const sessionEvidenceOf: (session: Stripe.Checkout.Session) => SessionEvidence;
|
|
10
|
+
/**
|
|
11
|
+
* An invoice's evidence, best effort: an unreachable invoice is logged and yields nothing — the
|
|
12
|
+
* withdrawal reads it again when it needs it. `invoice.payment_intent` is top-level on the pinned
|
|
13
|
+
* API version.
|
|
14
|
+
*/
|
|
15
|
+
declare const invoiceEvidenceOf: (stripe: Stripe | null | undefined, invoiceId: string | undefined) => Promise<InvoiceEvidence>;
|
|
16
|
+
/**
|
|
17
|
+
* A completed, paid ONE-TIME checkout as a purchase — the window and the contract registry. Runs
|
|
18
|
+
* BEFORE the credits are granted: the billing country is locked first (first write wins; another
|
|
19
|
+
* country is a `lock-mismatch` event), then the purchase row is written, then its confirmation is
|
|
20
|
+
* mailed. `null` when no consumer-rights policy is declared.
|
|
21
|
+
*/
|
|
22
|
+
declare const capturePaymentPurchase: (ctx: ApiContext, stripe: Stripe | null, session: Stripe.Checkout.Session, extra?: {
|
|
23
|
+
netAmountMinor?: number;
|
|
24
|
+
amountCurrency?: string;
|
|
25
|
+
units?: number;
|
|
26
|
+
taxBehavior?: string;
|
|
27
|
+
at?: Date;
|
|
28
|
+
}, opts?: {
|
|
29
|
+
mail?: boolean;
|
|
30
|
+
}) => Promise<CapturedPurchase | null>;
|
|
31
|
+
/**
|
|
32
|
+
* A subscription's FIRST invoice as a purchase — called while the subscription is committed, BEFORE
|
|
33
|
+
* the `created` observers grant anything, so the window exists before the bundle can be spent. The
|
|
34
|
+
* buyer's country and totals are refined when the checkout completes. The start request (when the
|
|
35
|
+
* metadata names one) is the purchase's consent: `servicesStartedAt` and `consentedAt`.
|
|
36
|
+
*/
|
|
37
|
+
declare const captureSubscriptionPurchase: (ctx: ApiContext, stripe: Stripe | null, subscription: Stripe.Subscription, row: PaymentSubscriptionRecord) => Promise<CapturedPurchase | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Refine a subscription purchase with its completed checkout: the buyer's own country (and so the
|
|
40
|
+
* scope and deadline), e-mail, the charged totals, the terms acceptance and the session id; lock
|
|
41
|
+
* the billing country; mail the confirmation once.
|
|
42
|
+
*/
|
|
43
|
+
declare const completeSubscriptionPurchase: (ctx: ApiContext, stripe: Stripe | null, session: Stripe.Checkout.Session, purchase: PurchaseRecord, opts?: {
|
|
44
|
+
mail?: boolean;
|
|
45
|
+
}) => Promise<PurchaseRecord>;
|
|
46
|
+
export declare const createCaptureHelper: () => {
|
|
47
|
+
sessionEvidenceOf: typeof sessionEvidenceOf;
|
|
48
|
+
invoiceEvidenceOf: typeof invoiceEvidenceOf;
|
|
49
|
+
capturePaymentPurchase: typeof capturePaymentPurchase;
|
|
50
|
+
captureSubscriptionPurchase: typeof captureSubscriptionPurchase;
|
|
51
|
+
completeSubscriptionPurchase: typeof completeSubscriptionPurchase;
|
|
52
|
+
};
|
|
53
|
+
export declare const captureHelper: {
|
|
54
|
+
sessionEvidenceOf: typeof sessionEvidenceOf;
|
|
55
|
+
invoiceEvidenceOf: typeof invoiceEvidenceOf;
|
|
56
|
+
capturePaymentPurchase: typeof capturePaymentPurchase;
|
|
57
|
+
captureSubscriptionPurchase: typeof captureSubscriptionPurchase;
|
|
58
|
+
completeSubscriptionPurchase: typeof completeSubscriptionPurchase;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/consumer/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAOjE,OAAO,KAAK,EAAiB,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACnG,OAAO,KAAK,EAAwB,yBAAyB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGlG;;;GAGG;AACH,QAAA,MAAM,iBAAiB,YAAa,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAG,eAsB7D,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,WAAkB,MAAM,GAAG,IAAI,GAAG,SAAS,aAAa,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,eAAe,CAwB1H,CAAA;AAoDD;;;;;GAKG;AACH,QAAA,MAAM,sBAAsB,QACrB,UAAU,UAAU,MAAM,GAAG,IAAI,WAAW,MAAM,CAAC,QAAQ,CAAC,OAAO,UACjE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE,SACtG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KACvB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAiEjC,CAAA;AAYD;;;;;GAKG;AACH,QAAA,MAAM,2BAA2B,QAC1B,UAAU,UAAU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