@fonderie/billing 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brain/signatures.md +43 -0
- package/dist/{index-CBhthuMn.d.ts → index-Byy5mBE4.d.ts} +4 -3
- package/dist/{index-CS1QagwE.d.cts → index-DjAGcrSi.d.cts} +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.d.cts +1 -1
- package/dist/middlewares/index.d.ts +1 -1
- package/dist/middlewares/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -16,6 +16,9 @@ new StripeProvider(secretKey: string, webhookSecret?: string | undefined): Strip
|
|
|
16
16
|
.name: "stripe"
|
|
17
17
|
.createCustomer(opts: { email: string; subscriberType: SubscriberType; subscriberId: string; userId: string; }): Promise<{ customerId: string; }>
|
|
18
18
|
.createCheckoutSession(opts: { customerId: string; priceId: string; subscriberType: SubscriberType; subscriberId: string; trialDays?: number; successUrl: string; cancelUrl: string; }): Promise<{ url: string; }>
|
|
19
|
+
.resolvePriceById(priceId: string): Promise<IResolvedPrice | null>
|
|
20
|
+
.resolvePricesByLookupKey(lookupKeys: string[]): Promise<Map<string, IResolvedPrice>>
|
|
21
|
+
.updateSubscription(opts: { subscriptionId: string; priceId: string; }): Promise<{ status: string; currentPeriodStart: Date | null; currentPeriodEnd: Date | null; }>
|
|
19
22
|
.createPortalSession(opts: { customerId: string; returnUrl: string; }): Promise<{ url: string; }>
|
|
20
23
|
.constructEvent(opts: { payload: string; signature: string; secret: string; }): Promise<IBillingEvent>
|
|
21
24
|
|
|
@@ -43,6 +46,7 @@ interface IBillingConfig {
|
|
|
43
46
|
backend?: RateLimitBackendConfig;
|
|
44
47
|
};
|
|
45
48
|
notifications?: IBillingNotificationsConfig;
|
|
49
|
+
pricing?: IBillingPricingConfig;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
interface IBillingPlan {
|
|
@@ -62,6 +66,19 @@ interface IBillingPlanDefaults {
|
|
|
62
66
|
buffer?: number;
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
interface IBillingPlanPrice {
|
|
70
|
+
lookupKey?: string;
|
|
71
|
+
priceId?: string;
|
|
72
|
+
amount?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface IBillingPricingConfig {
|
|
76
|
+
hydration?: boolean;
|
|
77
|
+
cacheTtlMs?: number;
|
|
78
|
+
transferGraceMs?: number;
|
|
79
|
+
maxStaleMs?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
65
82
|
type RateLimitBackendConfig = 'memory' | 'db' | ICounterBackend;
|
|
66
83
|
|
|
67
84
|
interface IBillingNotificationsConfig {
|
|
@@ -84,6 +101,10 @@ interface ICounterBackend {
|
|
|
84
101
|
get(key: string, windowMs: number | null): Promise<number>;
|
|
85
102
|
}
|
|
86
103
|
|
|
104
|
+
const BILLING_INTERVAL: { readonly MONTH: "month"; readonly YEAR: "year"; }
|
|
105
|
+
|
|
106
|
+
type BillingInterval = (typeof BILLING_INTERVAL)[keyof typeof BILLING_INTERVAL];
|
|
107
|
+
|
|
87
108
|
interface IBillingProvider {
|
|
88
109
|
name: string;
|
|
89
110
|
createCustomer(opts: {
|
|
@@ -105,6 +126,16 @@ interface IBillingProvider {
|
|
|
105
126
|
}): Promise<{
|
|
106
127
|
url: string;
|
|
107
128
|
}>;
|
|
129
|
+
resolvePriceById(priceId: string): Promise<IResolvedPrice | null>;
|
|
130
|
+
resolvePricesByLookupKey(lookupKeys: string[]): Promise<Map<string, IResolvedPrice>>;
|
|
131
|
+
updateSubscription(opts: {
|
|
132
|
+
subscriptionId: string;
|
|
133
|
+
priceId: string;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
status: string;
|
|
136
|
+
currentPeriodStart: Date | null;
|
|
137
|
+
currentPeriodEnd: Date | null;
|
|
138
|
+
}>;
|
|
108
139
|
createPortalSession(opts: {
|
|
109
140
|
customerId: string;
|
|
110
141
|
returnUrl: string;
|
|
@@ -123,6 +154,17 @@ interface IBillingEvent {
|
|
|
123
154
|
subscription: INormalizedSubscription | null;
|
|
124
155
|
}
|
|
125
156
|
|
|
157
|
+
interface IResolvedPrice {
|
|
158
|
+
priceId: string;
|
|
159
|
+
lookupKey: string | null;
|
|
160
|
+
unitAmount: number;
|
|
161
|
+
currency: string;
|
|
162
|
+
interval: 'month' | 'year';
|
|
163
|
+
nickname: string | null;
|
|
164
|
+
productId: string;
|
|
165
|
+
active: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
126
168
|
interface IPlan {
|
|
127
169
|
id: string;
|
|
128
170
|
name: string;
|
|
@@ -211,6 +253,7 @@ interface IPlanDTO {
|
|
|
211
253
|
yearly: number;
|
|
212
254
|
currency: string;
|
|
213
255
|
};
|
|
256
|
+
pricingStale?: boolean;
|
|
214
257
|
features: IPlanFeature[];
|
|
215
258
|
metadata: Record<string, unknown>;
|
|
216
259
|
}
|
|
@@ -88,8 +88,9 @@ interface IBillingPlanPrice {
|
|
|
88
88
|
/** Stripe price id. Used for hydration and as a lookup_key fallback. */
|
|
89
89
|
priceId?: string;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
91
|
+
* Display amount in cents — the seed value written to fonderie_plans and the
|
|
92
|
+
* fallback shown (flagged pricingStale) when hydration is off or Stripe is
|
|
93
|
+
* unreachable. When hydration resolves a live price, the live amount wins.
|
|
93
94
|
*/
|
|
94
95
|
amount?: number;
|
|
95
96
|
}
|
|
@@ -99,7 +100,7 @@ interface IBillingPlanPrice {
|
|
|
99
100
|
* See packages/billing/docs/pricing-hydration.md.
|
|
100
101
|
*/
|
|
101
102
|
interface IBillingPricingConfig {
|
|
102
|
-
/** Kill-switch. When false (default),
|
|
103
|
+
/** Kill-switch. When false (default), serve the configured amount/USD directly. */
|
|
103
104
|
hydration?: boolean;
|
|
104
105
|
/** Fresh-cache TTL. Default 300_000 (5m). */
|
|
105
106
|
cacheTtlMs?: number;
|
|
@@ -88,8 +88,9 @@ interface IBillingPlanPrice {
|
|
|
88
88
|
/** Stripe price id. Used for hydration and as a lookup_key fallback. */
|
|
89
89
|
priceId?: string;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
91
|
+
* Display amount in cents — the seed value written to fonderie_plans and the
|
|
92
|
+
* fallback shown (flagged pricingStale) when hydration is off or Stripe is
|
|
93
|
+
* unreachable. When hydration resolves a live price, the live amount wins.
|
|
93
94
|
*/
|
|
94
95
|
amount?: number;
|
|
95
96
|
}
|
|
@@ -99,7 +100,7 @@ interface IBillingPlanPrice {
|
|
|
99
100
|
* See packages/billing/docs/pricing-hydration.md.
|
|
100
101
|
*/
|
|
101
102
|
interface IBillingPricingConfig {
|
|
102
|
-
/** Kill-switch. When false (default),
|
|
103
|
+
/** Kill-switch. When false (default), serve the configured amount/USD directly. */
|
|
103
104
|
hydration?: boolean;
|
|
104
105
|
/** Fresh-cache TTL. Default 300_000 (5m). */
|
|
105
106
|
cacheTtlMs?: number;
|