@billkit-eu/sdk 0.6.0 → 0.7.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 +26 -0
- package/README.md +3 -1
- package/dist/index.cjs +203 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +289 -29
- package/dist/index.d.ts +289 -29
- package/dist/index.js +203 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +3 -0
- package/src/errors.ts +10 -1
- package/src/index.ts +9 -0
- package/src/resources.ts +401 -99
- package/src/transport.ts +21 -10
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -95,9 +95,15 @@ type QueryValue = string | number | boolean | null | undefined;
|
|
|
95
95
|
interface RequestOptions {
|
|
96
96
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
97
97
|
path: string;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Query parameters, as a plain object. Typed this way rather than with
|
|
100
|
+
* an index signature because TypeScript only gives an implicit index
|
|
101
|
+
* signature to type aliases, so a closed `*ListParams` interface would
|
|
102
|
+
* need a cast at every call site. {@link buildUrl} does the pruning:
|
|
103
|
+
* `undefined` and `null` are dropped, an array is joined with commas
|
|
104
|
+
* (the API's `expand=a,b` shape), everything else is stringified.
|
|
105
|
+
*/
|
|
106
|
+
query?: object;
|
|
101
107
|
body?: Record<string, unknown> | undefined;
|
|
102
108
|
idempotencyKey?: string | undefined;
|
|
103
109
|
extraHeaders?: Record<string, string>;
|
|
@@ -217,15 +223,23 @@ declare function paginate<T>(listFn: ListFn<T>, options?: PaginateOptions): Asyn
|
|
|
217
223
|
/**
|
|
218
224
|
* Cursor-pagination knobs shared by every `list()` method.
|
|
219
225
|
*
|
|
220
|
-
*
|
|
221
|
-
* (
|
|
222
|
-
* Transport
|
|
223
|
-
*
|
|
226
|
+
* Closed on purpose: there is no index signature, so a misspelled filter
|
|
227
|
+
* (`provisonal`) is a compile error instead of a query parameter the
|
|
228
|
+
* server ignores. The Transport takes `query` as a plain `object` and
|
|
229
|
+
* prunes/stringifies it, which is what lets these interfaces through
|
|
230
|
+
* without a cast.
|
|
224
231
|
*/
|
|
225
232
|
interface BaseListParams {
|
|
226
233
|
limit?: number;
|
|
227
234
|
starting_after?: string;
|
|
228
|
-
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* `?expand=` on a single-object GET. The relations a route accepts differ
|
|
238
|
+
* per resource and are listed on each `retrieve()`; an unknown one is a
|
|
239
|
+
* `400` naming the ones that work.
|
|
240
|
+
*/
|
|
241
|
+
interface ExpandOptions {
|
|
242
|
+
expand?: string[];
|
|
229
243
|
}
|
|
230
244
|
/**
|
|
231
245
|
* `prices.list` params. Adds the server-side `product_id` filter on top of
|
|
@@ -236,6 +250,40 @@ interface BaseListParams {
|
|
|
236
250
|
interface PricesListParams extends BaseListParams {
|
|
237
251
|
product_id?: string;
|
|
238
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* `payments.list` params. `customer_id` narrows to one customer's
|
|
255
|
+
* charges. Mandate verifications are never listed, so every row is a
|
|
256
|
+
* real purchase attempt; check `status` before treating one as revenue.
|
|
257
|
+
*/
|
|
258
|
+
interface PaymentsListParams extends BaseListParams {
|
|
259
|
+
customer_id?: string;
|
|
260
|
+
/** Expandable here: `customer`, `subscription`. */
|
|
261
|
+
expand?: string[];
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* `invoices.list` params. The three id filters each narrow to one row's
|
|
265
|
+
* worth of invoices: `payment_id` answers "which invoice did this charge
|
|
266
|
+
* produce".
|
|
267
|
+
*/
|
|
268
|
+
interface InvoicesListParams extends BaseListParams {
|
|
269
|
+
customer_id?: string;
|
|
270
|
+
subscription_id?: string;
|
|
271
|
+
payment_id?: string;
|
|
272
|
+
/** One of `draft`, `open`, `paid`, `void`, `uncollectible`. */
|
|
273
|
+
status?: string;
|
|
274
|
+
/** Expandable here: `customer`. */
|
|
275
|
+
expand?: string[];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `disputes.list` params. `status` takes a comma-separated list of `open`
|
|
279
|
+
* / `won`. There is no `lost`, because the provider gives no signal for
|
|
280
|
+
* one. `payment_id` matches subscription payments only, not one-off
|
|
281
|
+
* charges.
|
|
282
|
+
*/
|
|
283
|
+
interface DisputesListParams extends BaseListParams {
|
|
284
|
+
status?: string;
|
|
285
|
+
payment_id?: string;
|
|
286
|
+
}
|
|
239
287
|
/**
|
|
240
288
|
* `subscriptions.list` params. Both filters take a comma-separated
|
|
241
289
|
* list (`"active,past_due"`); an unrecognised value is rejected with
|
|
@@ -255,6 +303,8 @@ interface SubscriptionsListParams extends BaseListParams {
|
|
|
255
303
|
status?: string;
|
|
256
304
|
/** `auto_renew` | `paused` | `canceling` | `stopped`, CSV. */
|
|
257
305
|
renewal_state?: string;
|
|
306
|
+
/** Expandable here: `customer`, `price`, `refund_eligibility`. */
|
|
307
|
+
expand?: string[];
|
|
258
308
|
}
|
|
259
309
|
/** Optional idempotency knob carried by every mutating call. */
|
|
260
310
|
interface IdempotencyOptions {
|
|
@@ -264,9 +314,12 @@ interface IdempotencyOptions {
|
|
|
264
314
|
* process to converge on the same server-side result. */
|
|
265
315
|
idempotencyKey?: string;
|
|
266
316
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated Alias of {@link BaseListParams}, kept for callers that
|
|
319
|
+
* imported the older name. Reach for the resource-specific `*ListParams`
|
|
320
|
+
* (e.g. `EventsListParams`) instead.
|
|
321
|
+
*/
|
|
322
|
+
type ListParams = BaseListParams;
|
|
270
323
|
interface CreateCustomerParams extends IdempotencyOptions {
|
|
271
324
|
email?: string;
|
|
272
325
|
name?: string;
|
|
@@ -286,14 +339,25 @@ interface CustomerListParams extends BaseListParams {
|
|
|
286
339
|
* omitted for both.
|
|
287
340
|
*/
|
|
288
341
|
provisional?: boolean;
|
|
342
|
+
/** Expandable here: `stats`. Sent as `expand=a,b`. */
|
|
343
|
+
expand?: string[];
|
|
344
|
+
}
|
|
345
|
+
/** Query parameters accepted by `GET /v1/products`. */
|
|
346
|
+
interface ProductsListParams extends BaseListParams {
|
|
347
|
+
/** Expandable here: `prices`, `stats`. */
|
|
348
|
+
expand?: string[];
|
|
289
349
|
}
|
|
290
350
|
/**
|
|
291
351
|
* Body for `POST /v1/customers/{id}/vat_number`. The VAT number is
|
|
292
352
|
* sent through VIES server-side; the response carries
|
|
293
353
|
* `vat_number_validated` reflecting the outcome.
|
|
354
|
+
*
|
|
355
|
+
* `vat_number: null` **clears** the registration, and is sent as an
|
|
356
|
+
* explicit null rather than pruned: only `undefined` is dropped.
|
|
294
357
|
*/
|
|
295
358
|
interface SetCustomerVatNumberParams extends IdempotencyOptions {
|
|
296
|
-
vat_number: string;
|
|
359
|
+
vat_number: string | null;
|
|
360
|
+
/** VIES needs a country; send it when the customer has none yet. */
|
|
297
361
|
country_code?: string;
|
|
298
362
|
}
|
|
299
363
|
/**
|
|
@@ -336,13 +400,34 @@ interface UpdateProductParams extends IdempotencyOptions {
|
|
|
336
400
|
allow_promotion_codes?: boolean;
|
|
337
401
|
}
|
|
338
402
|
/**
|
|
339
|
-
* Body for `POST /v1/prices/{id}`.
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
403
|
+
* Body for `POST /v1/prices/{id}`. Every field is optional; omitted ones
|
|
404
|
+
* are left alone.
|
|
405
|
+
*
|
|
406
|
+
* The dividing line is what a field decides. `amount_cents`, `currency`,
|
|
407
|
+
* `interval` and `usage_type` decide **what a past charge was**, so they
|
|
408
|
+
* are fixed at creation and absent here, because subscriptions renew
|
|
409
|
+
* against a price by id and editing one would re-price live customers.
|
|
410
|
+
* Everything
|
|
411
|
+
* below decides **what happens next**, which is why it is editable:
|
|
412
|
+
* setting `refund_on_cancel` covers the customers already on the price.
|
|
413
|
+
*
|
|
414
|
+
* `tax_behavior` is the exception and moves one way. It can be set while
|
|
415
|
+
* the price is still `"unspecified"` and never changed again, because
|
|
416
|
+
* flipping it would restate whether tax was inside or on top of an amount
|
|
417
|
+
* somebody has already paid.
|
|
343
418
|
*/
|
|
344
419
|
interface UpdatePriceParams extends IdempotencyOptions {
|
|
345
|
-
|
|
420
|
+
/** `false` withdraws the price from sale, `true` puts it back. */
|
|
421
|
+
active?: boolean;
|
|
422
|
+
metadata?: Record<string, string>;
|
|
423
|
+
/** Settable once, while the price is still `"unspecified"`. */
|
|
424
|
+
tax_behavior?: "inclusive" | "exclusive";
|
|
425
|
+
/** Read when a checkout opens. At least one entry. */
|
|
426
|
+
payment_methods?: Array<"creditcard" | "directdebit" | "ideal" | "eps" | "applepay" | "paypal" | (string & {})>;
|
|
427
|
+
refund_on_cancel?: "none" | "full" | "prorated";
|
|
428
|
+
/** `0` disables refunds for that charge type; `N > 0` is an N-day window. */
|
|
429
|
+
refund_window_initial_days?: number;
|
|
430
|
+
refund_window_renewal_days?: number;
|
|
346
431
|
}
|
|
347
432
|
/**
|
|
348
433
|
* One band of a tiered price.
|
|
@@ -527,6 +612,14 @@ interface CreateCheckoutSessionParams extends IdempotencyOptions {
|
|
|
527
612
|
price_id: string;
|
|
528
613
|
success_url: string;
|
|
529
614
|
cancel_url: string;
|
|
615
|
+
/**
|
|
616
|
+
* The buyer's ISO-3166-1 alpha-2 country, when you already know it.
|
|
617
|
+
* Stored on the customer if they do not have one yet, which is what
|
|
618
|
+
* lets VAT apply to the very first charge. On the hosted flow the buyer
|
|
619
|
+
* only reaches a country-collecting page after the charge exists.
|
|
620
|
+
* Never overwrites a country the customer already has.
|
|
621
|
+
*/
|
|
622
|
+
country?: string;
|
|
530
623
|
/**
|
|
531
624
|
* Pin the Mollie payment method. `undefined` lets Mollie pick from
|
|
532
625
|
* the customer's available methods; when set, must be in the price's
|
|
@@ -649,6 +742,8 @@ interface UpdateWebhookEndpointParams extends IdempotencyOptions {
|
|
|
649
742
|
interface EventsListParams extends BaseListParams {
|
|
650
743
|
/** Server-side filter, e.g. `customer.created`. */
|
|
651
744
|
type?: string;
|
|
745
|
+
/** Expandable here: `customer`. `events.retrieve` accepts none. */
|
|
746
|
+
expand?: string[];
|
|
652
747
|
}
|
|
653
748
|
interface SetPortalBrandingParams extends IdempotencyOptions {
|
|
654
749
|
business_name?: string;
|
|
@@ -667,7 +762,12 @@ interface RotateProviderCredentialParams extends IdempotencyOptions {
|
|
|
667
762
|
}
|
|
668
763
|
interface CreateCouponParams extends IdempotencyOptions {
|
|
669
764
|
code: string;
|
|
670
|
-
|
|
765
|
+
/**
|
|
766
|
+
* `"percent"` reads `discount_value` as whole percent; `"fixed_cents"`
|
|
767
|
+
* reads it as minor units off the charge. Those are the only two the
|
|
768
|
+
* API accepts (`schemas/coupon.py`); anything else is a `422`.
|
|
769
|
+
*/
|
|
770
|
+
discount_type: "percent" | "fixed_cents" | (string & {});
|
|
671
771
|
discount_value: number;
|
|
672
772
|
duration: "once" | "repeating" | "forever" | (string & {});
|
|
673
773
|
duration_in_months?: number;
|
|
@@ -735,6 +835,40 @@ interface CreditNotesListParams extends BaseListParams {
|
|
|
735
835
|
invoice_id?: string;
|
|
736
836
|
customer_id?: string;
|
|
737
837
|
}
|
|
838
|
+
/**
|
|
839
|
+
* Body for `POST /v1/tenant/billing_profile`: the seller identity that
|
|
840
|
+
* VAT is decided against and that an invoice prints.
|
|
841
|
+
*
|
|
842
|
+
* `country_code` is required on every call: there is nothing to leave
|
|
843
|
+
* alone about a jurisdiction. Every other field is partial-update: omit
|
|
844
|
+
* it to leave the stored value alone, or pass an explicit `null` to
|
|
845
|
+
* clear it, because ceasing to be VAT registered (or moving office) is a
|
|
846
|
+
* real event.
|
|
847
|
+
*/
|
|
848
|
+
interface SetTenantBillingProfileParams extends IdempotencyOptions {
|
|
849
|
+
/** ISO-3166-1 alpha-2, e.g. `"NL"`. */
|
|
850
|
+
country_code: string;
|
|
851
|
+
/** Your own EU VAT registration, or `null` to clear it. */
|
|
852
|
+
vat_id?: string | null;
|
|
853
|
+
address_line1?: string | null;
|
|
854
|
+
address_line2?: string | null;
|
|
855
|
+
postal_code?: string | null;
|
|
856
|
+
city?: string | null;
|
|
857
|
+
registration_number?: string | null;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Body for `POST /v1/api_keys`. The full key is returned **once**, on the
|
|
861
|
+
* create response, and is never retrievable again.
|
|
862
|
+
*/
|
|
863
|
+
interface CreateApiKeyParams extends IdempotencyOptions {
|
|
864
|
+
/** Human label, so a key can be identified before it is revoked. */
|
|
865
|
+
label?: string;
|
|
866
|
+
/**
|
|
867
|
+
* Narrow what the key may do. Omit to inherit the calling key's own
|
|
868
|
+
* scopes; a key can never grant more than it holds.
|
|
869
|
+
*/
|
|
870
|
+
scopes?: string[];
|
|
871
|
+
}
|
|
738
872
|
/** `invoices.void` params. `reason` is recorded on the audit row only. */
|
|
739
873
|
interface VoidInvoiceParams extends IdempotencyOptions {
|
|
740
874
|
reason?: string;
|
|
@@ -742,6 +876,12 @@ interface VoidInvoiceParams extends IdempotencyOptions {
|
|
|
742
876
|
interface CreateBillingPortalSessionParams extends IdempotencyOptions {
|
|
743
877
|
subscription_id: string;
|
|
744
878
|
return_url: string;
|
|
879
|
+
/**
|
|
880
|
+
* Also email the portal link to the subscription's customer, at the
|
|
881
|
+
* address on their record, as a tenant-branded message. Defaults to
|
|
882
|
+
* `false`: without it you distribute the returned `url` yourself.
|
|
883
|
+
*/
|
|
884
|
+
deliver_email?: boolean;
|
|
745
885
|
}
|
|
746
886
|
/**
|
|
747
887
|
* Shared transport wrapper. Resources subclass this so each method
|
|
@@ -752,7 +892,13 @@ interface CreateBillingPortalSessionParams extends IdempotencyOptions {
|
|
|
752
892
|
declare abstract class BaseResource {
|
|
753
893
|
protected readonly t: Transport;
|
|
754
894
|
constructor(t: Transport);
|
|
755
|
-
|
|
895
|
+
/**
|
|
896
|
+
* `query` is a plain object rather than an index-signature type: TypeScript
|
|
897
|
+
* only gives an implicit index signature to type *aliases*, so a closed
|
|
898
|
+
* `*ListParams` interface would otherwise need a cast at every call site.
|
|
899
|
+
* The transport prunes `undefined`/`null` and joins arrays with commas.
|
|
900
|
+
*/
|
|
901
|
+
protected get<T>(path: string, query?: object): Promise<T>;
|
|
756
902
|
protected post<T, P extends IdempotencyOptions>(path: string, params: P): Promise<T>;
|
|
757
903
|
/** POST with no body, used by lifecycle verbs (cancel, resume, revoke ...). */
|
|
758
904
|
protected postEmpty<T>(path: string, params?: IdempotencyOptions): Promise<T>;
|
|
@@ -812,7 +958,8 @@ declare class Customers extends BaseResource {
|
|
|
812
958
|
declare class Products extends BaseResource {
|
|
813
959
|
/** Create a catalog Product, then attach one or more Prices to it. */
|
|
814
960
|
create<T = unknown>(params: CreateProductParams): Promise<T>;
|
|
815
|
-
|
|
961
|
+
/** Expandable: `prices` (every price on the product), `stats`. */
|
|
962
|
+
retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
|
|
816
963
|
/**
|
|
817
964
|
* Patch mutable Product fields, or archive it with `active: false`.
|
|
818
965
|
*
|
|
@@ -823,7 +970,7 @@ declare class Products extends BaseResource {
|
|
|
823
970
|
* `active: true` un-archives.
|
|
824
971
|
*/
|
|
825
972
|
update<T = unknown>(id: string, params: UpdateProductParams): Promise<T>;
|
|
826
|
-
list<T = unknown>(params?:
|
|
973
|
+
list<T = unknown>(params?: ProductsListParams): Promise<ListResponseEnvelope<T>>;
|
|
827
974
|
iter<T = unknown>(options?: {
|
|
828
975
|
pageSize?: number;
|
|
829
976
|
}): AsyncIterableIterator<T>;
|
|
@@ -887,7 +1034,8 @@ declare class OneShotPayments extends BaseResource {
|
|
|
887
1034
|
retrieve<T = unknown>(id: string): Promise<T>;
|
|
888
1035
|
}
|
|
889
1036
|
declare class Subscriptions extends BaseResource {
|
|
890
|
-
|
|
1037
|
+
/** Expandable: `customer`, `price`, `refund_eligibility`. */
|
|
1038
|
+
retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
|
|
891
1039
|
/**
|
|
892
1040
|
* List subscriptions, newest first, optionally filtered.
|
|
893
1041
|
*
|
|
@@ -996,12 +1144,22 @@ declare class Refunds extends BaseResource {
|
|
|
996
1144
|
*/
|
|
997
1145
|
declare class Disputes extends BaseResource {
|
|
998
1146
|
retrieve<T = unknown>(id: string): Promise<T>;
|
|
999
|
-
list<T = unknown>(params?:
|
|
1147
|
+
list<T = unknown>(params?: DisputesListParams): Promise<ListResponseEnvelope<T>>;
|
|
1000
1148
|
iter<T = unknown>(options?: {
|
|
1001
1149
|
pageSize?: number;
|
|
1150
|
+
status?: string;
|
|
1151
|
+
payment_id?: string;
|
|
1002
1152
|
}): AsyncIterableIterator<T>;
|
|
1003
1153
|
}
|
|
1004
1154
|
declare class WebhookEndpoints extends BaseResource {
|
|
1155
|
+
/**
|
|
1156
|
+
* Every event type this deployment can deliver, plus the wildcard.
|
|
1157
|
+
*
|
|
1158
|
+
* `enabled_events` rejects anything not on this list, so read it rather
|
|
1159
|
+
* than hard-coding a set: a name that is not on it fails at
|
|
1160
|
+
* registration and leaves you with an endpoint that never fires.
|
|
1161
|
+
*/
|
|
1162
|
+
listEventTypes<T = unknown>(): Promise<T>;
|
|
1005
1163
|
create<T = unknown>(params: CreateWebhookEndpointParams): Promise<T>;
|
|
1006
1164
|
retrieve<T = unknown>(id: string): Promise<T>;
|
|
1007
1165
|
/**
|
|
@@ -1085,6 +1243,40 @@ declare class Events extends BaseResource {
|
|
|
1085
1243
|
declare class Tenant extends BaseResource {
|
|
1086
1244
|
/** Cached Mollie profile shape (enabled methods, country, currency). */
|
|
1087
1245
|
capabilities<T = unknown>(): Promise<T>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Your registered country and VAT number: what your customers' VAT is
|
|
1248
|
+
* decided against.
|
|
1249
|
+
*
|
|
1250
|
+
* `country_code` is what you have stored and can be `null`;
|
|
1251
|
+
* `effective_country_code` is what the next charge will really use.
|
|
1252
|
+
* The two differ only when you have stored nothing, which is exactly
|
|
1253
|
+
* the case worth spotting before a first live payment.
|
|
1254
|
+
*/
|
|
1255
|
+
billingProfile<T = unknown>(): Promise<T>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Set the seller identity. `country_code` is required on every call;
|
|
1258
|
+
* every other field is partial-update, with an explicit `null` to
|
|
1259
|
+
* clear. Changes take effect on the next charge only. Tax is written
|
|
1260
|
+
* onto a payment and its invoice before money moves, and nothing goes
|
|
1261
|
+
* back and recalculates it.
|
|
1262
|
+
*/
|
|
1263
|
+
setBillingProfile<T = unknown>(params: SetTenantBillingProfileParams): Promise<T>;
|
|
1264
|
+
/**
|
|
1265
|
+
* Download everything in the account as one JSON document, as raw bytes.
|
|
1266
|
+
*
|
|
1267
|
+
* ```ts
|
|
1268
|
+
* await writeFile("export.json", Buffer.from(await client.tenant.export()));
|
|
1269
|
+
* ```
|
|
1270
|
+
*
|
|
1271
|
+
* The GDPR Article 20 portability route, and the way to take a backup.
|
|
1272
|
+
* It is `application/json` streamed inline, with no redirect, and each
|
|
1273
|
+
* record has the same shape its `GET` route returns, with
|
|
1274
|
+
* `billkit_export_version` naming the shape. It can be large, so write
|
|
1275
|
+
* it to a file rather than holding it in memory. Test and live data
|
|
1276
|
+
* export separately: you get whichever mode the key belongs to. The
|
|
1277
|
+
* access is recorded in your audit log.
|
|
1278
|
+
*/
|
|
1279
|
+
export(): Promise<ArrayBuffer>;
|
|
1088
1280
|
/** Current portal branding row (business name, theme, capability flags). */
|
|
1089
1281
|
portalBranding<T = unknown>(): Promise<T>;
|
|
1090
1282
|
/**
|
|
@@ -1153,7 +1345,8 @@ declare class TaxRates extends BaseResource {
|
|
|
1153
1345
|
* {@link Invoices.retrievePdf}.
|
|
1154
1346
|
*/
|
|
1155
1347
|
declare class Invoices extends BaseResource {
|
|
1156
|
-
|
|
1348
|
+
/** Expandable: `customer`. */
|
|
1349
|
+
retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
|
|
1157
1350
|
/**
|
|
1158
1351
|
* Download the rendered invoice PDF as raw bytes.
|
|
1159
1352
|
*
|
|
@@ -1173,9 +1366,24 @@ declare class Invoices extends BaseResource {
|
|
|
1173
1366
|
* structured invoice for tenants who render their own.
|
|
1174
1367
|
*/
|
|
1175
1368
|
retrievePdf(id: string): Promise<ArrayBuffer>;
|
|
1176
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* Send the customer their invoice again.
|
|
1371
|
+
*
|
|
1372
|
+
* The same tenant-branded "your invoice is ready" email, with a fresh
|
|
1373
|
+
* portal link, because the one in the original may have expired. It
|
|
1374
|
+
* goes to the address captured **on the invoice**, not the customer's
|
|
1375
|
+
* current one: this is a copy of a document that was issued to
|
|
1376
|
+
* somebody. An invoice with no address on file is a
|
|
1377
|
+
* `InvalidRequestError` rather than a send that did not happen.
|
|
1378
|
+
*/
|
|
1379
|
+
sendEmail<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
|
|
1380
|
+
list<T = unknown>(params?: InvoicesListParams): Promise<ListResponseEnvelope<T>>;
|
|
1177
1381
|
iter<T = unknown>(options?: {
|
|
1178
1382
|
pageSize?: number;
|
|
1383
|
+
customer_id?: string;
|
|
1384
|
+
subscription_id?: string;
|
|
1385
|
+
payment_id?: string;
|
|
1386
|
+
status?: string;
|
|
1179
1387
|
}): AsyncIterableIterator<T>;
|
|
1180
1388
|
/**
|
|
1181
1389
|
* Void an invoice: state that the sale was never owed.
|
|
@@ -1245,10 +1453,23 @@ declare class AuditLogs extends BaseResource {
|
|
|
1245
1453
|
* refunds and disputes are separate flows.
|
|
1246
1454
|
*/
|
|
1247
1455
|
declare class Payments extends BaseResource {
|
|
1248
|
-
|
|
1249
|
-
|
|
1456
|
+
/** Expandable: `customer`, `subscription`. */
|
|
1457
|
+
retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Fetch the provider's own record of this charge, live.
|
|
1460
|
+
*
|
|
1461
|
+
* Reads Mollie at request time rather than a stored copy, so it carries
|
|
1462
|
+
* what BillKit deliberately does not keep: the card BIN, the iDEAL
|
|
1463
|
+
* bank, the provider's own status string. Reading live means it can
|
|
1464
|
+
* fail: a provider outage or a charge old enough to have aged out
|
|
1465
|
+
* answers `200` with `available: false` and a short reason, so render
|
|
1466
|
+
* the rest of the page regardless.
|
|
1467
|
+
*/
|
|
1468
|
+
retrieveProvider<T = unknown>(id: string): Promise<T>;
|
|
1469
|
+
list<T = unknown>(params?: PaymentsListParams): Promise<ListResponseEnvelope<T>>;
|
|
1250
1470
|
iter<T = unknown>(options?: {
|
|
1251
1471
|
pageSize?: number;
|
|
1472
|
+
customer_id?: string;
|
|
1252
1473
|
}): AsyncIterableIterator<T>;
|
|
1253
1474
|
}
|
|
1254
1475
|
/**
|
|
@@ -1264,6 +1485,38 @@ declare class BillingPortalSessions extends BaseResource {
|
|
|
1264
1485
|
/** Kill an in-the-wild portal session. Idempotent. */
|
|
1265
1486
|
revoke<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
|
|
1266
1487
|
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Issue, inspect and revoke API keys.
|
|
1490
|
+
*
|
|
1491
|
+
* A key is issued in the same mode as the key that created it, so a test
|
|
1492
|
+
* key can only mint test keys, and it can never grant scopes it does not
|
|
1493
|
+
* hold itself. The secret is returned **once**, on
|
|
1494
|
+
* {@link ApiKeys.create}; every later read carries only the prefix.
|
|
1495
|
+
*/
|
|
1496
|
+
declare class ApiKeys extends BaseResource {
|
|
1497
|
+
/**
|
|
1498
|
+
* Issue a new key. The response's `secret` is the only time the full
|
|
1499
|
+
* key exists outside the caller's own storage, so record it now.
|
|
1500
|
+
*/
|
|
1501
|
+
create<T = unknown>(params?: CreateApiKeyParams): Promise<T>;
|
|
1502
|
+
/**
|
|
1503
|
+
* One key's metadata: prefix, label, scopes, `revoked_at`, and
|
|
1504
|
+
* `last_used_at`, which is the field to read before revoking one.
|
|
1505
|
+
*/
|
|
1506
|
+
retrieve<T = unknown>(id: string): Promise<T>;
|
|
1507
|
+
/**
|
|
1508
|
+
* Revoke a key so it stops working. Immediate and irreversible; issue a
|
|
1509
|
+
* new key instead. Revoking an already-revoked key returns it
|
|
1510
|
+
* unchanged, so a retry is safe, and a key may revoke itself, which is
|
|
1511
|
+
* what you want when the leaked key is the one you are calling with.
|
|
1512
|
+
*/
|
|
1513
|
+
revoke<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
|
|
1514
|
+
/** List keys, newest first. Revoked ones are included; check `revoked_at`. */
|
|
1515
|
+
list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
|
|
1516
|
+
iter<T = unknown>(options?: {
|
|
1517
|
+
pageSize?: number;
|
|
1518
|
+
}): AsyncIterableIterator<T>;
|
|
1519
|
+
}
|
|
1267
1520
|
|
|
1268
1521
|
/**
|
|
1269
1522
|
* Top-level BillKit client.
|
|
@@ -1279,6 +1532,7 @@ interface BillKitOptions extends Omit<TransportConfig, "apiKey"> {
|
|
|
1279
1532
|
apiKey?: string;
|
|
1280
1533
|
}
|
|
1281
1534
|
declare class BillKit {
|
|
1535
|
+
readonly apiKeys: ApiKeys;
|
|
1282
1536
|
readonly customers: Customers;
|
|
1283
1537
|
readonly products: Products;
|
|
1284
1538
|
readonly prices: Prices;
|
|
@@ -1307,6 +1561,12 @@ interface BillKitErrorOptions {
|
|
|
1307
1561
|
statusCode?: number | undefined;
|
|
1308
1562
|
requestId?: string | undefined;
|
|
1309
1563
|
rawBody?: unknown;
|
|
1564
|
+
/**
|
|
1565
|
+
* The underlying error, forwarded to `Error`'s own `cause`. Set on
|
|
1566
|
+
* `APIConnectionError` so the runtime's reason for a failed fetch
|
|
1567
|
+
* (`ECONNREFUSED`, a TLS failure, an abort) survives the mapping.
|
|
1568
|
+
*/
|
|
1569
|
+
cause?: unknown;
|
|
1310
1570
|
}
|
|
1311
1571
|
declare class BillKitError extends Error {
|
|
1312
1572
|
name: string;
|
|
@@ -1350,7 +1610,7 @@ declare class RateLimitError extends BillKitError {
|
|
|
1350
1610
|
});
|
|
1351
1611
|
}
|
|
1352
1612
|
|
|
1353
|
-
declare const VERSION = "0.
|
|
1613
|
+
declare const VERSION = "0.7.0";
|
|
1354
1614
|
|
|
1355
1615
|
/**
|
|
1356
1616
|
* Verify `BillKit-Signature: t=<unix>,v1=<hex>` headers.
|
|
@@ -1382,4 +1642,4 @@ interface VerifyWebhookOptions {
|
|
|
1382
1642
|
}
|
|
1383
1643
|
declare function verifyWebhookSignature<T = unknown>(options: VerifyWebhookOptions): Promise<T>;
|
|
1384
1644
|
|
|
1385
|
-
export { APIConnectionError, APIError, type AuditLogsListParams, AuthenticationError, type BaseListParams, BillKit, BillKitError, type BillKitLogger, type BillKitOptions, ConflictError, type CreateBillingPortalSessionParams, type CreateCheckoutSessionParams, type CreateCouponParams, type CreateCustomerParams, type CreateOneShotPaymentParams, type CreatePriceParams, type CreateProductParams, type CreateRefundParams, type CreateTaxRateParams, type CreateUsageRecordParams, type CreateWebhookEndpointParams, type CreditNotesListParams, type CustomerListParams, DEFAULT_RETRY_POLICY, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type EventsListParams, type IdempotencyOptions, InvalidRequestError, type ListParams, type ListResponseEnvelope, type LogContext, NOOP_LOGGER, type PaginateOptions, PermissionError, type PriceTier, type PricesListParams, RateLimitError, ResourceMissingError, type RetryPolicy, type RotateProviderCredentialParams, ServerError, type SetPortalBrandingParams, type SubscriptionsListParams, type UpdateCouponParams, type UpdateCustomerParams, type UpdateProductParams, type UpdateTaxRateParams, type UpdateWebhookEndpointParams, type UsageRecordsListParams, VERSION, type ValidateCouponParams, type VerifyWebhookOptions, type VoidInvoiceParams, WebhookVerificationError, paginate, verifyWebhookSignature };
|
|
1645
|
+
export { APIConnectionError, APIError, type AuditLogsListParams, AuthenticationError, type BaseListParams, BillKit, BillKitError, type BillKitLogger, type BillKitOptions, ConflictError, type CreateApiKeyParams, type CreateBillingPortalSessionParams, type CreateCheckoutSessionParams, type CreateCouponParams, type CreateCustomerParams, type CreateOneShotPaymentParams, type CreatePriceParams, type CreateProductParams, type CreateRefundParams, type CreateTaxRateParams, type CreateUsageRecordParams, type CreateWebhookEndpointParams, type CreditNotesListParams, type CustomerListParams, DEFAULT_RETRY_POLICY, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type DisputesListParams, type EventsListParams, type ExpandOptions, type IdempotencyOptions, InvalidRequestError, type InvoicesListParams, type ListParams, type ListResponseEnvelope, type LogContext, NOOP_LOGGER, type PaginateOptions, type PaymentsListParams, PermissionError, type PriceTier, type PricesListParams, type ProductsListParams, RateLimitError, ResourceMissingError, type RetryPolicy, type RotateProviderCredentialParams, ServerError, type SetCustomerVatNumberParams, type SetPortalBrandingParams, type SetTenantBillingProfileParams, type SubscriptionsListParams, type UpdateCouponParams, type UpdateCustomerParams, type UpdatePriceParams, type UpdateProductParams, type UpdateTaxRateParams, type UpdateWebhookEndpointParams, type UsageRecordsListParams, VERSION, type ValidateCouponParams, type VerifyWebhookOptions, type VoidInvoiceParams, WebhookVerificationError, paginate, verifyWebhookSignature };
|