@usebillow/sdk 0.5.0 → 0.6.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 +11 -0
- package/README.md +9 -0
- package/dist/billing-B-VyZCXV.d.cts +371 -0
- package/dist/billing-CgjcWmvb.d.ts +371 -0
- package/dist/{chunk-Z6VXPONT.js → chunk-DYWGZRE2.js} +197 -15
- package/dist/chunk-DYWGZRE2.js.map +1 -0
- package/dist/config.d.cts +4 -3
- package/dist/config.d.ts +4 -3
- package/dist/{credits-C3Fe3TO0.d.ts → hosted-domains-BtCd-Rur.d.cts} +43 -1
- package/dist/{credits-C3Fe3TO0.d.cts → hosted-domains-CrVDsk2i.d.ts} +43 -1
- package/dist/index.cjs +195 -13
- package/dist/index.cjs.map +1 -1
- package/dist/{billing-C4RIMgH_.d.ts → index.d-CKQAhQfJ.d.cts} +180 -374
- package/dist/{billing-DZ4rIyg7.d.cts → index.d-CKQAhQfJ.d.ts} +180 -374
- package/dist/index.d.cts +547 -42
- package/dist/index.d.ts +547 -42
- package/dist/index.js +1 -1
- package/dist/ingestion.d.cts +3 -2
- package/dist/ingestion.d.ts +3 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -1
- package/dist/server.d.cts +3 -2
- package/dist/server.d.ts +3 -2
- package/dist/webhooks.cjs +10 -2
- package/dist/webhooks.cjs.map +1 -1
- package/dist/webhooks.d.cts +37 -21
- package/dist/webhooks.d.ts +37 -21
- package/dist/webhooks.js +10 -3
- package/dist/webhooks.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-Z6VXPONT.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { C as ChargeStatus } from './billing-status-BZQN_gm7.js';
|
|
3
2
|
|
|
4
3
|
declare const createChargeSchema: z.ZodObject<{
|
|
5
4
|
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -56,8 +55,8 @@ declare const resolveRefundSchema: z.ZodObject<{
|
|
|
56
55
|
}>;
|
|
57
56
|
note: z.ZodString;
|
|
58
57
|
}, z.core.$strip>;
|
|
59
|
-
type CreateChargeInput
|
|
60
|
-
type CreateMerchantInitiatedChargeInput
|
|
58
|
+
type CreateChargeInput = z.infer<typeof createChargeSchema>;
|
|
59
|
+
type CreateMerchantInitiatedChargeInput = z.infer<typeof createMerchantInitiatedChargeSchema>;
|
|
61
60
|
type RefundChargeInput = z.infer<typeof refundChargeSchema>;
|
|
62
61
|
type ResolveRefundInput = z.infer<typeof resolveRefundSchema>;
|
|
63
62
|
|
|
@@ -69,6 +68,172 @@ declare const createCustomerSchema: z.ZodObject<{
|
|
|
69
68
|
taxId: z.ZodOptional<z.ZodString>;
|
|
70
69
|
}, z.core.$strip>;
|
|
71
70
|
type CreateCustomerInput = z.infer<typeof createCustomerSchema>;
|
|
71
|
+
declare const createHostedDomainSchema: z.ZodObject<{
|
|
72
|
+
hostname: z.ZodString;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
declare const hostedDomainResponseSchema: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
hostname: z.ZodString;
|
|
77
|
+
hostnameUnicode: z.ZodString;
|
|
78
|
+
environment: z.ZodLiteral<"live">;
|
|
79
|
+
status: z.ZodEnum<{
|
|
80
|
+
active: "active";
|
|
81
|
+
failed: "failed";
|
|
82
|
+
pending_verification: "pending_verification";
|
|
83
|
+
verified: "verified";
|
|
84
|
+
disabled: "disabled";
|
|
85
|
+
}>;
|
|
86
|
+
statusReason: z.ZodNullable<z.ZodEnum<{
|
|
87
|
+
verification_expired: "verification_expired";
|
|
88
|
+
tls_unavailable: "tls_unavailable";
|
|
89
|
+
edge_blocked: "edge_blocked";
|
|
90
|
+
dns_lost: "dns_lost";
|
|
91
|
+
reassigned: "reassigned";
|
|
92
|
+
entitlement_lapsed: "entitlement_lapsed";
|
|
93
|
+
suspended: "suspended";
|
|
94
|
+
}>>;
|
|
95
|
+
isPrimary: z.ZodBoolean;
|
|
96
|
+
records: z.ZodArray<z.ZodObject<{
|
|
97
|
+
type: z.ZodEnum<{
|
|
98
|
+
TXT: "TXT";
|
|
99
|
+
CNAME: "CNAME";
|
|
100
|
+
}>;
|
|
101
|
+
name: z.ZodString;
|
|
102
|
+
value: z.ZodString;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
dns: z.ZodObject<{
|
|
105
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
106
|
+
failingSince: z.ZodNullable<z.ZodString>;
|
|
107
|
+
graceEndsAt: z.ZodNullable<z.ZodString>;
|
|
108
|
+
txt: z.ZodObject<{
|
|
109
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
110
|
+
found: "found";
|
|
111
|
+
missing: "missing";
|
|
112
|
+
inconclusive: "inconclusive";
|
|
113
|
+
}>>;
|
|
114
|
+
values: z.ZodArray<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
cname: z.ZodObject<{
|
|
117
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
118
|
+
found: "found";
|
|
119
|
+
missing: "missing";
|
|
120
|
+
inconclusive: "inconclusive";
|
|
121
|
+
wrong: "wrong";
|
|
122
|
+
}>>;
|
|
123
|
+
chain: z.ZodArray<z.ZodString>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
edge: z.ZodObject<{
|
|
127
|
+
status: z.ZodNullable<z.ZodString>;
|
|
128
|
+
sslStatus: z.ZodNullable<z.ZodString>;
|
|
129
|
+
errors: z.ZodArray<z.ZodString>;
|
|
130
|
+
certificateExpiresAt: z.ZodNullable<z.ZodString>;
|
|
131
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
reassignment: z.ZodNullable<z.ZodObject<{
|
|
134
|
+
role: z.ZodEnum<{
|
|
135
|
+
owner: "owner";
|
|
136
|
+
claimant: "claimant";
|
|
137
|
+
}>;
|
|
138
|
+
dueAt: z.ZodString;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
entitlementLapse: z.ZodNullable<z.ZodObject<{
|
|
141
|
+
lapsedAt: z.ZodString;
|
|
142
|
+
servingEndsAt: z.ZodString;
|
|
143
|
+
disablesAt: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
verificationExpiresAt: z.ZodNullable<z.ZodString>;
|
|
146
|
+
verifiedAt: z.ZodNullable<z.ZodString>;
|
|
147
|
+
activatedAt: z.ZodNullable<z.ZodString>;
|
|
148
|
+
createdAt: z.ZodString;
|
|
149
|
+
updatedAt: z.ZodString;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
declare const hostedDomainListResponseSchema: z.ZodObject<{
|
|
152
|
+
data: z.ZodArray<z.ZodObject<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
hostname: z.ZodString;
|
|
155
|
+
hostnameUnicode: z.ZodString;
|
|
156
|
+
environment: z.ZodLiteral<"live">;
|
|
157
|
+
status: z.ZodEnum<{
|
|
158
|
+
active: "active";
|
|
159
|
+
failed: "failed";
|
|
160
|
+
pending_verification: "pending_verification";
|
|
161
|
+
verified: "verified";
|
|
162
|
+
disabled: "disabled";
|
|
163
|
+
}>;
|
|
164
|
+
statusReason: z.ZodNullable<z.ZodEnum<{
|
|
165
|
+
verification_expired: "verification_expired";
|
|
166
|
+
tls_unavailable: "tls_unavailable";
|
|
167
|
+
edge_blocked: "edge_blocked";
|
|
168
|
+
dns_lost: "dns_lost";
|
|
169
|
+
reassigned: "reassigned";
|
|
170
|
+
entitlement_lapsed: "entitlement_lapsed";
|
|
171
|
+
suspended: "suspended";
|
|
172
|
+
}>>;
|
|
173
|
+
isPrimary: z.ZodBoolean;
|
|
174
|
+
records: z.ZodArray<z.ZodObject<{
|
|
175
|
+
type: z.ZodEnum<{
|
|
176
|
+
TXT: "TXT";
|
|
177
|
+
CNAME: "CNAME";
|
|
178
|
+
}>;
|
|
179
|
+
name: z.ZodString;
|
|
180
|
+
value: z.ZodString;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
dns: z.ZodObject<{
|
|
183
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
184
|
+
failingSince: z.ZodNullable<z.ZodString>;
|
|
185
|
+
graceEndsAt: z.ZodNullable<z.ZodString>;
|
|
186
|
+
txt: z.ZodObject<{
|
|
187
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
188
|
+
found: "found";
|
|
189
|
+
missing: "missing";
|
|
190
|
+
inconclusive: "inconclusive";
|
|
191
|
+
}>>;
|
|
192
|
+
values: z.ZodArray<z.ZodString>;
|
|
193
|
+
}, z.core.$strip>;
|
|
194
|
+
cname: z.ZodObject<{
|
|
195
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
196
|
+
found: "found";
|
|
197
|
+
missing: "missing";
|
|
198
|
+
inconclusive: "inconclusive";
|
|
199
|
+
wrong: "wrong";
|
|
200
|
+
}>>;
|
|
201
|
+
chain: z.ZodArray<z.ZodString>;
|
|
202
|
+
}, z.core.$strip>;
|
|
203
|
+
}, z.core.$strip>;
|
|
204
|
+
edge: z.ZodObject<{
|
|
205
|
+
status: z.ZodNullable<z.ZodString>;
|
|
206
|
+
sslStatus: z.ZodNullable<z.ZodString>;
|
|
207
|
+
errors: z.ZodArray<z.ZodString>;
|
|
208
|
+
certificateExpiresAt: z.ZodNullable<z.ZodString>;
|
|
209
|
+
checkedAt: z.ZodNullable<z.ZodString>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
reassignment: z.ZodNullable<z.ZodObject<{
|
|
212
|
+
role: z.ZodEnum<{
|
|
213
|
+
owner: "owner";
|
|
214
|
+
claimant: "claimant";
|
|
215
|
+
}>;
|
|
216
|
+
dueAt: z.ZodString;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
entitlementLapse: z.ZodNullable<z.ZodObject<{
|
|
219
|
+
lapsedAt: z.ZodString;
|
|
220
|
+
servingEndsAt: z.ZodString;
|
|
221
|
+
disablesAt: z.ZodString;
|
|
222
|
+
}, z.core.$strip>>;
|
|
223
|
+
verificationExpiresAt: z.ZodNullable<z.ZodString>;
|
|
224
|
+
verifiedAt: z.ZodNullable<z.ZodString>;
|
|
225
|
+
activatedAt: z.ZodNullable<z.ZodString>;
|
|
226
|
+
createdAt: z.ZodString;
|
|
227
|
+
updatedAt: z.ZodString;
|
|
228
|
+
}, z.core.$strip>>;
|
|
229
|
+
whiteLabel: z.ZodObject<{
|
|
230
|
+
entitled: z.ZodBoolean;
|
|
231
|
+
requiredPlan: z.ZodString;
|
|
232
|
+
}, z.core.$strip>;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
type CreateHostedDomainInput = z.infer<typeof createHostedDomainSchema>;
|
|
235
|
+
type HostedDomainResponse = z.infer<typeof hostedDomainResponseSchema>;
|
|
236
|
+
type HostedDomainListResponse = z.infer<typeof hostedDomainListResponseSchema>;
|
|
72
237
|
|
|
73
238
|
declare const payInvoiceSchema: z.ZodObject<{
|
|
74
239
|
returnUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -349,8 +514,8 @@ declare const productResponseSchema: z.ZodObject<{
|
|
|
349
514
|
rollover: z.ZodBoolean;
|
|
350
515
|
}, z.core.$strict>>;
|
|
351
516
|
}, z.core.$strict>;
|
|
352
|
-
type CreateProductInput
|
|
353
|
-
type UpdateProductInput
|
|
517
|
+
type CreateProductInput = z.infer<typeof createProductSchema>;
|
|
518
|
+
type UpdateProductInput = z.infer<typeof updateProductSchema>;
|
|
354
519
|
type MigrateSubscribersInput = z.infer<typeof migrateSubscribersSchema>;
|
|
355
520
|
type ProductPriceResponse = z.infer<typeof productPriceResponseSchema>;
|
|
356
521
|
type ProductEntitlementResponse = z.infer<typeof productEntitlementResponseSchema>;
|
|
@@ -581,7 +746,7 @@ declare const subscriptionItemResponseSchema: z.ZodObject<{
|
|
|
581
746
|
isAddOn: z.ZodBoolean;
|
|
582
747
|
isBase: z.ZodBoolean;
|
|
583
748
|
}, z.core.$strict>;
|
|
584
|
-
type CreateSubscriptionInput
|
|
749
|
+
type CreateSubscriptionInput = z.infer<typeof createSubscriptionSchema>;
|
|
585
750
|
type CancelSubscriptionInput = z.infer<typeof cancelSubscriptionSchema>;
|
|
586
751
|
type ChangeSubscriptionPlanInput = z.infer<typeof changeSubscriptionPlanSchema>;
|
|
587
752
|
type AddSubscriptionItemInput = z.infer<typeof addSubscriptionItemSchema>;
|
|
@@ -634,6 +799,10 @@ declare const createWebhookEndpointSchema: z.ZodObject<{
|
|
|
634
799
|
"credit_top_up.failed": "credit_top_up.failed";
|
|
635
800
|
"credit_top_up.refunded": "credit_top_up.refunded";
|
|
636
801
|
"credit_top_up.unfulfilled": "credit_top_up.unfulfilled";
|
|
802
|
+
"hosted_domain.activated": "hosted_domain.activated";
|
|
803
|
+
"hosted_domain.dns_failing": "hosted_domain.dns_failing";
|
|
804
|
+
"hosted_domain.reassignment_pending": "hosted_domain.reassignment_pending";
|
|
805
|
+
"hosted_domain.disabled": "hosted_domain.disabled";
|
|
637
806
|
}>, z.ZodLiteral<"*">]>>>;
|
|
638
807
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
639
808
|
}, z.core.$strip>;
|
|
@@ -677,377 +846,14 @@ declare const updateWebhookEndpointSchema: z.ZodObject<{
|
|
|
677
846
|
"credit_top_up.failed": "credit_top_up.failed";
|
|
678
847
|
"credit_top_up.refunded": "credit_top_up.refunded";
|
|
679
848
|
"credit_top_up.unfulfilled": "credit_top_up.unfulfilled";
|
|
849
|
+
"hosted_domain.activated": "hosted_domain.activated";
|
|
850
|
+
"hosted_domain.dns_failing": "hosted_domain.dns_failing";
|
|
851
|
+
"hosted_domain.reassignment_pending": "hosted_domain.reassignment_pending";
|
|
852
|
+
"hosted_domain.disabled": "hosted_domain.disabled";
|
|
680
853
|
}>, z.ZodLiteral<"*">]>>>;
|
|
681
854
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
682
855
|
}, z.core.$strip>;
|
|
683
856
|
type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointSchema>;
|
|
684
857
|
type UpdateWebhookEndpointInput = z.infer<typeof updateWebhookEndpointSchema>;
|
|
685
858
|
|
|
686
|
-
|
|
687
|
-
interface BillowOptions {
|
|
688
|
-
/**
|
|
689
|
-
* Base URL of the Billow API. Falls back to the `BILLOW_URL` env var, then to the hosted
|
|
690
|
-
* API at `https://api.usebillow.com`. Set it for local development (for example
|
|
691
|
-
* `http://localhost:4001`) or a self-hosted server.
|
|
692
|
-
*/
|
|
693
|
-
baseUrl?: string;
|
|
694
|
-
fetch?: typeof fetch;
|
|
695
|
-
/**
|
|
696
|
-
* Hard per-request timeout in milliseconds; the request is aborted once it elapses.
|
|
697
|
-
* Defaults to 60_000. Set `0` to disable the timeout.
|
|
698
|
-
*/
|
|
699
|
-
timeoutMs?: number;
|
|
700
|
-
/**
|
|
701
|
-
* How many times to retry a transient failure. Retries are **opt-in** — the default is
|
|
702
|
-
* `0`. Only requests that are safe to repeat are retried: every `GET`, plus **any** method
|
|
703
|
-
* on a `429` (a rate-limited request never executed). A write (`POST`/`PATCH`/`DELETE`) is
|
|
704
|
-
* never retried on a `5xx`/network error, since it may have already applied.
|
|
705
|
-
*/
|
|
706
|
-
maxRetries?: number;
|
|
707
|
-
/**
|
|
708
|
-
* Base backoff in milliseconds between retries — exponential (`base × 2^attempt`), and a
|
|
709
|
-
* `Retry-After` response header takes precedence when present. Defaults to 500.
|
|
710
|
-
*/
|
|
711
|
-
retryBackoffMs?: number;
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Per-call overrides passed as the last argument to a resource method.
|
|
715
|
-
* - `signal` cancels the request (a caller abort is surfaced immediately and never retried).
|
|
716
|
-
* - `timeoutMs` overrides the client's default timeout for this call (applied per attempt).
|
|
717
|
-
* - `idempotencyKey` sends an `Idempotency-Key` and makes the write **safe to retry** — reused
|
|
718
|
-
* verbatim on every attempt. Only exposed on writes the server replays (create/attach/track/refund).
|
|
719
|
-
*/
|
|
720
|
-
interface RequestOptions {
|
|
721
|
-
signal?: AbortSignal;
|
|
722
|
-
timeoutMs?: number;
|
|
723
|
-
idempotencyKey?: string;
|
|
724
|
-
}
|
|
725
|
-
/** Options for writes that require a stable idempotency key. */
|
|
726
|
-
type IdempotentRequestOptions = RequestOptions & {
|
|
727
|
-
idempotencyKey: string;
|
|
728
|
-
};
|
|
729
|
-
/** Per-call overrides for reads and non-replayable writes — cancellation + timeout, no idempotency key. */
|
|
730
|
-
type CallOptions = Omit<RequestOptions, "idempotencyKey">;
|
|
731
|
-
interface Customer {
|
|
732
|
-
id: string;
|
|
733
|
-
externalId: string;
|
|
734
|
-
name?: string | null;
|
|
735
|
-
email?: string | null;
|
|
736
|
-
phone?: string | null;
|
|
737
|
-
/** The customer's tax / VAT registration number, recorded on their invoices. */
|
|
738
|
-
taxId?: string | null;
|
|
739
|
-
}
|
|
740
|
-
/** How a price's tax relates to its amount: added on top (`exclusive`) or contained (`inclusive`). */
|
|
741
|
-
type TaxBehavior = "exclusive" | "inclusive";
|
|
742
|
-
interface CheckResult {
|
|
743
|
-
feature: string;
|
|
744
|
-
allowed: boolean;
|
|
745
|
-
balance: number | null;
|
|
746
|
-
}
|
|
747
|
-
interface AttachResult {
|
|
748
|
-
/** Hosted checkout URL to redirect the customer to (null if none was minted). */
|
|
749
|
-
url: string | null;
|
|
750
|
-
/** Null until a paid first-cycle checkout succeeds and creates the subscription. */
|
|
751
|
-
subscriptionId: string | null;
|
|
752
|
-
checkoutSessionId: string | null;
|
|
753
|
-
}
|
|
754
|
-
type BillingInterval = "day" | "week" | "month" | "year";
|
|
755
|
-
type FeatureKind = "boolean" | "metered";
|
|
756
|
-
type MeterAggregation = "count" | "sum" | "max" | "latest" | "count_unique";
|
|
757
|
-
type MeterRoundingMode = "none" | "round" | "ceil" | "floor";
|
|
758
|
-
interface MeterFilter {
|
|
759
|
-
key: string;
|
|
760
|
-
values: string[];
|
|
761
|
-
}
|
|
762
|
-
/** A meter's measurement config (ADR-0011) — how a metered feature's usage aggregates. */
|
|
763
|
-
interface MeterConfig {
|
|
764
|
-
aggregation: MeterAggregation;
|
|
765
|
-
eventProperty?: string | null;
|
|
766
|
-
filters?: MeterFilter[];
|
|
767
|
-
roundingMode?: MeterRoundingMode;
|
|
768
|
-
roundingScale?: number | null;
|
|
769
|
-
/**
|
|
770
|
-
* Reset window anchoring (plan 07). Omitted/`cycle` = subscription anniversary in UTC
|
|
771
|
-
* (default). `calendar` tiles windows on calendar months in `resetTz` and REQUIRES a
|
|
772
|
-
* canonical IANA `resetTz` (e.g. `"Africa/Cairo"`, `"UTC"`).
|
|
773
|
-
*/
|
|
774
|
-
resetAnchor?: "cycle" | "calendar";
|
|
775
|
-
resetTz?: string | null;
|
|
776
|
-
}
|
|
777
|
-
/** How a usage price turns billable quantity into money. */
|
|
778
|
-
type UsageModel = "graduated" | "volume" | "package" | "percentage" | "stairstep";
|
|
779
|
-
/** A usage-pricing tier (`upTo: null` = the unbounded last tier). */
|
|
780
|
-
interface UsageTier {
|
|
781
|
-
upTo: number | null;
|
|
782
|
-
unitAmount: number;
|
|
783
|
-
flatAmount?: number;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/** Public SDK types for this domain. Re-exported by ../types.ts. */
|
|
787
|
-
|
|
788
|
-
interface PriceInput {
|
|
789
|
-
/** `licensed` = per-unit recurring, billed × the subscription item's quantity (seats). */
|
|
790
|
-
kind: "fixed_recurring" | "licensed" | "one_time" | "usage";
|
|
791
|
-
interval?: BillingInterval;
|
|
792
|
-
intervalCount?: number;
|
|
793
|
-
/** Amount in minor units (per unit for `usage` prices without tiers). */
|
|
794
|
-
amount: number;
|
|
795
|
-
currency: string;
|
|
796
|
-
/** For `usage` prices: the metered feature's slug. */
|
|
797
|
-
meterFeature?: string;
|
|
798
|
-
/** For `usage` prices: the pricing model (default graduated). */
|
|
799
|
-
usageModel?: UsageModel;
|
|
800
|
-
/** For `usage` prices: tiers for graduated/volume/stairstep (overrides flat `amount`). */
|
|
801
|
-
usageTiers?: UsageTier[];
|
|
802
|
-
/** For `package` pricing: units per package (each priced at `amount`). */
|
|
803
|
-
packageSize?: number;
|
|
804
|
-
/** For `percentage` pricing: basis points of the metered amount. */
|
|
805
|
-
rateBps?: number;
|
|
806
|
-
/** Tax rate override in basis points; omit to inherit the org default, 0 = zero-rated. */
|
|
807
|
-
taxRateBps?: number | null;
|
|
808
|
-
/** Tax behavior override; omit to inherit the org default. */
|
|
809
|
-
taxBehavior?: TaxBehavior | null;
|
|
810
|
-
}
|
|
811
|
-
interface EntitlementInput {
|
|
812
|
-
/** The feature's slug (must already exist). */
|
|
813
|
-
feature: string;
|
|
814
|
-
/** Included units; `null`/omitted = unlimited. */
|
|
815
|
-
allowance?: number | null;
|
|
816
|
-
/** How often the balance refills; omitted = only on renewal. */
|
|
817
|
-
resetInterval?: BillingInterval;
|
|
818
|
-
rollover?: boolean;
|
|
819
|
-
}
|
|
820
|
-
interface CreateProductInput {
|
|
821
|
-
slug: string;
|
|
822
|
-
name: string;
|
|
823
|
-
type: "recurring" | "one_time";
|
|
824
|
-
isAddOn?: boolean;
|
|
825
|
-
/** Free-form string map that round-trips on the product + on subscription.* webhooks. */
|
|
826
|
-
metadata?: Record<string, string>;
|
|
827
|
-
prices: PriceInput[];
|
|
828
|
-
entitlements?: EntitlementInput[];
|
|
829
|
-
}
|
|
830
|
-
/** A price in a product edit: carry `id` to update that row in place, omit it to add. */
|
|
831
|
-
type UpdatePriceInput = PriceInput & {
|
|
832
|
-
id?: string;
|
|
833
|
-
};
|
|
834
|
-
/** The result of migrating a plan's subscribers to another plan (ADR-0015). */
|
|
835
|
-
interface MigrationResult {
|
|
836
|
-
/** How many subscriptions were moved to the target plan. */
|
|
837
|
-
migrated: number;
|
|
838
|
-
/** Subscriptions that couldn't be moved, with the reason (wrong currency, not active, …). */
|
|
839
|
-
skipped: Array<{
|
|
840
|
-
subscriptionId: string;
|
|
841
|
-
reason: string;
|
|
842
|
-
}>;
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* Edit a product (ADR-0015): rename, archive, and/or replace its prices/entitlements
|
|
846
|
-
* in place. `prices`/`entitlements`, when given, reconcile the latest version's rows
|
|
847
|
-
* (existing subscribers re-price at their next renewal).
|
|
848
|
-
*/
|
|
849
|
-
interface UpdateProductInput {
|
|
850
|
-
name?: string;
|
|
851
|
-
archived?: boolean;
|
|
852
|
-
/** Replace the product's metadata map. */
|
|
853
|
-
metadata?: Record<string, string>;
|
|
854
|
-
prices?: UpdatePriceInput[];
|
|
855
|
-
entitlements?: EntitlementInput[];
|
|
856
|
-
}
|
|
857
|
-
interface Feature {
|
|
858
|
-
id: string;
|
|
859
|
-
slug: string;
|
|
860
|
-
name: string;
|
|
861
|
-
kind: FeatureKind;
|
|
862
|
-
/** Meter config for metered features (ADR-0011); null/absent for boolean. */
|
|
863
|
-
meter?: MeterConfig | null;
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* An in-place edit to a feature. `name` is always allowed; `meter` re-configures a
|
|
867
|
-
* metered feature's aggregation — but the server refuses a meter change once usage has
|
|
868
|
-
* been recorded (it would rewrite billed history). At least one field must be present.
|
|
869
|
-
*/
|
|
870
|
-
interface UpdateFeatureInput {
|
|
871
|
-
name?: string;
|
|
872
|
-
meter?: MeterConfig;
|
|
873
|
-
}
|
|
874
|
-
/** A usage-monitoring rule: a `threshold` Alert (notifies) or a `cap` (blocks). */
|
|
875
|
-
type UsageAlertKind = "threshold" | "cap";
|
|
876
|
-
/** How an alert threshold figure reads: absolute usage, percent used, or percent remaining. */
|
|
877
|
-
type UsageAlertMetric = "absolute" | "percent_used" | "percent_remaining";
|
|
878
|
-
/** A configured Alert / Spend cap on a metered feature (Phase C). */
|
|
879
|
-
interface UsageAlert {
|
|
880
|
-
id: string;
|
|
881
|
-
kind: UsageAlertKind;
|
|
882
|
-
metric: UsageAlertMetric;
|
|
883
|
-
/** Threshold figures (units, or a percentage). One for a cap; one+ for an Alert. */
|
|
884
|
-
thresholds: number[];
|
|
885
|
-
/** Threshold Alerts: re-fire every N past the highest threshold; else null. */
|
|
886
|
-
recurringStep: number | null;
|
|
887
|
-
/** Threshold Alerts: also email the Customer (webhook always fires). */
|
|
888
|
-
notifyCustomer: boolean;
|
|
889
|
-
enabled: boolean;
|
|
890
|
-
}
|
|
891
|
-
interface CreateUsageAlertInput {
|
|
892
|
-
kind: UsageAlertKind;
|
|
893
|
-
metric: UsageAlertMetric;
|
|
894
|
-
thresholds: number[];
|
|
895
|
-
/** Threshold Alerts only: re-fire every N past the highest threshold. */
|
|
896
|
-
recurringStep?: number;
|
|
897
|
-
/** Threshold Alerts only: also email the Customer. */
|
|
898
|
-
notifyCustomer?: boolean;
|
|
899
|
-
}
|
|
900
|
-
interface TrackResult {
|
|
901
|
-
ok: true;
|
|
902
|
-
/** True when the idempotency key was already seen — the call was a no-op. */
|
|
903
|
-
deduplicated: boolean;
|
|
904
|
-
/** Remaining balance for the feature; `null` if unlimited. */
|
|
905
|
-
balance: number | null;
|
|
906
|
-
}
|
|
907
|
-
interface EntitlementView {
|
|
908
|
-
feature: string;
|
|
909
|
-
kind: FeatureKind;
|
|
910
|
-
allowed: boolean;
|
|
911
|
-
balance: number | null;
|
|
912
|
-
}
|
|
913
|
-
type ProductPrice = ProductPriceResponse;
|
|
914
|
-
type ProductEntitlement = ProductEntitlementResponse;
|
|
915
|
-
type Product = ProductResponse;
|
|
916
|
-
type Subscription = SubscriptionResponse;
|
|
917
|
-
/** A single fetched subscription (`subscriptions.get`) - {@link Subscription} plus the stable `customerExternalId` + `productSlug`. */
|
|
918
|
-
type SubscriptionDetail = SubscriptionDetailResponse;
|
|
919
|
-
/** A subscription line item — the base plan or an attached add-on (Phase D2). */
|
|
920
|
-
type SubscriptionItem = SubscriptionItemResponse;
|
|
921
|
-
interface CreateSubscriptionInput {
|
|
922
|
-
customerId: string;
|
|
923
|
-
/** The product slug to subscribe to. */
|
|
924
|
-
productId: string;
|
|
925
|
-
redirectionUrl?: string;
|
|
926
|
-
/** Optional coupon code to apply to the subscription. */
|
|
927
|
-
couponCode?: string;
|
|
928
|
-
/** Free-trial length in days (starts `trialing`, no charge until trial end). */
|
|
929
|
-
trialDays?: number;
|
|
930
|
-
/** For a trial, collect a card up front via tokenization (default true). */
|
|
931
|
-
collectCard?: boolean;
|
|
932
|
-
/** Units of the base price to bill (e.g. seats for a `licensed` plan); default 1. */
|
|
933
|
-
quantity?: number;
|
|
934
|
-
/** Limited term: total billing cycles before the subscription ends; omit = open-ended. */
|
|
935
|
-
cycles?: number;
|
|
936
|
-
/**
|
|
937
|
-
* The billing currency (Phase F, ADR-0013). Required only when the product has
|
|
938
|
-
* recurring prices in more than one currency; inferred when there's a single one.
|
|
939
|
-
*/
|
|
940
|
-
currency?: string;
|
|
941
|
-
}
|
|
942
|
-
type CouponKind = "percent" | "fixed";
|
|
943
|
-
type CouponDuration = "once" | "repeating" | "forever";
|
|
944
|
-
interface CreateCouponInput {
|
|
945
|
-
code?: string;
|
|
946
|
-
kind: CouponKind;
|
|
947
|
-
/** percent: basis points (1% = 100 bps). fixed: minor units. */
|
|
948
|
-
value: number;
|
|
949
|
-
currency?: string;
|
|
950
|
-
duration: CouponDuration;
|
|
951
|
-
durationCycles?: number;
|
|
952
|
-
maxRedemptions?: number;
|
|
953
|
-
/** ISO-8601 timestamp. */
|
|
954
|
-
expiresAt?: string;
|
|
955
|
-
/** Product slugs the coupon is restricted to. */
|
|
956
|
-
productRestrictions?: string[];
|
|
957
|
-
}
|
|
958
|
-
interface Coupon {
|
|
959
|
-
id: string;
|
|
960
|
-
code: string | null;
|
|
961
|
-
kind: CouponKind;
|
|
962
|
-
value: number;
|
|
963
|
-
currency: string | null;
|
|
964
|
-
duration: CouponDuration;
|
|
965
|
-
durationCycles: number | null;
|
|
966
|
-
maxRedemptions: number | null;
|
|
967
|
-
redeemedCount: number;
|
|
968
|
-
expiresAt: string | null;
|
|
969
|
-
/** Set when an operator deactivated the coupon (it can no longer be applied). */
|
|
970
|
-
deactivatedAt?: string | null;
|
|
971
|
-
productRestrictions?: string[] | null;
|
|
972
|
-
}
|
|
973
|
-
type ActivatedSubscriptionResult = ActivatedSubscriptionResponse;
|
|
974
|
-
type PendingSubscriptionCheckoutResult = PendingSubscriptionCheckoutResponse;
|
|
975
|
-
type CreateSubscriptionResult = CreateSubscriptionResponse;
|
|
976
|
-
/**
|
|
977
|
-
* Why a succeeded charge could not be applied to the invoice it paid, so its money awaits an
|
|
978
|
-
* Operator refund: `duplicate_payment` - another payment had already paid the invoice;
|
|
979
|
-
* `invoice_closed` - the invoice was voided or written off before this payment arrived.
|
|
980
|
-
*/
|
|
981
|
-
type UnappliedPaymentReason = "duplicate_payment" | "invoice_closed";
|
|
982
|
-
interface Charge {
|
|
983
|
-
id: string;
|
|
984
|
-
status: ChargeStatus;
|
|
985
|
-
customerId: string;
|
|
986
|
-
customerExternalId: string;
|
|
987
|
-
invoiceId: string | null;
|
|
988
|
-
kind: "customer_present" | "mit";
|
|
989
|
-
subtotal: number;
|
|
990
|
-
tax: number;
|
|
991
|
-
total: number;
|
|
992
|
-
taxRateBps: number | null;
|
|
993
|
-
taxBehavior: "exclusive" | "inclusive" | null;
|
|
994
|
-
items: {
|
|
995
|
-
name: string;
|
|
996
|
-
amount: number;
|
|
997
|
-
quantity: number;
|
|
998
|
-
description?: string;
|
|
999
|
-
}[];
|
|
1000
|
-
/** Backward-compatible alias of `total`, the amount sent to the provider. */
|
|
1001
|
-
amount: number;
|
|
1002
|
-
currency: string;
|
|
1003
|
-
checkoutUrl: string | null;
|
|
1004
|
-
specialReference: string;
|
|
1005
|
-
providerTransactionId: string | null;
|
|
1006
|
-
errorMessage: string | null;
|
|
1007
|
-
/** Provider-reported dispute/chargeback (PRD-08), read-only. Null unless disputed. */
|
|
1008
|
-
disputedAt: string | null;
|
|
1009
|
-
disputeReason: string | null;
|
|
1010
|
-
disputeId: string | null;
|
|
1011
|
-
disputeAmount: number | null;
|
|
1012
|
-
disputeState: "open" | "won" | "lost" | null;
|
|
1013
|
-
/** Set when this payment could not be applied to its invoice; null otherwise. */
|
|
1014
|
-
unappliedReason: UnappliedPaymentReason | null;
|
|
1015
|
-
createdAt: string;
|
|
1016
|
-
}
|
|
1017
|
-
interface CreateChargeInput {
|
|
1018
|
-
customerId: string;
|
|
1019
|
-
/** Amount in minor units (e.g. piasters). */
|
|
1020
|
-
amount: number;
|
|
1021
|
-
currency: string;
|
|
1022
|
-
/** Tax rate in basis points. When set, `taxBehavior` defaults to `exclusive`. */
|
|
1023
|
-
taxRateBps?: number;
|
|
1024
|
-
/** Whether `amount` excludes or includes tax. Requires `taxRateBps`. */
|
|
1025
|
-
taxBehavior?: "exclusive" | "inclusive";
|
|
1026
|
-
items?: {
|
|
1027
|
-
name: string;
|
|
1028
|
-
amount: number;
|
|
1029
|
-
quantity: number;
|
|
1030
|
-
description?: string;
|
|
1031
|
-
}[];
|
|
1032
|
-
/** Restrict the offered methods; omit to offer every method the merchant has configured. */
|
|
1033
|
-
methods?: ("card" | "wallet" | "sympl" | "applepay")[];
|
|
1034
|
-
saveCard?: boolean;
|
|
1035
|
-
redirectionUrl?: string;
|
|
1036
|
-
}
|
|
1037
|
-
/** A standalone off-session charge against the customer's current saved card. */
|
|
1038
|
-
interface CreateMerchantInitiatedChargeInput {
|
|
1039
|
-
customerId: string;
|
|
1040
|
-
paymentMethodId: string;
|
|
1041
|
-
amount: number;
|
|
1042
|
-
currency: string;
|
|
1043
|
-
items: {
|
|
1044
|
-
name: string;
|
|
1045
|
-
amount: number;
|
|
1046
|
-
quantity: number;
|
|
1047
|
-
description?: string;
|
|
1048
|
-
}[];
|
|
1049
|
-
taxRateBps?: number;
|
|
1050
|
-
taxBehavior?: "exclusive" | "inclusive";
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
export type { MeterAggregation as $, AttachResult as A, BillowOptions as B, CreateProductInput as C, CreatePortalSessionInput as D, EntitlementView as E, FeatureKind as F, CreateProductInput$1 as G, CreateSubscriptionInput$1 as H, IdempotentRequestOptions as I, CreateWebhookEndpointInput as J, MigrateSubscribersInput as K, RefundChargeInput as L, MeterConfig as M, ResolveRefundInput as N, UpdateProductInput$1 as O, Product as P, UpdateSubscriptionItemInput as Q, RequestOptions as R, SavedPaymentMethod as S, TrackResult as T, UnappliedPaymentReason as U, UpdateWebhookEndpointInput as V, CouponDuration as W, CouponKind as X, CreateSubscriptionResult as Y, EntitlementInput as Z, InvoicePaymentResult as _, CreateCouponInput as a, MeterFilter as a0, MeterRoundingMode as a1, PendingSubscriptionCheckoutResult as a2, PriceInput as a3, ProductEntitlement as a4, ProductPrice as a5, Subscription as a6, SubscriptionDetail as a7, SubscriptionItem as a8, UpdatePriceInput as a9, UsageAlertKind as aa, UsageAlertMetric as ab, UsageModel as ac, UsageTier as ad, CheckResult as b, TaxBehavior as c, Customer as d, CreateChargeInput as e, Charge as f, CreateMerchantInitiatedChargeInput as g, CallOptions as h, PayInvoiceInput as i, UpdateProductInput as j, MigrationResult as k, CreateSubscriptionInput as l, Coupon as m, Feature as n, UpdateFeatureInput as o, UsageAlert as p, CreateUsageAlertInput as q, ActivatedSubscriptionResult as r, BillingInterval as s, AddSubscriptionItemInput as t, ApplySubscriptionCouponInput as u, CancelSubscriptionInput as v, ChangeSubscriptionPlanInput as w, CreateChargeInput$1 as x, CreateCustomerInput as y, CreateMerchantInitiatedChargeInput$1 as z };
|
|
859
|
+
export type { ActivatedSubscriptionResponse as A, CreateSubscriptionResponse as C, HostedDomainResponse as H, InvoicePaymentResult as I, MigrateSubscribersInput as M, PendingSubscriptionCheckoutResponse as P, RefundChargeInput as R, SubscriptionResponse as S, UpdateProductInput as U, ProductResponse as a, ProductEntitlementResponse as b, ProductPriceResponse as c, SubscriptionDetailResponse as d, SubscriptionItemResponse as e, SavedPaymentMethod as f, CreateHostedDomainInput as g, PayInvoiceInput as h, AddSubscriptionItemInput as i, ApplySubscriptionCouponInput as j, CancelSubscriptionInput as k, ChangeSubscriptionPlanInput as l, CreateChargeInput as m, CreateCustomerInput as n, CreateMerchantInitiatedChargeInput as o, CreatePortalSessionInput as p, CreateProductInput as q, CreateSubscriptionInput as r, CreateWebhookEndpointInput as s, ResolveRefundInput as t, UpdateSubscriptionItemInput as u, UpdateWebhookEndpointInput as v, HostedDomainListResponse as w };
|