@billkit-eu/sdk 0.5.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/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
- query?: {
99
- readonly [key: string]: QueryValue;
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
- * The index signature is what lets a resource-specific extension
221
- * (e.g. `EventsListParams` adds `type?: string`) flow through the
222
- * Transport's `query` shape without a cast. Excess fields are
223
- * tolerated; `undefined` values are pruned before serialisation.
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
- readonly [key: string]: QueryValue;
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
- type ListParams = BaseListParams & {
268
- readonly [key: string]: QueryValue;
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}`. `active` is the only field a price
340
- * accepts, and it moves both ways: `false` withdraws the price from sale,
341
- * `true` puts it back. The amount, currency and interval are fixed at
342
- * creation, so neither direction changes what anyone was charged.
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
- active: boolean;
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.
@@ -420,7 +505,7 @@ interface CreatePriceParams extends IdempotencyOptions {
420
505
  metadata?: Record<string, string>;
421
506
  trial_days?: number;
422
507
  trial_verification_cents?: number;
423
- payment_methods?: Array<"creditcard" | "directdebit" | "ideal" | "applepay" | (string & {})>;
508
+ payment_methods?: Array<"creditcard" | "directdebit" | "ideal" | "eps" | "applepay" | "paypal" | (string & {})>;
424
509
  /**
425
510
  * What a cancellation refunds without being asked. `"none"` (the default)
426
511
  * nothing; `"full"` the whole last charge; `"prorated"` the unused part
@@ -527,12 +612,26 @@ 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
533
626
  * `payment_methods` allowlist.
627
+ *
628
+ * Subscription-starting only, so this is deliberately NARROWER than the
629
+ * one-shot union: `bancontact` and `banktransfer` are absent because
630
+ * neither can mint the mandate a renewal needs. Mollie refuses the
631
+ * latter outright with "The payment method does not support sequence
632
+ * type".
534
633
  */
535
- method?: "creditcard" | "directdebit" | "ideal" | "applepay" | (string & {});
634
+ method?: "creditcard" | "directdebit" | "ideal" | "eps" | "applepay" | "paypal" | (string & {});
536
635
  /** Optional coupon code applied at checkout; atomically claimed. */
537
636
  coupon_code?: string;
538
637
  /**
@@ -588,8 +687,12 @@ interface CreateOneShotPaymentParams extends IdempotencyOptions {
588
687
  /**
589
688
  * Concrete Mollie method to charge with. Required, because a one-shot commits
590
689
  * up front). Validated against the tenant's capability allowlist for
591
- * `currency`; one-off methods like `bancontact`/`eps` are allowed here
592
- * even though they can't back a subscription.
690
+ * `currency`; one-off methods like `bancontact` and `banktransfer` are
691
+ * allowed here even though they can't back a subscription.
692
+ *
693
+ * `banktransfer` settles in DAYS, not seconds: the payer is handed bank
694
+ * details and Mollie holds the payment `open` for about a fortnight. Expect
695
+ * `one_shot_payment.paid` long after the call returns.
593
696
  *
594
697
  * `giropay` was removed: the scheme shut down at the end of 2024 and the
595
698
  * server now 422s it. The `(string & {})` tail keeps this open on
@@ -597,7 +700,7 @@ interface CreateOneShotPaymentParams extends IdempotencyOptions {
597
700
  * *request* type the server validates, so an SDK that lags a newly-added
598
701
  * method should not be the thing that blocks the call.
599
702
  */
600
- method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | "applepay" | (string & {});
703
+ method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | "applepay" | "paypal" | "banktransfer" | (string & {});
601
704
  /** Where Mollie returns the payer after the hosted checkout. */
602
705
  success_url: string;
603
706
  /** Optional page for an abandoned/cancelled payment. */
@@ -639,6 +742,8 @@ interface UpdateWebhookEndpointParams extends IdempotencyOptions {
639
742
  interface EventsListParams extends BaseListParams {
640
743
  /** Server-side filter, e.g. `customer.created`. */
641
744
  type?: string;
745
+ /** Expandable here: `customer`. `events.retrieve` accepts none. */
746
+ expand?: string[];
642
747
  }
643
748
  interface SetPortalBrandingParams extends IdempotencyOptions {
644
749
  business_name?: string;
@@ -657,7 +762,12 @@ interface RotateProviderCredentialParams extends IdempotencyOptions {
657
762
  }
658
763
  interface CreateCouponParams extends IdempotencyOptions {
659
764
  code: string;
660
- discount_type: "percentage" | "amount" | (string & {});
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 & {});
661
771
  discount_value: number;
662
772
  duration: "once" | "repeating" | "forever" | (string & {});
663
773
  duration_in_months?: number;
@@ -700,9 +810,18 @@ interface UpdateTaxRateParams extends IdempotencyOptions {
700
810
  inclusive?: boolean;
701
811
  active?: boolean;
702
812
  }
813
+ /**
814
+ * `auditLogs.list` params. All four filters match exactly and combine.
815
+ *
816
+ * `resource_type` narrows to a kind (`"customer"`, `"price"`);
817
+ * `resource_id` narrows to one row, which is the "everything that ever
818
+ * happened to this customer" question an audit log mostly exists for.
819
+ * Pair them or use `resource_id` alone — ids are already unique.
820
+ */
703
821
  interface AuditLogsListParams extends BaseListParams {
704
822
  action?: string;
705
823
  resource_type?: string;
824
+ resource_id?: string;
706
825
  actor_id?: string;
707
826
  }
708
827
  /**
@@ -716,6 +835,40 @@ interface CreditNotesListParams extends BaseListParams {
716
835
  invoice_id?: string;
717
836
  customer_id?: string;
718
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
+ }
719
872
  /** `invoices.void` params. `reason` is recorded on the audit row only. */
720
873
  interface VoidInvoiceParams extends IdempotencyOptions {
721
874
  reason?: string;
@@ -723,6 +876,12 @@ interface VoidInvoiceParams extends IdempotencyOptions {
723
876
  interface CreateBillingPortalSessionParams extends IdempotencyOptions {
724
877
  subscription_id: string;
725
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;
726
885
  }
727
886
  /**
728
887
  * Shared transport wrapper. Resources subclass this so each method
@@ -733,7 +892,13 @@ interface CreateBillingPortalSessionParams extends IdempotencyOptions {
733
892
  declare abstract class BaseResource {
734
893
  protected readonly t: Transport;
735
894
  constructor(t: Transport);
736
- protected get<T>(path: string, query?: BaseListParams & Record<string, QueryValue>): Promise<T>;
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>;
737
902
  protected post<T, P extends IdempotencyOptions>(path: string, params: P): Promise<T>;
738
903
  /** POST with no body, used by lifecycle verbs (cancel, resume, revoke ...). */
739
904
  protected postEmpty<T>(path: string, params?: IdempotencyOptions): Promise<T>;
@@ -793,7 +958,8 @@ declare class Customers extends BaseResource {
793
958
  declare class Products extends BaseResource {
794
959
  /** Create a catalog Product, then attach one or more Prices to it. */
795
960
  create<T = unknown>(params: CreateProductParams): Promise<T>;
796
- retrieve<T = unknown>(id: string): Promise<T>;
961
+ /** Expandable: `prices` (every price on the product), `stats`. */
962
+ retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
797
963
  /**
798
964
  * Patch mutable Product fields, or archive it with `active: false`.
799
965
  *
@@ -804,7 +970,7 @@ declare class Products extends BaseResource {
804
970
  * `active: true` un-archives.
805
971
  */
806
972
  update<T = unknown>(id: string, params: UpdateProductParams): Promise<T>;
807
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
973
+ list<T = unknown>(params?: ProductsListParams): Promise<ListResponseEnvelope<T>>;
808
974
  iter<T = unknown>(options?: {
809
975
  pageSize?: number;
810
976
  }): AsyncIterableIterator<T>;
@@ -868,7 +1034,8 @@ declare class OneShotPayments extends BaseResource {
868
1034
  retrieve<T = unknown>(id: string): Promise<T>;
869
1035
  }
870
1036
  declare class Subscriptions extends BaseResource {
871
- retrieve<T = unknown>(id: string): Promise<T>;
1037
+ /** Expandable: `customer`, `price`, `refund_eligibility`. */
1038
+ retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
872
1039
  /**
873
1040
  * List subscriptions, newest first, optionally filtered.
874
1041
  *
@@ -977,12 +1144,22 @@ declare class Refunds extends BaseResource {
977
1144
  */
978
1145
  declare class Disputes extends BaseResource {
979
1146
  retrieve<T = unknown>(id: string): Promise<T>;
980
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
1147
+ list<T = unknown>(params?: DisputesListParams): Promise<ListResponseEnvelope<T>>;
981
1148
  iter<T = unknown>(options?: {
982
1149
  pageSize?: number;
1150
+ status?: string;
1151
+ payment_id?: string;
983
1152
  }): AsyncIterableIterator<T>;
984
1153
  }
985
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>;
986
1163
  create<T = unknown>(params: CreateWebhookEndpointParams): Promise<T>;
987
1164
  retrieve<T = unknown>(id: string): Promise<T>;
988
1165
  /**
@@ -1066,6 +1243,40 @@ declare class Events extends BaseResource {
1066
1243
  declare class Tenant extends BaseResource {
1067
1244
  /** Cached Mollie profile shape (enabled methods, country, currency). */
1068
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>;
1069
1280
  /** Current portal branding row (business name, theme, capability flags). */
1070
1281
  portalBranding<T = unknown>(): Promise<T>;
1071
1282
  /**
@@ -1134,7 +1345,8 @@ declare class TaxRates extends BaseResource {
1134
1345
  * {@link Invoices.retrievePdf}.
1135
1346
  */
1136
1347
  declare class Invoices extends BaseResource {
1137
- retrieve<T = unknown>(id: string): Promise<T>;
1348
+ /** Expandable: `customer`. */
1349
+ retrieve<T = unknown>(id: string, options?: ExpandOptions): Promise<T>;
1138
1350
  /**
1139
1351
  * Download the rendered invoice PDF as raw bytes.
1140
1352
  *
@@ -1154,9 +1366,24 @@ declare class Invoices extends BaseResource {
1154
1366
  * structured invoice for tenants who render their own.
1155
1367
  */
1156
1368
  retrievePdf(id: string): Promise<ArrayBuffer>;
1157
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
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>>;
1158
1381
  iter<T = unknown>(options?: {
1159
1382
  pageSize?: number;
1383
+ customer_id?: string;
1384
+ subscription_id?: string;
1385
+ payment_id?: string;
1386
+ status?: string;
1160
1387
  }): AsyncIterableIterator<T>;
1161
1388
  /**
1162
1389
  * Void an invoice: state that the sale was never owed.
@@ -1214,6 +1441,7 @@ declare class AuditLogs extends BaseResource {
1214
1441
  pageSize?: number;
1215
1442
  action?: string;
1216
1443
  resource_type?: string;
1444
+ resource_id?: string;
1217
1445
  actor_id?: string;
1218
1446
  }): AsyncIterableIterator<T>;
1219
1447
  }
@@ -1225,10 +1453,23 @@ declare class AuditLogs extends BaseResource {
1225
1453
  * refunds and disputes are separate flows.
1226
1454
  */
1227
1455
  declare class Payments extends BaseResource {
1228
- retrieve<T = unknown>(id: string): Promise<T>;
1229
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
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>>;
1230
1470
  iter<T = unknown>(options?: {
1231
1471
  pageSize?: number;
1472
+ customer_id?: string;
1232
1473
  }): AsyncIterableIterator<T>;
1233
1474
  }
1234
1475
  /**
@@ -1244,6 +1485,38 @@ declare class BillingPortalSessions extends BaseResource {
1244
1485
  /** Kill an in-the-wild portal session. Idempotent. */
1245
1486
  revoke<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
1246
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
+ }
1247
1520
 
1248
1521
  /**
1249
1522
  * Top-level BillKit client.
@@ -1259,6 +1532,7 @@ interface BillKitOptions extends Omit<TransportConfig, "apiKey"> {
1259
1532
  apiKey?: string;
1260
1533
  }
1261
1534
  declare class BillKit {
1535
+ readonly apiKeys: ApiKeys;
1262
1536
  readonly customers: Customers;
1263
1537
  readonly products: Products;
1264
1538
  readonly prices: Prices;
@@ -1287,6 +1561,12 @@ interface BillKitErrorOptions {
1287
1561
  statusCode?: number | undefined;
1288
1562
  requestId?: string | undefined;
1289
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;
1290
1570
  }
1291
1571
  declare class BillKitError extends Error {
1292
1572
  name: string;
@@ -1330,7 +1610,7 @@ declare class RateLimitError extends BillKitError {
1330
1610
  });
1331
1611
  }
1332
1612
 
1333
- declare const VERSION = "0.5.0";
1613
+ declare const VERSION = "0.7.0";
1334
1614
 
1335
1615
  /**
1336
1616
  * Verify `BillKit-Signature: t=<unix>,v1=<hex>` headers.
@@ -1362,4 +1642,4 @@ interface VerifyWebhookOptions {
1362
1642
  }
1363
1643
  declare function verifyWebhookSignature<T = unknown>(options: VerifyWebhookOptions): Promise<T>;
1364
1644
 
1365
- 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 };