@owlmeans/payment 0.1.18-rc.9 → 0.1.18
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 +95 -57
- package/agent-meta/manifest.json +10 -3
- package/agent-meta/skills/entitlements/SKILL.md +159 -0
- package/agent-meta/skills/payment/SKILL.md +491 -28
- package/build/advertise.d.ts +2 -0
- package/build/advertise.d.ts.map +1 -0
- package/build/advertise.js +10 -0
- package/build/advertise.js.map +1 -0
- package/build/checkout/consts.d.ts +2 -0
- package/build/checkout/consts.d.ts.map +1 -0
- package/build/checkout/consts.js +2 -0
- package/build/checkout/consts.js.map +1 -0
- package/build/checkout/index.d.ts +6 -0
- package/build/checkout/index.d.ts.map +1 -0
- package/build/checkout/index.js +4 -0
- package/build/checkout/index.js.map +1 -0
- package/build/checkout/narrow/types.d.ts +25 -0
- package/build/checkout/narrow/types.d.ts.map +1 -0
- package/build/checkout/narrow/types.js +2 -0
- package/build/checkout/narrow/types.js.map +1 -0
- package/build/checkout/narrow.d.ts +8 -0
- package/build/checkout/narrow.d.ts.map +1 -0
- package/build/checkout/narrow.js +47 -0
- package/build/checkout/narrow.js.map +1 -0
- package/build/checkout/protocols.d.ts +8 -0
- package/build/checkout/protocols.d.ts.map +1 -0
- package/build/checkout/protocols.js +28 -0
- package/build/checkout/protocols.js.map +1 -0
- package/build/checkout/types.d.ts +29 -0
- package/build/checkout/types.d.ts.map +1 -0
- package/build/checkout/types.js +2 -0
- package/build/checkout/types.js.map +1 -0
- package/build/consts.d.ts +242 -25
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +377 -24
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +20 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +23 -0
- package/build/consts.local.js.map +1 -0
- package/build/consumer/cancel.d.ts +11 -0
- package/build/consumer/cancel.d.ts.map +1 -0
- package/build/consumer/cancel.js +33 -0
- package/build/consumer/cancel.js.map +1 -0
- package/build/consumer/consts.d.ts +20 -0
- package/build/consumer/consts.d.ts.map +1 -0
- package/build/consumer/consts.js +39 -0
- package/build/consumer/consts.js.map +1 -0
- package/build/consumer/consts.local.d.ts +7 -0
- package/build/consumer/consts.local.d.ts.map +1 -0
- package/build/consumer/consts.local.js +13 -0
- package/build/consumer/consts.local.js.map +1 -0
- package/build/consumer/copy/types.d.ts +56 -0
- package/build/consumer/copy/types.d.ts.map +1 -0
- package/build/consumer/copy/types.js +2 -0
- package/build/consumer/copy/types.js.map +1 -0
- package/build/consumer/copy.d.ts +22 -0
- package/build/consumer/copy.d.ts.map +1 -0
- package/build/consumer/copy.js +87 -0
- package/build/consumer/copy.js.map +1 -0
- package/build/consumer/deadline/types.d.ts +30 -0
- package/build/consumer/deadline/types.d.ts.map +1 -0
- package/build/consumer/deadline/types.js +2 -0
- package/build/consumer/deadline/types.js.map +1 -0
- package/build/consumer/deadline.d.ts +12 -0
- package/build/consumer/deadline.d.ts.map +1 -0
- package/build/consumer/deadline.js +44 -0
- package/build/consumer/deadline.js.map +1 -0
- package/build/consumer/fifo/types.d.ts +17 -0
- package/build/consumer/fifo/types.d.ts.map +1 -0
- package/build/consumer/fifo/types.js +2 -0
- package/build/consumer/fifo/types.js.map +1 -0
- package/build/consumer/fifo.d.ts +4 -0
- package/build/consumer/fifo.d.ts.map +1 -0
- package/build/consumer/fifo.js +34 -0
- package/build/consumer/fifo.js.map +1 -0
- package/build/consumer/index.d.ts +18 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +11 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/policy/types.d.ts +20 -0
- package/build/consumer/policy/types.d.ts.map +1 -0
- package/build/consumer/policy/types.js +2 -0
- package/build/consumer/policy/types.js.map +1 -0
- package/build/consumer/policy.d.ts +17 -0
- package/build/consumer/policy.d.ts.map +1 -0
- package/build/consumer/policy.js +91 -0
- package/build/consumer/policy.js.map +1 -0
- package/build/consumer/protocols.d.ts +20 -0
- package/build/consumer/protocols.d.ts.map +1 -0
- package/build/consumer/protocols.js +70 -0
- package/build/consumer/protocols.js.map +1 -0
- package/build/consumer/refund/types.d.ts +27 -0
- package/build/consumer/refund/types.d.ts.map +1 -0
- package/build/consumer/refund/types.js +2 -0
- package/build/consumer/refund/types.js.map +1 -0
- package/build/consumer/refund.d.ts +9 -0
- package/build/consumer/refund.d.ts.map +1 -0
- package/build/consumer/refund.js +112 -0
- package/build/consumer/refund.js.map +1 -0
- package/build/consumer/refusal.d.ts +10 -0
- package/build/consumer/refusal.d.ts.map +1 -0
- package/build/consumer/refusal.js +35 -0
- package/build/consumer/refusal.js.map +1 -0
- package/build/consumer/revive/types.d.ts +19 -0
- package/build/consumer/revive/types.d.ts.map +1 -0
- package/build/consumer/revive/types.js +2 -0
- package/build/consumer/revive/types.js.map +1 -0
- package/build/consumer/revive.d.ts +13 -0
- package/build/consumer/revive.d.ts.map +1 -0
- package/build/consumer/revive.js +43 -0
- package/build/consumer/revive.js.map +1 -0
- package/build/consumer/types.d.ts +196 -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 +11 -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/countries.d.ts +3 -0
- package/build/countries.d.ts.map +1 -0
- package/build/countries.js +4 -0
- package/build/countries.js.map +1 -0
- package/build/entitled.d.ts +14 -0
- package/build/entitled.d.ts.map +1 -0
- package/build/entitled.js +17 -0
- package/build/entitled.js.map +1 -0
- package/build/entitlement/types.d.ts +29 -0
- package/build/entitlement/types.d.ts.map +1 -0
- package/build/entitlement/types.js +2 -0
- package/build/entitlement/types.js.map +1 -0
- package/build/entitlement.d.ts +7 -55
- package/build/entitlement.d.ts.map +1 -1
- package/build/entitlement.js +55 -86
- package/build/entitlement.js.map +1 -1
- package/build/errors.d.ts +189 -0
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js +361 -0
- package/build/errors.js.map +1 -1
- package/build/estimate/types.d.ts +34 -0
- package/build/estimate/types.d.ts.map +1 -0
- package/build/estimate/types.js +2 -0
- package/build/estimate/types.js.map +1 -0
- package/build/estimate.d.ts +11 -0
- package/build/estimate.d.ts.map +1 -0
- package/build/estimate.js +76 -0
- package/build/estimate.js.map +1 -0
- package/build/i18n/consumer-rights/be.json +131 -0
- package/build/i18n/consumer-rights/de.json +131 -0
- package/build/i18n/consumer-rights/en.json +131 -0
- package/build/i18n/consumer-rights/es.json +131 -0
- package/build/i18n/consumer-rights/fr.json +131 -0
- package/build/i18n/consumer-rights/pl.json +131 -0
- package/build/i18n/consumer-rights/ru.json +131 -0
- package/build/i18n/consumer-rights/uk.json +131 -0
- package/build/i18n/errors/be.json +30 -0
- package/build/i18n/errors/de.json +30 -0
- package/build/i18n/errors/en.json +30 -0
- package/build/i18n/errors/es.json +30 -0
- package/build/i18n/errors/fr.json +30 -0
- package/build/i18n/errors/pl.json +30 -0
- package/build/i18n/errors/ru.json +30 -0
- package/build/i18n/errors/uk.json +30 -0
- package/build/i18n/fr.json +39 -0
- package/build/i18n.js +53 -8
- package/build/i18n.js.map +1 -1
- package/build/index.d.ts +18 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +11 -1
- package/build/index.js.map +1 -1
- package/build/limit/types.d.ts +44 -0
- package/build/limit/types.d.ts.map +1 -0
- package/build/limit/types.js +2 -0
- package/build/limit/types.js.map +1 -0
- package/build/limit.d.ts +23 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +97 -0
- package/build/limit.js.map +1 -0
- package/build/model/checkout.d.ts +2 -3
- package/build/model/checkout.d.ts.map +1 -1
- package/build/model/checkout.js +12 -7
- package/build/model/checkout.js.map +1 -1
- package/build/model/consts.d.ts +15 -0
- package/build/model/consts.d.ts.map +1 -0
- package/build/model/consts.js +193 -0
- package/build/model/consts.js.map +1 -0
- package/build/model/consts.local.d.ts +35 -0
- package/build/model/consts.local.d.ts.map +1 -0
- package/build/model/consts.local.js +65 -0
- package/build/model/consts.local.js.map +1 -0
- package/build/model/consumer.d.ts +23 -0
- package/build/model/consumer.d.ts.map +1 -0
- package/build/model/consumer.js +272 -0
- package/build/model/consumer.js.map +1 -0
- package/build/model/estimate.d.ts +5 -0
- package/build/model/estimate.d.ts.map +1 -0
- package/build/model/estimate.js +69 -0
- package/build/model/estimate.js.map +1 -0
- package/build/model/index.d.ts +7 -2
- package/build/model/index.d.ts.map +1 -1
- package/build/model/index.js +7 -2
- package/build/model/index.js.map +1 -1
- package/build/model/limit.d.ts +7 -0
- package/build/model/limit.d.ts.map +1 -0
- package/build/model/limit.js +32 -0
- package/build/model/limit.js.map +1 -0
- package/build/model/plan.d.ts.map +1 -1
- package/build/model/plan.js +24 -11
- package/build/model/plan.js.map +1 -1
- package/build/model/portal.d.ts +4 -0
- package/build/model/portal.d.ts.map +1 -0
- package/build/model/portal.js +22 -0
- package/build/model/portal.js.map +1 -0
- package/build/model/pricing.d.ts +4 -0
- package/build/model/pricing.d.ts.map +1 -0
- package/build/model/pricing.js +31 -0
- package/build/model/pricing.js.map +1 -0
- package/build/model/view.d.ts +3 -0
- package/build/model/view.d.ts.map +1 -0
- package/build/model/view.js +15 -0
- package/build/model/view.js.map +1 -0
- package/build/pricing/types.d.ts +13 -0
- package/build/pricing/types.d.ts.map +1 -0
- package/build/pricing/types.js +2 -0
- package/build/pricing/types.js.map +1 -0
- package/build/pricing.d.ts +13 -0
- package/build/pricing.d.ts.map +1 -0
- package/build/pricing.js +74 -0
- package/build/pricing.js.map +1 -0
- package/build/promo/types.d.ts +14 -0
- package/build/promo/types.d.ts.map +1 -0
- package/build/promo/types.js +2 -0
- package/build/promo/types.js.map +1 -0
- package/build/promo.d.ts +7 -0
- package/build/promo.d.ts.map +1 -0
- package/build/promo.js +25 -0
- package/build/promo.js.map +1 -0
- package/build/regions/types.d.ts +32 -0
- package/build/regions/types.d.ts.map +1 -0
- package/build/regions/types.js +2 -0
- package/build/regions/types.js.map +1 -0
- package/build/regions.d.ts +15 -0
- package/build/regions.d.ts.map +1 -0
- package/build/regions.js +43 -0
- package/build/regions.js.map +1 -0
- package/build/service.d.ts.map +1 -1
- package/build/service.js +24 -9
- package/build/service.js.map +1 -1
- package/build/types.d.ts +619 -52
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +4 -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/view/types.d.ts +33 -0
- package/build/view/types.d.ts.map +1 -0
- package/build/view/types.js +2 -0
- package/build/view/types.js.map +1 -0
- package/build/view.d.ts +13 -0
- package/build/view.d.ts.map +1 -0
- package/build/view.js +78 -0
- package/build/view.js.map +1 -0
- package/package.json +14 -12
- package/src/advertise.ts +13 -0
- package/src/checkout/consts.ts +1 -0
- package/src/checkout/index.ts +5 -0
- package/src/checkout/narrow/types.ts +27 -0
- package/src/checkout/narrow.ts +63 -0
- package/src/checkout/protocols.ts +39 -0
- package/src/checkout/types.ts +27 -0
- package/src/consts.local.ts +34 -0
- package/src/consts.ts +417 -24
- package/src/consumer/cancel.ts +40 -0
- package/src/consumer/consts.local.ts +16 -0
- package/src/consumer/consts.ts +46 -0
- package/src/consumer/copy/types.ts +54 -0
- package/src/consumer/copy.ts +121 -0
- package/src/consumer/deadline/types.ts +30 -0
- package/src/consumer/deadline.ts +61 -0
- package/src/consumer/fifo/types.ts +17 -0
- package/src/consumer/fifo.ts +42 -0
- package/src/consumer/index.ts +17 -0
- package/src/consumer/policy/types.ts +20 -0
- package/src/consumer/policy.ts +101 -0
- package/src/consumer/protocols.ts +116 -0
- package/src/consumer/refund/types.ts +27 -0
- package/src/consumer/refund.ts +136 -0
- package/src/consumer/refusal.ts +35 -0
- package/src/consumer/revive/types.ts +23 -0
- package/src/consumer/revive.ts +82 -0
- package/src/consumer/types.local.ts +10 -0
- package/src/consumer/types.ts +189 -0
- package/src/countries.ts +5 -0
- package/src/entitled.ts +20 -0
- package/src/entitlement/types.ts +29 -0
- package/src/entitlement.ts +67 -103
- package/src/errors.ts +445 -0
- package/src/estimate/types.ts +34 -0
- package/src/estimate.ts +90 -0
- package/src/i18n/consumer-rights/be.json +131 -0
- package/src/i18n/consumer-rights/de.json +131 -0
- package/src/i18n/consumer-rights/en.json +131 -0
- package/src/i18n/consumer-rights/es.json +131 -0
- package/src/i18n/consumer-rights/fr.json +131 -0
- package/src/i18n/consumer-rights/pl.json +131 -0
- package/src/i18n/consumer-rights/ru.json +131 -0
- package/src/i18n/consumer-rights/uk.json +131 -0
- package/src/i18n/errors/be.json +30 -0
- package/src/i18n/errors/de.json +30 -0
- package/src/i18n/errors/en.json +30 -0
- package/src/i18n/errors/es.json +30 -0
- package/src/i18n/errors/fr.json +30 -0
- package/src/i18n/errors/pl.json +30 -0
- package/src/i18n/errors/ru.json +30 -0
- package/src/i18n/errors/uk.json +30 -0
- package/src/i18n/fr.json +39 -0
- package/src/i18n.ts +58 -8
- package/src/index.ts +18 -2
- package/src/limit/types.ts +41 -0
- package/src/limit.ts +132 -0
- package/src/model/checkout.ts +12 -7
- package/src/model/consts.local.ts +83 -0
- package/src/model/consts.ts +206 -0
- package/src/model/consumer.ts +294 -0
- package/src/model/estimate.ts +73 -0
- package/src/model/index.ts +7 -2
- package/src/model/limit.ts +36 -0
- package/src/model/plan.ts +25 -12
- package/src/model/portal.ts +25 -0
- package/src/model/pricing.ts +34 -0
- package/src/model/view.ts +17 -0
- package/src/pricing/types.ts +13 -0
- package/src/pricing.ts +110 -0
- package/src/promo/types.ts +18 -0
- package/src/promo.ts +46 -0
- package/src/regions/types.ts +42 -0
- package/src/regions.ts +85 -0
- package/src/service.ts +32 -15
- package/src/types.local.ts +5 -0
- package/src/types.ts +669 -49
- package/src/view/types.ts +39 -0
- package/src/view.ts +119 -0
- package/tests/checkout-narrow.spec.ts +75 -0
- package/tests/consumer-copy.spec.ts +378 -0
- package/tests/consumer-deadline.spec.ts +85 -0
- package/tests/consumer-fifo.spec.ts +61 -0
- package/tests/consumer-protocols.spec.ts +103 -0
- package/tests/consumer-refund.spec.ts +134 -0
- package/tests/consumer-regions.spec.ts +140 -0
- package/tests/consumer-wire.spec.ts +170 -0
- package/tests/contract.spec.ts +183 -0
- package/tests/entitlement.spec.ts +38 -25
- package/tests/errors.spec.ts +168 -0
- package/tests/estimate.spec.ts +139 -0
- package/tests/limit.spec.ts +117 -0
- package/tests/pricing.spec.ts +30 -0
- package/tests/view.spec.ts +130 -0
- package/build/.gitkeep +0 -0
- package/src/model/subscription.ts +0 -63
- package/src/model/utils.ts +0 -32
- package/src/modules.ts +0 -43
- package/tests/entitlement.spec.d.ts +0 -2
- package/tests/entitlement.spec.d.ts.map +0 -1
- package/tests/entitlement.spec.js +0 -72
- package/tests/entitlement.spec.js.map +0 -1
package/src/types.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { InitializedService } from '@owlmeans/context'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
CancellationKind, CancellationStatus, CheckoutPricingMode, ConsumerRegion, LimitKind, LimitWindow,
|
|
5
|
+
PaymentEntityType, PlanDuration, PlanStatus, PortalFlow, ProductType, PurchaseKind, SubscriptionStatus,
|
|
6
|
+
TaxBehavior, TaxEstimateStatus, TaxType, WithdrawalStatus,
|
|
7
|
+
} from './consts.js'
|
|
4
8
|
import type { PermissionSet } from '@owlmeans/auth'
|
|
5
9
|
|
|
6
10
|
export interface Product {
|
|
@@ -28,13 +32,46 @@ export interface Localization {
|
|
|
28
32
|
keywords?: { [key: string]: string }
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
/**
|
|
36
|
+
* A time-boxed grant on a capability set or a limit.
|
|
37
|
+
*
|
|
38
|
+
* In force while `now < until`; with `grandfather`, also for a subscription created before `until`.
|
|
39
|
+
*/
|
|
40
|
+
export interface PromoDeclaration {
|
|
41
|
+
until: Date
|
|
42
|
+
grandfather?: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A capability set a plan grants, optionally only while a promo is in force. */
|
|
46
|
+
export interface PlanCapability extends PermissionSet {
|
|
47
|
+
promo?: PromoDeclaration
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A counted allowance a plan grants under one key. */
|
|
51
|
+
export interface LimitDeclaration {
|
|
52
|
+
kind: LimitKind
|
|
53
|
+
/** The ceiling. `0` means "not included". */
|
|
54
|
+
limit: number
|
|
55
|
+
/** Required for `LimitKind.Window`; ignored otherwise. */
|
|
56
|
+
window?: LimitWindow
|
|
57
|
+
/** A display unit, never interpreted. */
|
|
58
|
+
unit?: string
|
|
59
|
+
promo?: PromoDeclaration
|
|
60
|
+
}
|
|
61
|
+
|
|
31
62
|
export interface ProductPlan {
|
|
32
63
|
productSku: string
|
|
33
64
|
sku: string
|
|
34
65
|
status: PlanStatus
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Position among the plans of one product: a higher rank is an upgrade. Treated as `0` when
|
|
68
|
+
* absent.
|
|
69
|
+
*/
|
|
70
|
+
rank?: number
|
|
71
|
+
/** A plan every entity holds without paying: `price: 0`, no paygate. */
|
|
72
|
+
free?: boolean
|
|
73
|
+
/** The paygates this plan is sold through. Empty for a free plan. */
|
|
74
|
+
gateways?: string[]
|
|
38
75
|
duration: PlanDuration
|
|
39
76
|
trial?: number
|
|
40
77
|
gatedTrial?: boolean
|
|
@@ -55,75 +92,259 @@ export interface ProductPlan {
|
|
|
55
92
|
* This way we can plan event when users loose access in case they don't upgrade.
|
|
56
93
|
*/
|
|
57
94
|
deprecatedAt?: Date
|
|
58
|
-
supsendedAt?: Date
|
|
59
|
-
capabilities?: PermissionSet[]
|
|
60
|
-
limits?: { [key: string]: LimitConfig }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface PlanSubscription {
|
|
64
|
-
sku: string
|
|
65
|
-
entityId: string
|
|
66
|
-
paymentMethod?: string
|
|
67
|
-
externalId?: string
|
|
68
|
-
createdAt: Date
|
|
69
|
-
lastPaymentAt?: Date
|
|
70
|
-
trialUntil?: Date
|
|
71
|
-
startsdAt: Date
|
|
72
|
-
expirationAt?: Date
|
|
73
|
-
endsAt?: Date
|
|
74
|
-
archiveAt?: Date
|
|
75
95
|
suspendedAt?: Date
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* Custom capabilities for the particular subscription.
|
|
82
|
-
*/
|
|
83
|
-
capabilities?: PermissionSet[]
|
|
96
|
+
capabilities?: PlanCapability[]
|
|
97
|
+
limits?: { [key: string]: LimitDeclaration }
|
|
98
|
+
pricingMode?: CheckoutPricingMode
|
|
99
|
+
amountPolicy?: AmountCheckoutPolicy
|
|
100
|
+
quantityPolicy?: QuantityCheckoutPolicy
|
|
84
101
|
/**
|
|
85
|
-
*
|
|
102
|
+
* How the price of a subscription splits for a withdrawal (CJEU C-641/19 PE Digital: pro rata
|
|
103
|
+
* temporis unless the contract states a separately priced component). Absent: the whole price is
|
|
104
|
+
* one `time` component.
|
|
86
105
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
withdrawal?: { components: PlanWithdrawalComponent[] }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* One separately priced part of a plan. A `time` part is deducted pro rata by the days elapsed
|
|
111
|
+
* since the services were requested; a `units` part by the units used after consent. The shares
|
|
112
|
+
* of a plan sum to its price in minor units.
|
|
113
|
+
*/
|
|
114
|
+
export interface PlanWithdrawalComponent {
|
|
115
|
+
key: string
|
|
116
|
+
basis: WithdrawalBasis
|
|
117
|
+
shareMinor: number
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type WithdrawalBasis = 'time' | 'units'
|
|
121
|
+
|
|
122
|
+
export interface AmountCheckoutPolicy {
|
|
123
|
+
currency: string
|
|
124
|
+
minimumMinor: number
|
|
125
|
+
maximumMinor: number
|
|
126
|
+
defaultMinor: number
|
|
127
|
+
presetsMinor: number[]
|
|
128
|
+
fixedMinor: number
|
|
129
|
+
rateBps: number
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface QuantityCheckoutPolicy {
|
|
133
|
+
minimum: number
|
|
134
|
+
maximum: number
|
|
135
|
+
default: number
|
|
89
136
|
}
|
|
90
137
|
|
|
91
138
|
export interface CreateCheckoutBody {
|
|
92
139
|
productSku: string
|
|
93
|
-
|
|
94
|
-
|
|
140
|
+
/** The plan to subscribe to, for a subscription checkout. */
|
|
141
|
+
planSku?: string
|
|
142
|
+
/** Renameable organization value carried across a protocol boundary. */
|
|
143
|
+
entitySlug: string
|
|
95
144
|
service: string
|
|
145
|
+
/** Net credit value for amount-priced checkouts, in integer currency minor units. */
|
|
146
|
+
amountMinor?: number
|
|
96
147
|
subscriptionId?: string
|
|
97
148
|
successUrl?: string
|
|
98
149
|
cancelUrl?: string
|
|
150
|
+
/** The billing country the buyer declared (ISO 3166-1 alpha-2). A locked profile overrides it. */
|
|
151
|
+
country?: string
|
|
152
|
+
/** The subscription start request recorded right before this checkout. */
|
|
153
|
+
startRequestId?: string
|
|
99
154
|
}
|
|
100
155
|
|
|
101
156
|
export interface CreateCheckoutResponse {
|
|
102
157
|
url: string
|
|
103
158
|
}
|
|
104
159
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
/**
|
|
161
|
+
* What an entity may do and how much of each limit is left, at one instant.
|
|
162
|
+
*
|
|
163
|
+
* The one read both the server gate and the browser consume. Built by `entitlementViewOf`.
|
|
164
|
+
*/
|
|
165
|
+
export interface EntitlementView {
|
|
166
|
+
plan: EntitlementPlanView
|
|
167
|
+
capabilities: CapabilityView[]
|
|
168
|
+
limits: LimitView[]
|
|
169
|
+
at: Date
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The effective plan and the subscription behind it. */
|
|
173
|
+
export interface EntitlementPlanView {
|
|
174
|
+
sku: string
|
|
175
|
+
productSku: string
|
|
176
|
+
title: string
|
|
177
|
+
rank: number
|
|
178
|
+
free: boolean
|
|
179
|
+
status: SubscriptionStatus
|
|
180
|
+
paygate: string
|
|
181
|
+
subscriptionId?: string
|
|
182
|
+
/** When the subscription was created — what a grandfathered promo is measured against. */
|
|
183
|
+
subscribedAt?: Date
|
|
184
|
+
periodStart?: Date
|
|
185
|
+
periodEnd?: Date
|
|
186
|
+
cancelAtPeriodEnd?: boolean
|
|
187
|
+
trialEnd?: Date
|
|
188
|
+
pausedAt?: Date
|
|
189
|
+
pastDue?: boolean
|
|
190
|
+
/** The plan the entity falls back to when this one ends. */
|
|
191
|
+
fallbackSku?: string
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface CapabilityView {
|
|
195
|
+
/** `[scope:]permission`, exactly as the capability gate takes it. */
|
|
196
|
+
param: string
|
|
197
|
+
scope: string
|
|
198
|
+
permission: string
|
|
199
|
+
value: boolean | number
|
|
200
|
+
/** False when the set's promo is no longer in force. */
|
|
201
|
+
granted: boolean
|
|
202
|
+
promo?: PromoView
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface LimitView {
|
|
206
|
+
key: string
|
|
207
|
+
/** `limit:<key>`, exactly as the limit gate takes it. */
|
|
208
|
+
param: string
|
|
209
|
+
kind: LimitKind
|
|
210
|
+
window?: LimitWindow
|
|
211
|
+
/** The ceiling in force now: `0` when a promo has lapsed. */
|
|
212
|
+
limit: number
|
|
213
|
+
used: number
|
|
214
|
+
/** `max(0, limit - used)`. */
|
|
215
|
+
remaining: number
|
|
216
|
+
windowStart?: Date
|
|
217
|
+
/** Exclusive: the first instant of the next window. */
|
|
218
|
+
resetsAt?: Date
|
|
219
|
+
unit?: string
|
|
220
|
+
promo?: PromoView
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface PromoView {
|
|
224
|
+
until: Date
|
|
225
|
+
/** The subscription predates `until` and the promo grandfathers it. */
|
|
226
|
+
grandfathered: boolean
|
|
227
|
+
active: boolean
|
|
108
228
|
}
|
|
109
229
|
|
|
110
230
|
/**
|
|
111
|
-
*
|
|
231
|
+
* Declared once per configuration (a `PRICING_POLICY_RECORD_ID` singleton record). Absent entirely,
|
|
232
|
+
* `DEFAULT_PRICING_POLICY` applies: automatic tax and tax-id collection stay on for every checkout
|
|
233
|
+
* exactly as before this policy existed, no `behavior` is forced onto a synced price, no Adaptive
|
|
234
|
+
* Pricing, and the estimate endpoints stay off.
|
|
112
235
|
*/
|
|
113
|
-
export
|
|
236
|
+
export interface PricingPolicy {
|
|
237
|
+
tax: {
|
|
238
|
+
/** Stripe Tax on every checkout session (`automatic_tax`, required billing address). */
|
|
239
|
+
automatic: boolean
|
|
240
|
+
/**
|
|
241
|
+
* The behavior synced prices are given. Absent: a price's `tax_behavior` is left untouched
|
|
242
|
+
* (`unspecified`, following the Stripe account default) — never inferred, always declared.
|
|
243
|
+
*/
|
|
244
|
+
behavior?: TaxBehavior
|
|
245
|
+
/** VAT/GST id collection at checkout, for reverse charge. */
|
|
246
|
+
collectTaxId: boolean
|
|
247
|
+
/** Serve `PaymentService`'s tax estimate endpoint. Requires `automatic`. */
|
|
248
|
+
estimate: boolean
|
|
249
|
+
/** How long a tax estimate may be served from cache. Absent: the gateway's own default. */
|
|
250
|
+
estimateTtlSeconds?: number
|
|
251
|
+
}
|
|
252
|
+
currency: {
|
|
253
|
+
/** Stripe Adaptive Pricing (`adaptive_pricing.enabled`) on every checkout session. */
|
|
254
|
+
adaptive?: boolean
|
|
255
|
+
/**
|
|
256
|
+
* The conversion fee Adaptive Pricing adds to Stripe's base rate, as a fraction (`0.04` = 4%; Stripe
|
|
257
|
+
* documents 2–4% and decides it per currency) — a buyer pays `base-rate conversion × (1 + fee)`.
|
|
258
|
+
* The local-currency line of an estimate applies it, so a quoted total is the one Checkout shows.
|
|
259
|
+
* Absent: the FX Quotes API's own fee-inclusive rate (its `fx_fee_rate`, 2%), which is what a
|
|
260
|
+
* conversion through Stripe's FX costs, not what Adaptive Pricing charges. Requires `adaptive`.
|
|
261
|
+
*/
|
|
262
|
+
adaptiveFeeRate?: number
|
|
263
|
+
/** Serve the "≈ local total" line of an estimate. Requires `currency.adaptive`. */
|
|
264
|
+
estimate: boolean
|
|
265
|
+
/** How long an FX quote may be served from cache. Absent: the gateway's own default. */
|
|
266
|
+
estimateTtlSeconds?: number
|
|
267
|
+
}
|
|
268
|
+
}
|
|
114
269
|
|
|
115
|
-
export interface
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
270
|
+
export interface PriceEstimateBody {
|
|
271
|
+
/** Absent: the product's own reference plan (e.g. an amount-priced consumable). */
|
|
272
|
+
planSku?: string
|
|
273
|
+
/** ISO 3166-1 alpha-2. Absent: taken from the entity's paygate customer, else `location-required`. */
|
|
274
|
+
country?: string
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface TaxRateEstimate {
|
|
278
|
+
type: TaxType
|
|
279
|
+
/** The rate as Stripe states it, e.g. `"23"` or `"8.5"` — display only. */
|
|
280
|
+
percentage: string
|
|
281
|
+
/** The same rate as parts per million, exact: `23%` is `230000`. Never a float. */
|
|
282
|
+
ratePpm: number
|
|
283
|
+
country?: string
|
|
284
|
+
state?: string
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface TaxEstimate {
|
|
288
|
+
status: TaxEstimateStatus
|
|
289
|
+
subtotalMinor: number
|
|
290
|
+
taxMinor: number
|
|
291
|
+
totalMinor: number
|
|
292
|
+
/**
|
|
293
|
+
* Whether `rates` scales linearly to any other amount (a flat fee, a reduced-rate portion, or
|
|
294
|
+
* several inclusive rates do not). `false` means only the reference amount's own totals are
|
|
295
|
+
* trustworthy — a different amount shows "tax at checkout" instead of being rescaled.
|
|
296
|
+
*/
|
|
297
|
+
scalable: boolean
|
|
298
|
+
rates: TaxRateEstimate[]
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface PriceEstimate {
|
|
302
|
+
/** The billing country the estimate was computed for, when one was resolved. */
|
|
303
|
+
country?: string
|
|
304
|
+
/**
|
|
305
|
+
* Where that country came from — absent when neither the request nor the customer named one;
|
|
306
|
+
* `profile` when the entity's billing country is locked, which overrides the request.
|
|
307
|
+
*/
|
|
308
|
+
source?: 'request' | 'customer' | 'profile'
|
|
309
|
+
/** The country is the locked billing country; a picker shows it and does not change it. */
|
|
310
|
+
locked?: boolean
|
|
311
|
+
/** The consumer region of `country`. */
|
|
312
|
+
region?: ConsumerRegion
|
|
313
|
+
/** The integration currency (lowercase ISO 4217) the amounts above and `tax` are stated in. */
|
|
314
|
+
currency: string
|
|
315
|
+
behavior: TaxBehavior
|
|
316
|
+
tax: TaxEstimate
|
|
317
|
+
/** The approximate total in the country's own currency, when it differs and a rate was found. */
|
|
318
|
+
local?: {
|
|
319
|
+
currency: string
|
|
320
|
+
/**
|
|
321
|
+
* Integration-currency (`currency` above) units per one unit of `local.currency`, fee-inclusive
|
|
322
|
+
* (Stripe FX Quotes, requested `to_currency: currency, from_currencies: [local.currency]`): the
|
|
323
|
+
* quote's `base_rate / (1 + currency.adaptiveFeeRate)` when the policy declares the Adaptive Pricing
|
|
324
|
+
* fee, else the quote's own `exchange_rate`. A local amount is `amountInCurrency / exchangeRate`.
|
|
325
|
+
*/
|
|
326
|
+
exchangeRate: number
|
|
327
|
+
/** The conversion fee `exchangeRate` includes: `currency.adaptiveFeeRate`, else the quote's `fx_fee_rate`. */
|
|
328
|
+
fxFeeRate?: number
|
|
329
|
+
}
|
|
119
330
|
}
|
|
120
331
|
|
|
121
|
-
export interface
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
332
|
+
export interface PortalLinkBody {
|
|
333
|
+
flow: PortalFlow
|
|
334
|
+
/** The target plan of a `PortalFlow.Change`. */
|
|
335
|
+
planSku?: string
|
|
336
|
+
returnUrl?: string
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface PortalLinkResponse {
|
|
340
|
+
url: string
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** One counter reading: how much of `key` is used in `window` (a `windowKeyOf` value). */
|
|
344
|
+
export interface LimitUsage {
|
|
345
|
+
key: string
|
|
346
|
+
window: string
|
|
347
|
+
used: number
|
|
127
348
|
}
|
|
128
349
|
|
|
129
350
|
type PaymentEntity = Product | ProductPlan | PermissionSet
|
|
@@ -142,4 +363,403 @@ export interface PaymentService extends InitializedService {
|
|
|
142
363
|
localize: (lng: string, entity: PaymentEntity) => Promise<Localization | null>
|
|
143
364
|
|
|
144
365
|
shallowAuthentication: (token: string | null) => Promise<string>
|
|
366
|
+
|
|
367
|
+
/** The declared `PricingPolicy`, or `DEFAULT_PRICING_POLICY` when none was declared. */
|
|
368
|
+
pricingPolicy: () => Promise<PricingPolicy>
|
|
369
|
+
|
|
370
|
+
/** The declared `ConsumerRightsPolicy`, or `null` when the application declared none. */
|
|
371
|
+
consumerRightsPolicy: () => Promise<ConsumerRightsPolicy | null>
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// --- Consumer rights --------------------------------------------------------------------------
|
|
375
|
+
|
|
376
|
+
/** The legal documents and functions of one language. Every value is an absolute https URL. */
|
|
377
|
+
export interface ConsumerRightsLinks {
|
|
378
|
+
billingTerms: string
|
|
379
|
+
withdrawalInformation?: string
|
|
380
|
+
withdrawalForm?: string
|
|
381
|
+
/** The public withdrawal function — the address the Billing Terms name. */
|
|
382
|
+
withdrawalFunction?: string
|
|
383
|
+
/** The public cancellation page. */
|
|
384
|
+
cancellation?: string
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Which consumer-rights mechanisms an application runs. Each is a separate switch. */
|
|
388
|
+
export interface ConsumerRightsMechanisms {
|
|
389
|
+
/** Fix the billing country at the first purchase. */
|
|
390
|
+
countryLock: boolean
|
|
391
|
+
/** The terms checkbox and text on every checkout (needs a terms URL at the paygate). */
|
|
392
|
+
checkoutTerms: boolean
|
|
393
|
+
/** Ask for express consent before credits bought inside their window are spent. */
|
|
394
|
+
performanceConsent: boolean
|
|
395
|
+
/** Ask for an express start request before a subscription checkout. */
|
|
396
|
+
subscriptionStart: boolean
|
|
397
|
+
/** The withdrawal function. */
|
|
398
|
+
withdrawal: boolean
|
|
399
|
+
/** Execute a withdrawal's refund at the paygate without an operator. */
|
|
400
|
+
automaticRefunds: boolean
|
|
401
|
+
/** The cancellation function. */
|
|
402
|
+
cancellation: boolean
|
|
403
|
+
/** The purchase confirmation e-mail with the withdrawal information. */
|
|
404
|
+
purchaseConfirmation: boolean
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Declared once per configuration (a `CONSUMER_RIGHTS_RECORD_ID` singleton record). Carries no
|
|
409
|
+
* secret — it is advertised to the browser, which renders the same links and switches the server
|
|
410
|
+
* enforces.
|
|
411
|
+
*/
|
|
412
|
+
export interface ConsumerRightsPolicy {
|
|
413
|
+
/** The version of the application's Billing Terms and consent wording; a consent records it. */
|
|
414
|
+
textVersion: string
|
|
415
|
+
/** ISO 3166-1 alpha-2 countries whose consumers have the rights. */
|
|
416
|
+
countries: string[]
|
|
417
|
+
/** An unknown billing country is protected (treated as in scope) or ignored. */
|
|
418
|
+
unknownCountry: 'protect' | 'ignore'
|
|
419
|
+
withdrawalDays: number
|
|
420
|
+
deadline: { weekendRollover: boolean, marginDays: number }
|
|
421
|
+
mechanisms: ConsumerRightsMechanisms
|
|
422
|
+
/** The charge currency per region (lowercase ISO 4217), e.g. `{ eu: 'eur', other: 'usd' }`. */
|
|
423
|
+
currencies?: Partial<Record<ConsumerRegion, string>>
|
|
424
|
+
/** Country → language of the legal copy, over `COUNTRY_LANGUAGES`. */
|
|
425
|
+
languages?: Record<string, string>
|
|
426
|
+
defaultLanguage: string
|
|
427
|
+
/** Per language; `defaultLanguage` must be present. */
|
|
428
|
+
links: Record<string, ConsumerRightsLinks>
|
|
429
|
+
/** Whether a renewal opens a new withdrawal window. Off by default. */
|
|
430
|
+
renewalOpensWindow?: boolean
|
|
431
|
+
/** How long a subscription start request stays usable. */
|
|
432
|
+
startRequestTtlSeconds?: number
|
|
433
|
+
/** Whether a buyer with a business tax id is exempt. Off by default: everyone is protected. */
|
|
434
|
+
exemptBusinesses?: boolean
|
|
435
|
+
/**
|
|
436
|
+
* The copy variant of the performance consent (`^[a-z][a-z0-9-]*$`): its texts are read as
|
|
437
|
+
* `<key>_<consentContext>` first, the base key where no variant exists. Absent: the base texts.
|
|
438
|
+
*/
|
|
439
|
+
consentContext?: string
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** An entity's billing country, fixed at the first purchase. */
|
|
443
|
+
export interface BillingProfileView {
|
|
444
|
+
country: string | null
|
|
445
|
+
region: ConsumerRegion | null
|
|
446
|
+
/** The charge currency, fixed with the country. */
|
|
447
|
+
currency: string | null
|
|
448
|
+
locked: boolean
|
|
449
|
+
lockedAt?: Date
|
|
450
|
+
/** The language of the legal copy for this country. */
|
|
451
|
+
language: string
|
|
452
|
+
inScope: boolean
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** One purchase — a contract — and its withdrawal window. */
|
|
456
|
+
export interface PurchaseView {
|
|
457
|
+
purchaseId: string
|
|
458
|
+
/** The human contract reference a consumer quotes. */
|
|
459
|
+
contractRef: string
|
|
460
|
+
kind: PurchaseKind
|
|
461
|
+
purchasedAt: Date
|
|
462
|
+
/** Exclusive end of the withdrawal window; absent outside the consumer-rights territories. */
|
|
463
|
+
deadline?: Date
|
|
464
|
+
productSku: string
|
|
465
|
+
planSku?: string
|
|
466
|
+
amountTotalMinor: number
|
|
467
|
+
currency: string
|
|
468
|
+
consentedAt?: Date
|
|
469
|
+
withdrawnAt?: Date
|
|
470
|
+
/** Inside its window, not withdrawn, and something would be reimbursed. */
|
|
471
|
+
withdrawable: boolean
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface PurchaseList {
|
|
475
|
+
purchases: PurchaseView[]
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Whether billed work needs the consumer's express consent now, and what it would cover. */
|
|
479
|
+
export interface PerformanceConsentView {
|
|
480
|
+
required: boolean
|
|
481
|
+
region: ConsumerRegion | null
|
|
482
|
+
country: string | null
|
|
483
|
+
/** The language of the legal copy (the billing country's). */
|
|
484
|
+
language: string
|
|
485
|
+
/** The trader named in the statement. */
|
|
486
|
+
trader: string
|
|
487
|
+
/** The policy's `consentContext`: the copy variant the statement is rendered with. */
|
|
488
|
+
context?: string
|
|
489
|
+
textVersion: string
|
|
490
|
+
copyVersion: string
|
|
491
|
+
links: ConsumerRightsLinks
|
|
492
|
+
/** The open, unconsented purchases the consent would cover. */
|
|
493
|
+
purchases: PurchaseView[]
|
|
494
|
+
/** The latest deadline among them. */
|
|
495
|
+
deadline?: Date
|
|
496
|
+
at: Date
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export interface PerformanceConsentBody {
|
|
500
|
+
purchaseIds: string[]
|
|
501
|
+
textVersion: string
|
|
502
|
+
/** The language the statement was SHOWN in. */
|
|
503
|
+
language: string
|
|
504
|
+
acknowledged: true
|
|
505
|
+
uiLanguage?: string
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export interface PerformanceConsentResponse {
|
|
509
|
+
consentId: string
|
|
510
|
+
consentedAt: Date
|
|
511
|
+
purchaseIds: string[]
|
|
512
|
+
mailed: boolean
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export interface SubscriptionStartQuery {
|
|
516
|
+
planSku: string
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** Whether a subscription checkout needs an express start request first. */
|
|
520
|
+
export interface SubscriptionStartView {
|
|
521
|
+
required: boolean
|
|
522
|
+
planSku: string
|
|
523
|
+
language: string
|
|
524
|
+
trader: string
|
|
525
|
+
/**
|
|
526
|
+
* The copy variant the statement is rendered with — `startContextOf(plan)`: `'units'` for a plan
|
|
527
|
+
* with a `units` withdrawal component, absent for one withdrawn pro rata by time only.
|
|
528
|
+
*/
|
|
529
|
+
context?: string
|
|
530
|
+
textVersion: string
|
|
531
|
+
copyVersion: string
|
|
532
|
+
links: ConsumerRightsLinks
|
|
533
|
+
region: ConsumerRegion | null
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export interface SubscriptionStartBody {
|
|
537
|
+
planSku: string
|
|
538
|
+
textVersion: string
|
|
539
|
+
language: string
|
|
540
|
+
acknowledged: true
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface SubscriptionStartResponse {
|
|
544
|
+
startRequestId: string
|
|
545
|
+
requestedAt: Date
|
|
546
|
+
expiresAt: Date
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** What a withdrawal would reimburse now. */
|
|
550
|
+
export interface WithdrawalEstimate {
|
|
551
|
+
refundMinor: number
|
|
552
|
+
currency: string
|
|
553
|
+
timeDeductionMinor: number
|
|
554
|
+
unitsDeductionMinor: number
|
|
555
|
+
elapsedDays?: number
|
|
556
|
+
periodDays?: number
|
|
557
|
+
unitsUsed?: number
|
|
558
|
+
unitsGranted?: number
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export interface WithdrawalCandidate {
|
|
562
|
+
purchaseId: string
|
|
563
|
+
contractRef: string
|
|
564
|
+
kind: PurchaseKind
|
|
565
|
+
purchasedAt: Date
|
|
566
|
+
deadline: Date
|
|
567
|
+
amountTotalMinor: number
|
|
568
|
+
currency: string
|
|
569
|
+
/** `null` when it cannot be computed (no usage meter). */
|
|
570
|
+
estimate: WithdrawalEstimate | null
|
|
571
|
+
/** The refund is executed without an operator. */
|
|
572
|
+
automatic: boolean
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export interface WithdrawalCandidateList {
|
|
576
|
+
candidates: WithdrawalCandidate[]
|
|
577
|
+
language: string
|
|
578
|
+
links: ConsumerRightsLinks
|
|
579
|
+
/** Prefill for the form. */
|
|
580
|
+
name?: string
|
|
581
|
+
email?: string
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* A withdrawal declaration. In-app it names `purchaseId`; on the public page `contractRef` (or an
|
|
586
|
+
* invoice number) plus the e-mail of the purchase. Only name, contract and e-mail are asked.
|
|
587
|
+
*/
|
|
588
|
+
export interface WithdrawalBody {
|
|
589
|
+
purchaseId?: string
|
|
590
|
+
contractRef?: string
|
|
591
|
+
name: string
|
|
592
|
+
email: string
|
|
593
|
+
language?: string
|
|
594
|
+
/** A field a person never fills — a filled one marks a bot on a public form. */
|
|
595
|
+
honeypot?: string
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** The receipt of a declaration: what was declared and when it arrived. */
|
|
599
|
+
export interface DeclarationReceipt {
|
|
600
|
+
declarationId: string
|
|
601
|
+
receivedAt: Date
|
|
602
|
+
/** The declaration as received, field by field — echoed, never enriched with a match. */
|
|
603
|
+
content: Record<string, string>
|
|
604
|
+
mailed: boolean
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export interface WithdrawalReceipt extends DeclarationReceipt {
|
|
608
|
+
status: WithdrawalStatus
|
|
609
|
+
refundMinor?: number
|
|
610
|
+
currency?: string
|
|
611
|
+
subscriptionCanceled?: boolean
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export interface CancellationBody {
|
|
615
|
+
kind: CancellationKind
|
|
616
|
+
/** Required for an extraordinary cancellation. */
|
|
617
|
+
reason?: string
|
|
618
|
+
name: string
|
|
619
|
+
contractRef?: string
|
|
620
|
+
subscriptionId?: string
|
|
621
|
+
effective: 'earliest' | 'date'
|
|
622
|
+
/** `YYYY-MM-DD`, with `effective: 'date'`. */
|
|
623
|
+
date?: string
|
|
624
|
+
email: string
|
|
625
|
+
language?: string
|
|
626
|
+
/** A field a person never fills — a filled one marks a bot on a public form. */
|
|
627
|
+
honeypot?: string
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export interface CancellationReceipt extends DeclarationReceipt {
|
|
631
|
+
status: CancellationStatus
|
|
632
|
+
effectiveAt?: Date
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** What the public legal pages need without a login. */
|
|
636
|
+
export interface ConsumerRightsPublicView {
|
|
637
|
+
mechanisms: Pick<ConsumerRightsMechanisms, 'withdrawal' | 'cancellation'>
|
|
638
|
+
languages: string[]
|
|
639
|
+
links: Record<string, ConsumerRightsLinks>
|
|
640
|
+
textVersion: string
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* One narrowing of an amount checkout's maximum — what a checkout plugin (a spending tier, a
|
|
645
|
+
* rolling cap) answers for one entity at one instant.
|
|
646
|
+
*/
|
|
647
|
+
export interface AmountNarrowing {
|
|
648
|
+
/** The largest amount (net credit value, minor units) this narrowing allows now. */
|
|
649
|
+
maximumMinor: number
|
|
650
|
+
/** Why — a stable key a UI phrases (`per-purchase`, `window`, `hold` …). */
|
|
651
|
+
reason: string
|
|
652
|
+
/** When the narrowing lifts or widens. */
|
|
653
|
+
resetsAt?: Date
|
|
654
|
+
/** What is left of a rolling allowance, when that is the cause. */
|
|
655
|
+
remainingMinor?: number
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* The narrowed limit of an amount checkout, shared by the server's refusal and the dialog's
|
|
660
|
+
* control. `blocked` means no amount may be bought now.
|
|
661
|
+
*/
|
|
662
|
+
export interface CheckoutLimitView {
|
|
663
|
+
productSku: string
|
|
664
|
+
planSku?: string
|
|
665
|
+
currency: string
|
|
666
|
+
minimumMinor: number
|
|
667
|
+
/** The narrowed maximum — below `minimumMinor` when `blocked`. */
|
|
668
|
+
maximumMinor: number
|
|
669
|
+
narrowed: boolean
|
|
670
|
+
blocked: boolean
|
|
671
|
+
reason?: string
|
|
672
|
+
resetsAt?: Date
|
|
673
|
+
remainingMinor?: number
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** An amount policy as narrowed for one entity, and the limit that narrowed it (`null`: none). */
|
|
677
|
+
export interface AmountPolicyView {
|
|
678
|
+
policy: AmountCheckoutPolicy
|
|
679
|
+
limit: CheckoutLimitView | null
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export interface AmountPolicyQuery {
|
|
683
|
+
productSku: string
|
|
684
|
+
planSku?: string
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** One price of a plan in one currency, as the paygate charges it. */
|
|
688
|
+
export interface PlanPriceView {
|
|
689
|
+
planSku: string
|
|
690
|
+
currency: string
|
|
691
|
+
unitAmountMinor: number
|
|
692
|
+
/** The price's default currency (the others are currency options). */
|
|
693
|
+
default: boolean
|
|
694
|
+
taxBehavior?: TaxBehavior
|
|
695
|
+
interval?: 'month' | 'year'
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export interface PlanPriceList {
|
|
699
|
+
prices: PlanPriceView[]
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export interface PlanPricesQuery {
|
|
703
|
+
productSku: string
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export interface EntitlementParam {
|
|
707
|
+
/** Capability scope. Absent means any scope. */
|
|
708
|
+
scope?: string
|
|
709
|
+
/** The permission key inside `PermissionSet.permissions`. */
|
|
710
|
+
permission: string
|
|
711
|
+
/** Numeric floor: `credits>=100` passes when the held value is a number at least that big. */
|
|
712
|
+
atLeast?: number
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export interface LimitExhaustedDetails {
|
|
716
|
+
key: string
|
|
717
|
+
used: number
|
|
718
|
+
limit: number
|
|
719
|
+
/** When the window renews. Absent for a limit that never renews. */
|
|
720
|
+
resetsAt?: Date
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
export interface PerformanceConsentRequiredDetails {
|
|
724
|
+
/** How many open purchases wait for consent. */
|
|
725
|
+
pending: number
|
|
726
|
+
/** The latest of their deadlines. */
|
|
727
|
+
deadline?: Date
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export interface BillingCountryLockedDetails {
|
|
731
|
+
/** The locked country. */
|
|
732
|
+
country: string
|
|
733
|
+
/** The country the request declared. */
|
|
734
|
+
requested?: string
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export interface CheckoutLimitExceededDetails {
|
|
738
|
+
/** The key of the narrowing that set the maximum. */
|
|
739
|
+
reason: string
|
|
740
|
+
/** The narrowed maximum, net minor units — below the policy minimum when nothing may be bought. */
|
|
741
|
+
maximumMinor: number
|
|
742
|
+
currency: string
|
|
743
|
+
resetsAt?: Date
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export interface AmountEstimate {
|
|
747
|
+
subtotalMinor: number
|
|
748
|
+
/** `null` when `estimate` cannot be rescaled to this amount (see `TaxEstimate.scalable`). */
|
|
749
|
+
taxMinor: number | null
|
|
750
|
+
totalMinor: number | null
|
|
751
|
+
/**
|
|
752
|
+
* The subtotal, tax and total in the country's own currency, in major units — present only
|
|
753
|
+
* alongside a non-`null` `totalMinor`. A UI showing `local` shows ONLY `local` for the tax and
|
|
754
|
+
* total (marked `≈`, since it is Stripe's own rate at read time, not the checkout rate); the
|
|
755
|
+
* integration-currency amounts stay the reference for bookkeeping, never a second figure to show
|
|
756
|
+
* alongside the converted one.
|
|
757
|
+
*/
|
|
758
|
+
local?: { currency: string; subtotalAmount: number; taxAmount: number; totalAmount: number }
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export interface LimitParam {
|
|
762
|
+
key: string
|
|
763
|
+
/** How much room the requirement needs. `1` when the parameter states no floor. */
|
|
764
|
+
atLeast: number
|
|
145
765
|
}
|