@voltro/plugin-billing 0.85.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +666 -0
- package/README.md +7 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/catalog.js +471 -0
- package/dist/dunning.js +209 -0
- package/dist/entitlement.js +41 -0
- package/dist/flushClaim.js +20 -0
- package/dist/index.js +158 -2776
- package/dist/metering.js +74 -0
- package/dist/plans.js +24 -0
- package/dist/providers.js +133 -0
- package/dist/provision.js +153 -0
- package/dist/service.js +615 -0
- package/dist/stores.js +425 -0
- package/dist/stripeClient.js +53 -0
- package/dist/stripeProvider.js +352 -0
- package/dist/stripeRest.js +52 -0
- package/dist/table.js +54 -0
- package/dist/webhook.js +45 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -20,6 +20,13 @@ Installation, guides, the full API reference, and examples all live in the
|
|
|
20
20
|
**[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
|
|
21
21
|
deliberately short so there is nothing here to drift out of date.
|
|
22
22
|
|
|
23
|
+
|
|
24
|
+
`billing.subscription` and `billing.entitlementStatus` stream changes from the subscription table; `billing.invoices` follows invoice and customer-link changes. Cancelling, resuming, webhooks and reconciliation therefore update existing query subscriptions without client polling or reloading. Tenant and scope checks apply to each recomputation.
|
|
25
|
+
|
|
26
|
+
Checkout and portal URL routes recheck current authentication and their declared
|
|
27
|
+
manager guard after provider IO, before releasing the private URL. A refusal does
|
|
28
|
+
not undo or replay an already created external session.
|
|
29
|
+
|
|
23
30
|
## License
|
|
24
31
|
|
|
25
32
|
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Third-Party Notices — @voltro/plugin-billing
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package uses the open-source software listed below. Each is the
|
|
4
4
|
property of its respective copyright holders and is used under the terms of
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/plugin-billing itself, which is proprietary (see LICENSE).
|
|
7
7
|
|
|
8
|
-
Generated from the resolved runtime dependency closure (
|
|
8
|
+
Generated from the resolved runtime dependency closure (41 packages).
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -3636,34 +3636,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
3636
3636
|
SOFTWARE.
|
|
3637
3637
|
```
|
|
3638
3638
|
|
|
3639
|
-
## layerr@3.0.0
|
|
3640
|
-
|
|
3641
|
-
License: MIT
|
|
3642
|
-
|
|
3643
|
-
```
|
|
3644
|
-
MIT License
|
|
3645
|
-
|
|
3646
|
-
Copyright (c) 2020 Perry Mitchell
|
|
3647
|
-
|
|
3648
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
3649
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
3650
|
-
in the Software without restriction, including without limitation the rights
|
|
3651
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3652
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
3653
|
-
furnished to do so, subject to the following conditions:
|
|
3654
|
-
|
|
3655
|
-
The above copyright notice and this permission notice shall be included in all
|
|
3656
|
-
copies or substantial portions of the Software.
|
|
3657
|
-
|
|
3658
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
3659
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
3660
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
3661
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
3662
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
3663
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
3664
|
-
SOFTWARE.
|
|
3665
|
-
```
|
|
3666
|
-
|
|
3667
3639
|
## lib0@0.2.117
|
|
3668
3640
|
|
|
3669
3641
|
License: MIT
|
|
@@ -4013,14 +3985,14 @@ Apache License
|
|
|
4013
3985
|
limitations under the License.
|
|
4014
3986
|
```
|
|
4015
3987
|
|
|
4016
|
-
##
|
|
3988
|
+
## ulid@3.0.2
|
|
4017
3989
|
|
|
4018
3990
|
License: MIT
|
|
4019
3991
|
|
|
4020
3992
|
```
|
|
4021
|
-
MIT License
|
|
3993
|
+
The MIT License (MIT)
|
|
4022
3994
|
|
|
4023
|
-
Copyright (c)
|
|
3995
|
+
Copyright (c) 2017 Alizain Feerasta
|
|
4024
3996
|
|
|
4025
3997
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4026
3998
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { Stripe as e } from "./stripeClient.js";
|
|
2
|
+
import { STRIPE_WEBHOOK_EVENTS as t } from "./stripeProvider.js";
|
|
3
|
+
//#region src/catalog.ts
|
|
4
|
+
var n = e.API_VERSION, r = [
|
|
5
|
+
"Checkout → \"Limit customers to one subscription\" (with the customer portal login link enabled) — Stripe's own refusal of a second subscription",
|
|
6
|
+
"Smart Retries + failed-payment emails (Billing → Revenue recovery)",
|
|
7
|
+
"invoice branding and email settings",
|
|
8
|
+
"a restricted key (rk_) for the app, separate from the provisioning key"
|
|
9
|
+
], i = (e) => typeof e.tax_code == "string" ? e.tax_code : e.tax_code?.id ?? null, a = (e) => ({
|
|
10
|
+
name: e.name,
|
|
11
|
+
description: e.description,
|
|
12
|
+
unit_label: e.unitLabel,
|
|
13
|
+
tax_code: e.taxCode,
|
|
14
|
+
metadata: {
|
|
15
|
+
...e.metadata,
|
|
16
|
+
voltro_key: e.key
|
|
17
|
+
}
|
|
18
|
+
}), o = (e, t) => {
|
|
19
|
+
let n = [];
|
|
20
|
+
t.active || n.push("active"), t.name !== e.name && n.push("name"), (t.description ?? "") !== e.description && n.push("description"), (t.unit_label ?? "") !== e.unitLabel && n.push("unit_label"), i(t) !== e.taxCode && n.push("tax_code");
|
|
21
|
+
for (let [r, i] of Object.entries({
|
|
22
|
+
...e.metadata,
|
|
23
|
+
voltro_key: e.key
|
|
24
|
+
})) t.metadata[r] !== i && n.push(`metadata.${r}`);
|
|
25
|
+
return n;
|
|
26
|
+
}, s = (e, t) => {
|
|
27
|
+
let n = `product ${e.key}`, r = t.filter((t) => t.metadata.voltro_key === e.key);
|
|
28
|
+
if (r.length > 1) return {
|
|
29
|
+
finding: {
|
|
30
|
+
kind: "manual",
|
|
31
|
+
object: n,
|
|
32
|
+
detail: `${r.length} products carry this key — archive the extra ones`
|
|
33
|
+
},
|
|
34
|
+
id: null
|
|
35
|
+
};
|
|
36
|
+
let i = r[0];
|
|
37
|
+
if (i !== void 0) {
|
|
38
|
+
let t = o(e, i);
|
|
39
|
+
return t.length === 0 ? {
|
|
40
|
+
finding: {
|
|
41
|
+
kind: "ok",
|
|
42
|
+
object: n
|
|
43
|
+
},
|
|
44
|
+
id: i.id
|
|
45
|
+
} : {
|
|
46
|
+
finding: {
|
|
47
|
+
kind: "update",
|
|
48
|
+
object: n,
|
|
49
|
+
detail: t.join(", "),
|
|
50
|
+
apply: {
|
|
51
|
+
method: "POST",
|
|
52
|
+
path: `/v1/products/${i.id}`,
|
|
53
|
+
params: {
|
|
54
|
+
...a(e),
|
|
55
|
+
active: !0
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
id: i.id
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
let s = t.filter((t) => t.active && t.metadata.voltro_key === void 0 && Object.keys(e.metadata).length > 0 && Object.entries(e.metadata).every(([e, n]) => t.metadata[e] === n));
|
|
63
|
+
if (s.length === 1) {
|
|
64
|
+
let t = s[0];
|
|
65
|
+
return {
|
|
66
|
+
finding: {
|
|
67
|
+
kind: "adopt",
|
|
68
|
+
object: n,
|
|
69
|
+
detail: "existing product gets the catalog key",
|
|
70
|
+
apply: {
|
|
71
|
+
method: "POST",
|
|
72
|
+
path: `/v1/products/${t.id}`,
|
|
73
|
+
params: a(e)
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
id: t.id
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return s.length > 1 ? {
|
|
80
|
+
finding: {
|
|
81
|
+
kind: "manual",
|
|
82
|
+
object: n,
|
|
83
|
+
detail: `${s.length} products could be this one — archive all but one`
|
|
84
|
+
},
|
|
85
|
+
id: null
|
|
86
|
+
} : {
|
|
87
|
+
finding: {
|
|
88
|
+
kind: "create",
|
|
89
|
+
object: n,
|
|
90
|
+
detail: e.name,
|
|
91
|
+
apply: {
|
|
92
|
+
method: "POST",
|
|
93
|
+
path: "/v1/products",
|
|
94
|
+
params: a(e)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
id: null
|
|
98
|
+
};
|
|
99
|
+
}, c = (e, t, n, r) => {
|
|
100
|
+
let i = [];
|
|
101
|
+
return r.product !== t && i.push("product"), r.currency !== e.currency && i.push("currency"), r.unit_amount !== e.unitAmount && i.push("unit_amount"), r.recurring?.interval !== e.interval && i.push("interval"), r.recurring?.usage_type !== e.usageType && i.push("usage_type"), e.usageType === "metered" && r.recurring?.meter !== n && i.push("meter"), r.tax_behavior !== e.taxBehavior && i.push("tax_behavior"), i;
|
|
102
|
+
}, l = (e, t, n, r) => ({
|
|
103
|
+
product: t,
|
|
104
|
+
currency: e.currency,
|
|
105
|
+
unit_amount: e.unitAmount,
|
|
106
|
+
recurring: {
|
|
107
|
+
interval: e.interval,
|
|
108
|
+
usage_type: e.usageType,
|
|
109
|
+
...e.usageType === "metered" && n !== null ? { meter: n } : {}
|
|
110
|
+
},
|
|
111
|
+
tax_behavior: e.taxBehavior,
|
|
112
|
+
lookup_key: e.lookupKey,
|
|
113
|
+
...r ? { transfer_lookup_key: !0 } : {},
|
|
114
|
+
metadata: { voltro_key: e.lookupKey }
|
|
115
|
+
}), u = (e, t, n, r, i, a) => {
|
|
116
|
+
let o = `price ${e.lookupKey}`;
|
|
117
|
+
if (t === null) return {
|
|
118
|
+
finding: {
|
|
119
|
+
kind: "manual",
|
|
120
|
+
object: o,
|
|
121
|
+
detail: "its product is unresolved"
|
|
122
|
+
},
|
|
123
|
+
id: null
|
|
124
|
+
};
|
|
125
|
+
if (e.usageType === "metered" && n === null) return {
|
|
126
|
+
finding: {
|
|
127
|
+
kind: "manual",
|
|
128
|
+
object: o,
|
|
129
|
+
detail: "its meter is unresolved"
|
|
130
|
+
},
|
|
131
|
+
id: null
|
|
132
|
+
};
|
|
133
|
+
if (r !== null) {
|
|
134
|
+
let i = c(e, t, n, r);
|
|
135
|
+
if (i.length > 0) {
|
|
136
|
+
let s = {
|
|
137
|
+
method: "POST",
|
|
138
|
+
path: "/v1/prices",
|
|
139
|
+
params: l(e, t, n, !0)
|
|
140
|
+
};
|
|
141
|
+
return a ? {
|
|
142
|
+
finding: {
|
|
143
|
+
kind: "drift",
|
|
144
|
+
object: o,
|
|
145
|
+
detail: `replaced (${i.join(", ")}); existing subscriptions keep the old price`,
|
|
146
|
+
apply: s
|
|
147
|
+
},
|
|
148
|
+
id: null
|
|
149
|
+
} : {
|
|
150
|
+
finding: {
|
|
151
|
+
kind: "drift",
|
|
152
|
+
object: o,
|
|
153
|
+
detail: `${i.join(", ")} differ — a price change; rerun with --allow-price-change to replace it`
|
|
154
|
+
},
|
|
155
|
+
id: r.id
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return r.active ? {
|
|
159
|
+
finding: {
|
|
160
|
+
kind: "ok",
|
|
161
|
+
object: o
|
|
162
|
+
},
|
|
163
|
+
id: r.id
|
|
164
|
+
} : {
|
|
165
|
+
finding: {
|
|
166
|
+
kind: "update",
|
|
167
|
+
object: o,
|
|
168
|
+
detail: "inactive",
|
|
169
|
+
apply: {
|
|
170
|
+
method: "POST",
|
|
171
|
+
path: `/v1/prices/${r.id}`,
|
|
172
|
+
params: { active: !0 }
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
id: r.id
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
let s = i.filter((r) => r.active && r.lookup_key === null && c(e, t, n, r).length === 0)[0];
|
|
179
|
+
return s === void 0 ? {
|
|
180
|
+
finding: {
|
|
181
|
+
kind: "create",
|
|
182
|
+
object: o,
|
|
183
|
+
detail: `${e.unitAmount} ${e.currency} / ${e.interval}`,
|
|
184
|
+
apply: {
|
|
185
|
+
method: "POST",
|
|
186
|
+
path: "/v1/prices",
|
|
187
|
+
params: l(e, t, n, !1)
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
id: null
|
|
191
|
+
} : {
|
|
192
|
+
finding: {
|
|
193
|
+
kind: "adopt",
|
|
194
|
+
object: o,
|
|
195
|
+
detail: "existing price gets the lookup key",
|
|
196
|
+
apply: {
|
|
197
|
+
method: "POST",
|
|
198
|
+
path: `/v1/prices/${s.id}`,
|
|
199
|
+
params: {
|
|
200
|
+
lookup_key: e.lookupKey,
|
|
201
|
+
metadata: { voltro_key: e.lookupKey }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
id: s.id
|
|
206
|
+
};
|
|
207
|
+
}, d = (e, t) => {
|
|
208
|
+
let n = `meter ${e.eventName}`, r = t.find((t) => t.event_name === e.eventName);
|
|
209
|
+
if (r === void 0) return {
|
|
210
|
+
finding: {
|
|
211
|
+
kind: "create",
|
|
212
|
+
object: n,
|
|
213
|
+
detail: e.displayName,
|
|
214
|
+
apply: {
|
|
215
|
+
method: "POST",
|
|
216
|
+
path: "/v1/billing/meters",
|
|
217
|
+
params: {
|
|
218
|
+
display_name: e.displayName,
|
|
219
|
+
event_name: e.eventName,
|
|
220
|
+
default_aggregation: { formula: e.formula },
|
|
221
|
+
customer_mapping: {
|
|
222
|
+
type: "by_id",
|
|
223
|
+
event_payload_key: e.customerPayloadKey
|
|
224
|
+
},
|
|
225
|
+
value_settings: { event_payload_key: e.valuePayloadKey }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
id: null
|
|
230
|
+
};
|
|
231
|
+
let i = [];
|
|
232
|
+
return r.default_aggregation.formula !== e.formula && i.push("aggregation"), (r.customer_mapping.type !== "by_id" || r.customer_mapping.event_payload_key !== e.customerPayloadKey) && i.push("customer mapping"), r.value_settings.event_payload_key !== e.valuePayloadKey && i.push("value key"), i.length > 0 ? {
|
|
233
|
+
finding: {
|
|
234
|
+
kind: "drift",
|
|
235
|
+
object: n,
|
|
236
|
+
detail: `${i.join(", ")} differ and cannot be edited — a new meter needs a new event name`
|
|
237
|
+
},
|
|
238
|
+
id: r.id
|
|
239
|
+
} : r.status === "active" ? r.display_name === e.displayName ? {
|
|
240
|
+
finding: {
|
|
241
|
+
kind: "ok",
|
|
242
|
+
object: n
|
|
243
|
+
},
|
|
244
|
+
id: r.id
|
|
245
|
+
} : {
|
|
246
|
+
finding: {
|
|
247
|
+
kind: "update",
|
|
248
|
+
object: n,
|
|
249
|
+
detail: "display name",
|
|
250
|
+
apply: {
|
|
251
|
+
method: "POST",
|
|
252
|
+
path: `/v1/billing/meters/${r.id}`,
|
|
253
|
+
params: { display_name: e.displayName }
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
id: r.id
|
|
257
|
+
} : {
|
|
258
|
+
finding: {
|
|
259
|
+
kind: "update",
|
|
260
|
+
object: n,
|
|
261
|
+
detail: "inactive",
|
|
262
|
+
apply: {
|
|
263
|
+
method: "POST",
|
|
264
|
+
path: `/v1/billing/meters/${r.id}/reactivate`,
|
|
265
|
+
params: {}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
id: r.id
|
|
269
|
+
};
|
|
270
|
+
}, f = (e, t) => {
|
|
271
|
+
let n = "tax settings", r = t.head_office?.address ?? {}, i = [];
|
|
272
|
+
for (let [t, n] of Object.entries(e.headOffice)) r[t] !== n && i.push(`head_office.${t}`);
|
|
273
|
+
return t.defaults.tax_code !== e.defaultTaxCode && i.push("defaults.tax_code"), t.defaults.tax_behavior !== e.defaultTaxBehavior && i.push("defaults.tax_behavior"), i.length === 0 ? t.status === "active" ? {
|
|
274
|
+
kind: "ok",
|
|
275
|
+
object: n
|
|
276
|
+
} : {
|
|
277
|
+
kind: "manual",
|
|
278
|
+
object: n,
|
|
279
|
+
detail: `status ${t.status}`
|
|
280
|
+
} : {
|
|
281
|
+
kind: "update",
|
|
282
|
+
object: n,
|
|
283
|
+
detail: i.join(", "),
|
|
284
|
+
apply: {
|
|
285
|
+
method: "POST",
|
|
286
|
+
path: "/v1/tax/settings",
|
|
287
|
+
params: {
|
|
288
|
+
head_office: { address: e.headOffice },
|
|
289
|
+
defaults: {
|
|
290
|
+
tax_code: e.defaultTaxCode,
|
|
291
|
+
tax_behavior: e.defaultTaxBehavior
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}, p = (e, t, n) => ({
|
|
297
|
+
business_profile: {
|
|
298
|
+
headline: e.headline,
|
|
299
|
+
privacy_policy_url: e.privacyPolicyUrl,
|
|
300
|
+
terms_of_service_url: e.termsOfServiceUrl
|
|
301
|
+
},
|
|
302
|
+
default_return_url: t.portalReturnUrl,
|
|
303
|
+
features: {
|
|
304
|
+
customer_update: {
|
|
305
|
+
enabled: !0,
|
|
306
|
+
allowed_updates: [
|
|
307
|
+
"email",
|
|
308
|
+
"address",
|
|
309
|
+
"tax_id",
|
|
310
|
+
"name"
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
invoice_history: { enabled: !0 },
|
|
314
|
+
payment_method_update: { enabled: !0 },
|
|
315
|
+
subscription_cancel: {
|
|
316
|
+
enabled: !0,
|
|
317
|
+
mode: "at_period_end"
|
|
318
|
+
},
|
|
319
|
+
subscription_update: {
|
|
320
|
+
enabled: !0,
|
|
321
|
+
default_allowed_updates: ["price", "quantity"],
|
|
322
|
+
proration_behavior: "create_prorations",
|
|
323
|
+
products: n.map((e) => ({
|
|
324
|
+
product: e.productId,
|
|
325
|
+
prices: [e.priceId]
|
|
326
|
+
}))
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
metadata: { voltro_key: e.key }
|
|
330
|
+
}), m = (e) => JSON.stringify([...e ?? []].sort()), h = (e, t) => {
|
|
331
|
+
let n = [], r = t.features, i = e.features;
|
|
332
|
+
t.default_return_url !== e.default_return_url && n.push("default_return_url");
|
|
333
|
+
let a = e.business_profile;
|
|
334
|
+
for (let e of Object.keys(a)) t.business_profile[e] !== a[e] && n.push(`business_profile.${e}`);
|
|
335
|
+
for (let e of [
|
|
336
|
+
"customer_update",
|
|
337
|
+
"invoice_history",
|
|
338
|
+
"payment_method_update",
|
|
339
|
+
"subscription_cancel"
|
|
340
|
+
]) r[e]?.enabled !== !0 && n.push(`${e}.enabled`);
|
|
341
|
+
m(r.customer_update?.allowed_updates) !== m(i.customer_update.allowed_updates) && n.push("customer_update.allowed_updates"), r.subscription_cancel?.mode !== "at_period_end" && n.push("subscription_cancel.mode");
|
|
342
|
+
let o = r.subscription_update ?? {}, s = i.subscription_update;
|
|
343
|
+
o.enabled !== !0 && n.push("subscription_update.enabled"), o.proration_behavior !== s.proration_behavior && n.push("subscription_update.proration_behavior");
|
|
344
|
+
let c = (e) => JSON.stringify((e ?? []).map((e) => `${e.product}:${[...e.prices].sort().join("|")}`).sort());
|
|
345
|
+
return c(o.products) !== c(s.products) && n.push("subscription_update.products"), m(o.default_allowed_updates) !== m(s.default_allowed_updates) && n.push("subscription_update.default_allowed_updates"), n;
|
|
346
|
+
}, g = (e, t, n, r) => {
|
|
347
|
+
let i = "customer portal";
|
|
348
|
+
if (n === null) return [{
|
|
349
|
+
kind: "manual",
|
|
350
|
+
object: i,
|
|
351
|
+
detail: "its plan prices are unresolved"
|
|
352
|
+
}];
|
|
353
|
+
let a = p(e, t, n), o = r.find((t) => t.metadata.voltro_key === e.key) ?? r.find((t) => t.active && t.name === e.name);
|
|
354
|
+
if (o === void 0) return [{
|
|
355
|
+
kind: "create",
|
|
356
|
+
object: i,
|
|
357
|
+
detail: "self-service configuration",
|
|
358
|
+
apply: {
|
|
359
|
+
method: "POST",
|
|
360
|
+
path: "/v1/billing_portal/configurations",
|
|
361
|
+
params: {
|
|
362
|
+
...a,
|
|
363
|
+
name: e.name
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}, ...r.some((e) => e.is_default) ? [{
|
|
367
|
+
kind: "manual",
|
|
368
|
+
object: i,
|
|
369
|
+
detail: "another configuration is the default — make this one the default in the Dashboard"
|
|
370
|
+
}] : []];
|
|
371
|
+
let s = [], c = h(a, o), l = o.metadata.voltro_key !== e.key;
|
|
372
|
+
return c.length > 0 || l || !o.active ? s.push({
|
|
373
|
+
kind: l ? "adopt" : "update",
|
|
374
|
+
object: i,
|
|
375
|
+
detail: [...c, ...o.active ? [] : ["active"]].join(", ") || "catalog key",
|
|
376
|
+
apply: {
|
|
377
|
+
method: "POST",
|
|
378
|
+
path: `/v1/billing_portal/configurations/${o.id}`,
|
|
379
|
+
params: {
|
|
380
|
+
...a,
|
|
381
|
+
active: !0
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}) : s.push({
|
|
385
|
+
kind: "ok",
|
|
386
|
+
object: i
|
|
387
|
+
}), o.is_default || s.push({
|
|
388
|
+
kind: "manual",
|
|
389
|
+
object: i,
|
|
390
|
+
detail: "not the account default — portal sessions would use another configuration"
|
|
391
|
+
}), s;
|
|
392
|
+
}, _ = (e, r) => {
|
|
393
|
+
if (e.webhookUrl === null) return {
|
|
394
|
+
kind: "ok",
|
|
395
|
+
object: "webhook endpoint (none: stripe listen forwards locally)"
|
|
396
|
+
};
|
|
397
|
+
let i = `webhook endpoint ${e.webhookUrl}`, a = r.filter((t) => t.url === e.webhookUrl);
|
|
398
|
+
if (a.length > 1) return {
|
|
399
|
+
kind: "manual",
|
|
400
|
+
object: i,
|
|
401
|
+
detail: `${a.length} endpoints for this url — delete all but one`
|
|
402
|
+
};
|
|
403
|
+
let o = a[0], s = [...t].sort();
|
|
404
|
+
return o === void 0 ? {
|
|
405
|
+
kind: "create",
|
|
406
|
+
object: i,
|
|
407
|
+
detail: `${s.length} events`,
|
|
408
|
+
apply: {
|
|
409
|
+
method: "POST",
|
|
410
|
+
path: "/v1/webhook_endpoints",
|
|
411
|
+
params: {
|
|
412
|
+
url: e.webhookUrl,
|
|
413
|
+
enabled_events: s,
|
|
414
|
+
api_version: n,
|
|
415
|
+
description: "Voltro billing"
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
} : o.api_version !== null && o.api_version !== n ? {
|
|
419
|
+
kind: "drift",
|
|
420
|
+
object: i,
|
|
421
|
+
detail: `api version ${o.api_version} — payloads would not match the SDK; recreate it (and rotate STRIPE_WEBHOOK_SECRET)`
|
|
422
|
+
} : JSON.stringify([...o.enabled_events].sort()) !== JSON.stringify(s) || o.status !== "enabled" ? {
|
|
423
|
+
kind: "update",
|
|
424
|
+
object: i,
|
|
425
|
+
detail: o.status === "enabled" ? "events" : "disabled",
|
|
426
|
+
apply: {
|
|
427
|
+
method: "POST",
|
|
428
|
+
path: `/v1/webhook_endpoints/${o.id}`,
|
|
429
|
+
params: {
|
|
430
|
+
enabled_events: s,
|
|
431
|
+
disabled: !1
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} : {
|
|
435
|
+
kind: "ok",
|
|
436
|
+
object: i
|
|
437
|
+
};
|
|
438
|
+
}, v = (e) => {
|
|
439
|
+
let t = [];
|
|
440
|
+
for (let n of e.catalog.tax.registrationCountries) e.activeRegistrations.includes(n) || t.push({
|
|
441
|
+
kind: "manual",
|
|
442
|
+
object: `tax registration ${n}`,
|
|
443
|
+
detail: "none active — automatic tax collects nothing until it is registered (Dashboard → Tax → Registrations)"
|
|
444
|
+
});
|
|
445
|
+
if (!e.env.requireSellingReadiness) return t;
|
|
446
|
+
e.chargesEnabled === !1 && t.push({
|
|
447
|
+
kind: "manual",
|
|
448
|
+
object: "account",
|
|
449
|
+
detail: "charges not enabled — finish activation (business details, bank account) in the Dashboard"
|
|
450
|
+
}), e.chargesEnabled === null && t.push({
|
|
451
|
+
kind: "manual",
|
|
452
|
+
object: "account",
|
|
453
|
+
detail: "activation not readable with this key — check it in the Dashboard"
|
|
454
|
+
}), e.accountTaxIds === 0 && t.push({
|
|
455
|
+
kind: "manual",
|
|
456
|
+
object: "account tax id",
|
|
457
|
+
detail: "no VAT id on the account — invoices lack the issuer id"
|
|
458
|
+
}), e.accountTaxIds === null && t.push({
|
|
459
|
+
kind: "manual",
|
|
460
|
+
object: "account tax id",
|
|
461
|
+
detail: "not readable with this key — check Dashboard → Settings → Tax ids"
|
|
462
|
+
});
|
|
463
|
+
for (let n of e.catalog.dashboardReminders ?? r) t.push({
|
|
464
|
+
kind: "manual",
|
|
465
|
+
object: "dashboard",
|
|
466
|
+
detail: `${n} — not checkable through the API`
|
|
467
|
+
});
|
|
468
|
+
return t;
|
|
469
|
+
};
|
|
470
|
+
//#endregion
|
|
471
|
+
export { n as STRIPE_API_VERSION, r as STRIPE_DASHBOARD_REMINDERS, d as diffMeter, g as diffPortal, u as diffPrice, s as diffProduct, f as diffTaxSettings, _ as diffWebhook, p as portalParams, v as sellingReadiness };
|