@billkit-eu/sdk 0.2.1 → 0.3.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.cts CHANGED
@@ -279,6 +279,14 @@ interface UpdateCustomerParams extends IdempotencyOptions {
279
279
  country_code?: string;
280
280
  metadata?: Record<string, string>;
281
281
  }
282
+ /** Query parameters accepted by `GET /v1/customers`. */
283
+ interface CustomerListParams extends BaseListParams {
284
+ /**
285
+ * `false` for customers who have paid, `true` for abandoned checkouts,
286
+ * omitted for both.
287
+ */
288
+ provisional?: boolean;
289
+ }
282
290
  /**
283
291
  * Body for `POST /v1/customers/{id}/vat_number`. The VAT number is
284
292
  * sent through VIES server-side; the response carries
@@ -306,6 +314,16 @@ interface CreateProductParams extends IdempotencyOptions {
306
314
  marketing_features?: string[];
307
315
  /** Small string metadata map echoed back on the Product object. */
308
316
  metadata?: Record<string, string>;
317
+ /**
318
+ * Let a *buyer* type a coupon code at the embedded checkout for this
319
+ * product. Defaults to `false`. A coupon you apply yourself by passing
320
+ * `coupon_code` when you create a Checkout Session is unaffected — that
321
+ * is you discounting your own sale, and it has never needed this flag.
322
+ *
323
+ * The code is redeemed only once the payment settles, so a shopper who
324
+ * tries a single-use code and abandons the checkout does not use it up.
325
+ */
326
+ allow_promotion_codes?: boolean;
309
327
  }
310
328
  interface UpdateProductParams extends IdempotencyOptions {
311
329
  name?: string;
@@ -314,6 +332,8 @@ interface UpdateProductParams extends IdempotencyOptions {
314
332
  metadata?: Record<string, string>;
315
333
  /** Set false to stop selling a product without deleting history. */
316
334
  active?: boolean;
335
+ /** See {@link CreateProductParams.allow_promotion_codes}. */
336
+ allow_promotion_codes?: boolean;
317
337
  }
318
338
  /**
319
339
  * Body for `POST /v1/prices/{id}`. `active` is the only field a price
@@ -324,16 +344,93 @@ interface UpdateProductParams extends IdempotencyOptions {
324
344
  interface UpdatePriceParams extends IdempotencyOptions {
325
345
  active: boolean;
326
346
  }
347
+ /**
348
+ * One band of a tiered price.
349
+ *
350
+ * `up_to` is inclusive, and the **last band must be `"inf"`** because a
351
+ * bounded top band cannot price the usage above it. Bands must strictly
352
+ * increase.
353
+ *
354
+ * A band names a unit rate (`unit_amount` in whole minor units, or
355
+ * `unit_amount_decimal` for a finer one), a `flat_amount` charged once for
356
+ * reaching the band, or both. Write a free band as `unit_amount: 0` rather
357
+ * than by omitting the rate, so "free" is something the price says instead
358
+ * of something it forgot.
359
+ */
360
+ interface PriceTier {
361
+ up_to: number | "inf";
362
+ /** Whole minor units per unit in this band. */
363
+ unit_amount?: number;
364
+ /**
365
+ * A rate finer than one minor unit, **as a string** — see
366
+ * {@link CreatePriceParams.unit_amount_decimal} for why it is never a
367
+ * `number`.
368
+ */
369
+ unit_amount_decimal?: string;
370
+ /** Charged once when the usage reaches this band. Whole minor units. */
371
+ flat_amount?: number;
372
+ }
327
373
  interface CreatePriceParams extends IdempotencyOptions {
328
374
  /** Existing Product id returned from `client.products.create`. */
329
375
  product_id: string;
330
- amount_cents: number;
376
+ /**
377
+ * Whole minor units per period (licensed) or per unit (metered).
378
+ *
379
+ * Optional because a metered price can be priced by
380
+ * {@link CreatePriceParams.unit_amount_decimal} or by
381
+ * {@link CreatePriceParams.tiers} instead. Exactly one of the three; a
382
+ * price with none of them is refused server-side.
383
+ */
384
+ amount_cents?: number;
385
+ /**
386
+ * A per-unit rate smaller than one minor unit, in **minor units**, to 12
387
+ * decimal places. `"0.02"` is 0.02 cents, i.e. EUR 0.0002 per unit, which
388
+ * is the canonical per-API-call price and not expressible as an integer.
389
+ * Metered prices only.
390
+ *
391
+ * **It is a `string`, and that is load-bearing.** A JS `number` is an
392
+ * IEEE-754 double and cannot hold 0.0002 exactly, so the rate would be
393
+ * corrupted before it was ever multiplied by a quantity. The type forbids
394
+ * a number at compile time, and the SDK throws a `TypeError` if an
395
+ * untyped JavaScript caller passes one anyway.
396
+ *
397
+ * The period's whole quantity is multiplied by the rate and rounded
398
+ * **once**, at the invoice.
399
+ */
400
+ unit_amount_decimal?: string;
401
+ /**
402
+ * `"per_unit"` (the default) multiplies one rate by the quantity.
403
+ * `"tiered"` prices by bands and requires
404
+ * {@link CreatePriceParams.tiers} and
405
+ * {@link CreatePriceParams.tiers_mode}. Metered prices only.
406
+ */
407
+ billing_scheme?: "per_unit" | "tiered";
408
+ /**
409
+ * How a tier table is read, and there is **no default** because the same
410
+ * table means two different bills. `"graduated"` prices the units inside
411
+ * each band; `"volume"` lets the period total pick one band which then
412
+ * prices every unit. 1,500 units against "first 1,000 at EUR 0.01, then
413
+ * EUR 0.005" is EUR 12.50 graduated and EUR 7.50 by volume.
414
+ */
415
+ tiers_mode?: "graduated" | "volume";
416
+ /** The band table. Required when `billing_scheme` is `"tiered"`, refused otherwise. */
417
+ tiers?: PriceTier[];
331
418
  currency: string;
332
419
  interval: "month" | "year" | (string & {});
333
420
  metadata?: Record<string, string>;
334
421
  trial_days?: number;
335
422
  trial_verification_cents?: number;
336
- payment_methods?: Array<"creditcard" | "directdebit" | (string & {})>;
423
+ payment_methods?: Array<"creditcard" | "directdebit" | "ideal" | "applepay" | (string & {})>;
424
+ /**
425
+ * What a cancellation refunds without being asked. `"none"` (the default)
426
+ * nothing; `"full"` the whole last charge; `"prorated"` the unused part
427
+ * of the current period. Both non-none modes also end access
428
+ * immediately, and both stay bounded by the refund window below.
429
+ *
430
+ * Metered prices must leave this at `"none"`: ending access mid-period
431
+ * would strand usage that has not been billed yet.
432
+ */
433
+ refund_on_cancel?: "none" | "full" | "prorated";
337
434
  /**
338
435
  * Per-Price refund-window override (`POST /v1/prices`). `undefined`
339
436
  * inherits the default policy table (7d / 30d initial, 3d renewal);
@@ -354,12 +451,15 @@ interface CreatePriceParams extends IdempotencyOptions {
354
451
  tax_behavior?: "inclusive" | "exclusive" | "unspecified";
355
452
  /**
356
453
  * `"licensed"` (the default when omitted) bills `amount_cents` per
357
- * period regardless of consumption. `"metered"` bills
358
- * `amount_cents` **per reported unit**: post consumption with
359
- * `subscriptions.createUsageRecord` and the renewal invoice charges
360
- * `amount_cents × sum(quantity)` for the period. Metered prices
361
- * must be `interval: "month"`, carry `amount_cents > 0`, and cannot
362
- * have `trial_days`.
454
+ * period regardless of consumption. `"metered"` bills **per reported
455
+ * unit**: post consumption with `subscriptions.createUsageRecord`, and
456
+ * at each period close BillKit invoices the period's total and charges
457
+ * the stored mandate.
458
+ *
459
+ * A metered unit is priced by `amount_cents`, by `unit_amount_decimal`,
460
+ * or by `tiers` — exactly one. Metered prices must be
461
+ * `interval: "month"`, cannot have `trial_days`, and cannot set
462
+ * `refund_on_cancel`.
363
463
  */
364
464
  usage_type?: "licensed" | "metered";
365
465
  }
@@ -377,6 +477,22 @@ interface CreateUsageRecordParams extends IdempotencyOptions {
377
477
  * the record must land in the period the usage occurred.
378
478
  */
379
479
  occurred_at?: number;
480
+ /**
481
+ * Your own id for the event being metered, unique within this
482
+ * subscription. This is the dedupe an `Idempotency-Key` cannot do.
483
+ *
484
+ * The key covers a retry of *one HTTP request*, including the SDK's own
485
+ * internal retries. `identifier` covers a retry of *your* call — a job
486
+ * runner replaying a task, a queue delivering twice, your code
487
+ * re-invoking after its own timeout — which arrives at the API as a
488
+ * genuinely new request with a new key. A second report of the same
489
+ * identifier returns the first record unchanged instead of billing
490
+ * twice.
491
+ *
492
+ * If your reporting pipeline is at-least-once, this is the one that
493
+ * matters.
494
+ */
495
+ identifier?: string;
380
496
  /** Small string metadata map echoed back on the record. */
381
497
  metadata?: Record<string, string>;
382
498
  }
@@ -416,7 +532,7 @@ interface CreateCheckoutSessionParams extends IdempotencyOptions {
416
532
  * the customer's available methods; when set, must be in the price's
417
533
  * `payment_methods` allowlist.
418
534
  */
419
- method?: "creditcard" | "directdebit" | (string & {});
535
+ method?: "creditcard" | "directdebit" | "ideal" | "applepay" | (string & {});
420
536
  /** Optional coupon code applied at checkout; atomically claimed. */
421
537
  coupon_code?: string;
422
538
  /**
@@ -481,7 +597,7 @@ interface CreateOneShotPaymentParams extends IdempotencyOptions {
481
597
  * *request* type the server validates, so an SDK that lags a newly-added
482
598
  * method should not be the thing that blocks the call.
483
599
  */
484
- method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | (string & {});
600
+ method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | "applepay" | (string & {});
485
601
  /** Where Mollie returns the payer after the hosted checkout. */
486
602
  success_url: string;
487
603
  /** Optional page for an abandoned/cancelled payment. */
@@ -628,7 +744,17 @@ declare class Customers extends BaseResource {
628
744
  * charge them.
629
745
  */
630
746
  delete<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
631
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
747
+ /**
748
+ * List customers, newest first.
749
+ *
750
+ * `provisional` filters on whether the customer ever completed a
751
+ * payment. A checkout that captures an email commits its Customer
752
+ * before the charge, so a checkout nobody finished leaves a row behind:
753
+ * pass `false` for real customers only, `true` for the abandoned ones
754
+ * (the cart-recovery worklist), or omit for both. Abandoned rows are
755
+ * swept after the tenant's retention window.
756
+ */
757
+ list<T = unknown>(params?: CustomerListParams): Promise<ListResponseEnvelope<T>>;
632
758
  /** Walk every page of `list()` and yield each customer. */
633
759
  iter<T = unknown>(options?: {
634
760
  pageSize?: number;
@@ -669,7 +795,16 @@ declare class Products extends BaseResource {
669
795
  }): AsyncIterableIterator<T>;
670
796
  }
671
797
  declare class Prices extends BaseResource {
672
- /** Create immutable billing terms for an existing Product. */
798
+ /**
799
+ * Create immutable billing terms for an existing Product.
800
+ *
801
+ * A licensed price sends `amount_cents`. A metered price sends one of
802
+ * `amount_cents`, `unit_amount_decimal` (a rate finer than one minor
803
+ * unit, as a string) or `billing_scheme: "tiered"` with `tiers` and
804
+ * `tiers_mode`. Throws `TypeError` before any HTTP call if a decimal
805
+ * rate arrives as a number — see
806
+ * {@link CreatePriceParams.unit_amount_decimal}.
807
+ */
673
808
  create<T = unknown>(params: CreatePriceParams): Promise<T>;
674
809
  retrieve<T = unknown>(id: string): Promise<T>;
675
810
  /**
@@ -763,13 +898,16 @@ declare class Subscriptions extends BaseResource {
763
898
  *
764
899
  * Only valid when the subscription's price is `usage_type:
765
900
  * "metered"`; a licensed subscription is rejected with `400
766
- * parameter_invalid`. Records accumulate until the renewal invoice
767
- * rolls them up (`amount_cents × sum(quantity)`); the record's
768
- * `invoice_id` stays `null` until then.
901
+ * parameter_invalid`. Records accumulate until the next period close
902
+ * rolls them into one invoice line; the record's `invoice_id` stays
903
+ * `null` until then. Records are immutable once written — they are the
904
+ * audit trail behind that line — so there is no update or delete.
769
905
  *
770
- * Supports `Idempotency-Key` replay: retrying with the same key
771
- * returns the same record instead of double-counting the usage,
772
- * which is what makes at-least-once reporting pipelines safe.
906
+ * Two dedupe mechanisms, covering different failures. The
907
+ * `Idempotency-Key` the SDK sends covers a retry of this HTTP request,
908
+ * including its own internal retries. `params.identifier` covers a
909
+ * retry of *your* call, which arrives as a new request with a new key.
910
+ * See {@link CreateUsageRecordParams.identifier}.
773
911
  */
774
912
  createUsageRecord<T = unknown>(id: string, params: CreateUsageRecordParams): Promise<T>;
775
913
  /**
@@ -785,6 +923,25 @@ declare class Subscriptions extends BaseResource {
785
923
  pageSize?: number;
786
924
  invoice_id?: string;
787
925
  }): AsyncIterableIterator<T>;
926
+ /**
927
+ * Price the pending usage, before the period close bills it.
928
+ *
929
+ * `listUsageRecords({ invoice_id: "pending" })` gives the quantity; this
930
+ * gives the money. `net_cents` / `tax_cents` / `gross_cents` are
931
+ * computed through the same rate or tier table and the same VAT
932
+ * resolution the close itself uses, so it is a forecast of the real
933
+ * invoice rather than an estimate.
934
+ *
935
+ * **Read `will_charge` before promising a customer an amount.** A period
936
+ * whose total is under `minimum_charge_cents` (EUR 1.00) is not charged,
937
+ * because the payment provider would refuse it. The usage is not lost:
938
+ * it stays pending and rolls into the next period, which is then billed
939
+ * for both.
940
+ *
941
+ * `open_invoice_id` names an earlier cycle that is invoiced and still
942
+ * unsettled; while one is open, this period cannot be charged.
943
+ */
944
+ retrieveUsageSummary<T = unknown>(id: string): Promise<T>;
788
945
  }
789
946
  declare class Refunds extends BaseResource {
790
947
  create<T = unknown>(params: CreateRefundParams): Promise<T>;
@@ -1104,7 +1261,7 @@ declare class RateLimitError extends BillKitError {
1104
1261
  });
1105
1262
  }
1106
1263
 
1107
- declare const VERSION = "0.2.1";
1264
+ declare const VERSION = "0.3.0";
1108
1265
 
1109
1266
  /**
1110
1267
  * Verify `BillKit-Signature: t=<unix>,v1=<hex>` headers.
@@ -1136,4 +1293,4 @@ interface VerifyWebhookOptions {
1136
1293
  }
1137
1294
  declare function verifyWebhookSignature<T = unknown>(options: VerifyWebhookOptions): Promise<T>;
1138
1295
 
1139
- 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, DEFAULT_RETRY_POLICY, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type EventsListParams, type IdempotencyOptions, InvalidRequestError, type ListParams, type ListResponseEnvelope, type LogContext, NOOP_LOGGER, type PaginateOptions, PermissionError, 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, WebhookVerificationError, paginate, verifyWebhookSignature };
1296
+ 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, 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, WebhookVerificationError, paginate, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -279,6 +279,14 @@ interface UpdateCustomerParams extends IdempotencyOptions {
279
279
  country_code?: string;
280
280
  metadata?: Record<string, string>;
281
281
  }
282
+ /** Query parameters accepted by `GET /v1/customers`. */
283
+ interface CustomerListParams extends BaseListParams {
284
+ /**
285
+ * `false` for customers who have paid, `true` for abandoned checkouts,
286
+ * omitted for both.
287
+ */
288
+ provisional?: boolean;
289
+ }
282
290
  /**
283
291
  * Body for `POST /v1/customers/{id}/vat_number`. The VAT number is
284
292
  * sent through VIES server-side; the response carries
@@ -306,6 +314,16 @@ interface CreateProductParams extends IdempotencyOptions {
306
314
  marketing_features?: string[];
307
315
  /** Small string metadata map echoed back on the Product object. */
308
316
  metadata?: Record<string, string>;
317
+ /**
318
+ * Let a *buyer* type a coupon code at the embedded checkout for this
319
+ * product. Defaults to `false`. A coupon you apply yourself by passing
320
+ * `coupon_code` when you create a Checkout Session is unaffected — that
321
+ * is you discounting your own sale, and it has never needed this flag.
322
+ *
323
+ * The code is redeemed only once the payment settles, so a shopper who
324
+ * tries a single-use code and abandons the checkout does not use it up.
325
+ */
326
+ allow_promotion_codes?: boolean;
309
327
  }
310
328
  interface UpdateProductParams extends IdempotencyOptions {
311
329
  name?: string;
@@ -314,6 +332,8 @@ interface UpdateProductParams extends IdempotencyOptions {
314
332
  metadata?: Record<string, string>;
315
333
  /** Set false to stop selling a product without deleting history. */
316
334
  active?: boolean;
335
+ /** See {@link CreateProductParams.allow_promotion_codes}. */
336
+ allow_promotion_codes?: boolean;
317
337
  }
318
338
  /**
319
339
  * Body for `POST /v1/prices/{id}`. `active` is the only field a price
@@ -324,16 +344,93 @@ interface UpdateProductParams extends IdempotencyOptions {
324
344
  interface UpdatePriceParams extends IdempotencyOptions {
325
345
  active: boolean;
326
346
  }
347
+ /**
348
+ * One band of a tiered price.
349
+ *
350
+ * `up_to` is inclusive, and the **last band must be `"inf"`** because a
351
+ * bounded top band cannot price the usage above it. Bands must strictly
352
+ * increase.
353
+ *
354
+ * A band names a unit rate (`unit_amount` in whole minor units, or
355
+ * `unit_amount_decimal` for a finer one), a `flat_amount` charged once for
356
+ * reaching the band, or both. Write a free band as `unit_amount: 0` rather
357
+ * than by omitting the rate, so "free" is something the price says instead
358
+ * of something it forgot.
359
+ */
360
+ interface PriceTier {
361
+ up_to: number | "inf";
362
+ /** Whole minor units per unit in this band. */
363
+ unit_amount?: number;
364
+ /**
365
+ * A rate finer than one minor unit, **as a string** — see
366
+ * {@link CreatePriceParams.unit_amount_decimal} for why it is never a
367
+ * `number`.
368
+ */
369
+ unit_amount_decimal?: string;
370
+ /** Charged once when the usage reaches this band. Whole minor units. */
371
+ flat_amount?: number;
372
+ }
327
373
  interface CreatePriceParams extends IdempotencyOptions {
328
374
  /** Existing Product id returned from `client.products.create`. */
329
375
  product_id: string;
330
- amount_cents: number;
376
+ /**
377
+ * Whole minor units per period (licensed) or per unit (metered).
378
+ *
379
+ * Optional because a metered price can be priced by
380
+ * {@link CreatePriceParams.unit_amount_decimal} or by
381
+ * {@link CreatePriceParams.tiers} instead. Exactly one of the three; a
382
+ * price with none of them is refused server-side.
383
+ */
384
+ amount_cents?: number;
385
+ /**
386
+ * A per-unit rate smaller than one minor unit, in **minor units**, to 12
387
+ * decimal places. `"0.02"` is 0.02 cents, i.e. EUR 0.0002 per unit, which
388
+ * is the canonical per-API-call price and not expressible as an integer.
389
+ * Metered prices only.
390
+ *
391
+ * **It is a `string`, and that is load-bearing.** A JS `number` is an
392
+ * IEEE-754 double and cannot hold 0.0002 exactly, so the rate would be
393
+ * corrupted before it was ever multiplied by a quantity. The type forbids
394
+ * a number at compile time, and the SDK throws a `TypeError` if an
395
+ * untyped JavaScript caller passes one anyway.
396
+ *
397
+ * The period's whole quantity is multiplied by the rate and rounded
398
+ * **once**, at the invoice.
399
+ */
400
+ unit_amount_decimal?: string;
401
+ /**
402
+ * `"per_unit"` (the default) multiplies one rate by the quantity.
403
+ * `"tiered"` prices by bands and requires
404
+ * {@link CreatePriceParams.tiers} and
405
+ * {@link CreatePriceParams.tiers_mode}. Metered prices only.
406
+ */
407
+ billing_scheme?: "per_unit" | "tiered";
408
+ /**
409
+ * How a tier table is read, and there is **no default** because the same
410
+ * table means two different bills. `"graduated"` prices the units inside
411
+ * each band; `"volume"` lets the period total pick one band which then
412
+ * prices every unit. 1,500 units against "first 1,000 at EUR 0.01, then
413
+ * EUR 0.005" is EUR 12.50 graduated and EUR 7.50 by volume.
414
+ */
415
+ tiers_mode?: "graduated" | "volume";
416
+ /** The band table. Required when `billing_scheme` is `"tiered"`, refused otherwise. */
417
+ tiers?: PriceTier[];
331
418
  currency: string;
332
419
  interval: "month" | "year" | (string & {});
333
420
  metadata?: Record<string, string>;
334
421
  trial_days?: number;
335
422
  trial_verification_cents?: number;
336
- payment_methods?: Array<"creditcard" | "directdebit" | (string & {})>;
423
+ payment_methods?: Array<"creditcard" | "directdebit" | "ideal" | "applepay" | (string & {})>;
424
+ /**
425
+ * What a cancellation refunds without being asked. `"none"` (the default)
426
+ * nothing; `"full"` the whole last charge; `"prorated"` the unused part
427
+ * of the current period. Both non-none modes also end access
428
+ * immediately, and both stay bounded by the refund window below.
429
+ *
430
+ * Metered prices must leave this at `"none"`: ending access mid-period
431
+ * would strand usage that has not been billed yet.
432
+ */
433
+ refund_on_cancel?: "none" | "full" | "prorated";
337
434
  /**
338
435
  * Per-Price refund-window override (`POST /v1/prices`). `undefined`
339
436
  * inherits the default policy table (7d / 30d initial, 3d renewal);
@@ -354,12 +451,15 @@ interface CreatePriceParams extends IdempotencyOptions {
354
451
  tax_behavior?: "inclusive" | "exclusive" | "unspecified";
355
452
  /**
356
453
  * `"licensed"` (the default when omitted) bills `amount_cents` per
357
- * period regardless of consumption. `"metered"` bills
358
- * `amount_cents` **per reported unit**: post consumption with
359
- * `subscriptions.createUsageRecord` and the renewal invoice charges
360
- * `amount_cents × sum(quantity)` for the period. Metered prices
361
- * must be `interval: "month"`, carry `amount_cents > 0`, and cannot
362
- * have `trial_days`.
454
+ * period regardless of consumption. `"metered"` bills **per reported
455
+ * unit**: post consumption with `subscriptions.createUsageRecord`, and
456
+ * at each period close BillKit invoices the period's total and charges
457
+ * the stored mandate.
458
+ *
459
+ * A metered unit is priced by `amount_cents`, by `unit_amount_decimal`,
460
+ * or by `tiers` — exactly one. Metered prices must be
461
+ * `interval: "month"`, cannot have `trial_days`, and cannot set
462
+ * `refund_on_cancel`.
363
463
  */
364
464
  usage_type?: "licensed" | "metered";
365
465
  }
@@ -377,6 +477,22 @@ interface CreateUsageRecordParams extends IdempotencyOptions {
377
477
  * the record must land in the period the usage occurred.
378
478
  */
379
479
  occurred_at?: number;
480
+ /**
481
+ * Your own id for the event being metered, unique within this
482
+ * subscription. This is the dedupe an `Idempotency-Key` cannot do.
483
+ *
484
+ * The key covers a retry of *one HTTP request*, including the SDK's own
485
+ * internal retries. `identifier` covers a retry of *your* call — a job
486
+ * runner replaying a task, a queue delivering twice, your code
487
+ * re-invoking after its own timeout — which arrives at the API as a
488
+ * genuinely new request with a new key. A second report of the same
489
+ * identifier returns the first record unchanged instead of billing
490
+ * twice.
491
+ *
492
+ * If your reporting pipeline is at-least-once, this is the one that
493
+ * matters.
494
+ */
495
+ identifier?: string;
380
496
  /** Small string metadata map echoed back on the record. */
381
497
  metadata?: Record<string, string>;
382
498
  }
@@ -416,7 +532,7 @@ interface CreateCheckoutSessionParams extends IdempotencyOptions {
416
532
  * the customer's available methods; when set, must be in the price's
417
533
  * `payment_methods` allowlist.
418
534
  */
419
- method?: "creditcard" | "directdebit" | (string & {});
535
+ method?: "creditcard" | "directdebit" | "ideal" | "applepay" | (string & {});
420
536
  /** Optional coupon code applied at checkout; atomically claimed. */
421
537
  coupon_code?: string;
422
538
  /**
@@ -481,7 +597,7 @@ interface CreateOneShotPaymentParams extends IdempotencyOptions {
481
597
  * *request* type the server validates, so an SDK that lags a newly-added
482
598
  * method should not be the thing that blocks the call.
483
599
  */
484
- method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | (string & {});
600
+ method: "creditcard" | "directdebit" | "ideal" | "bancontact" | "eps" | "applepay" | (string & {});
485
601
  /** Where Mollie returns the payer after the hosted checkout. */
486
602
  success_url: string;
487
603
  /** Optional page for an abandoned/cancelled payment. */
@@ -628,7 +744,17 @@ declare class Customers extends BaseResource {
628
744
  * charge them.
629
745
  */
630
746
  delete<T = unknown>(id: string, params?: IdempotencyOptions): Promise<T>;
631
- list<T = unknown>(params?: BaseListParams): Promise<ListResponseEnvelope<T>>;
747
+ /**
748
+ * List customers, newest first.
749
+ *
750
+ * `provisional` filters on whether the customer ever completed a
751
+ * payment. A checkout that captures an email commits its Customer
752
+ * before the charge, so a checkout nobody finished leaves a row behind:
753
+ * pass `false` for real customers only, `true` for the abandoned ones
754
+ * (the cart-recovery worklist), or omit for both. Abandoned rows are
755
+ * swept after the tenant's retention window.
756
+ */
757
+ list<T = unknown>(params?: CustomerListParams): Promise<ListResponseEnvelope<T>>;
632
758
  /** Walk every page of `list()` and yield each customer. */
633
759
  iter<T = unknown>(options?: {
634
760
  pageSize?: number;
@@ -669,7 +795,16 @@ declare class Products extends BaseResource {
669
795
  }): AsyncIterableIterator<T>;
670
796
  }
671
797
  declare class Prices extends BaseResource {
672
- /** Create immutable billing terms for an existing Product. */
798
+ /**
799
+ * Create immutable billing terms for an existing Product.
800
+ *
801
+ * A licensed price sends `amount_cents`. A metered price sends one of
802
+ * `amount_cents`, `unit_amount_decimal` (a rate finer than one minor
803
+ * unit, as a string) or `billing_scheme: "tiered"` with `tiers` and
804
+ * `tiers_mode`. Throws `TypeError` before any HTTP call if a decimal
805
+ * rate arrives as a number — see
806
+ * {@link CreatePriceParams.unit_amount_decimal}.
807
+ */
673
808
  create<T = unknown>(params: CreatePriceParams): Promise<T>;
674
809
  retrieve<T = unknown>(id: string): Promise<T>;
675
810
  /**
@@ -763,13 +898,16 @@ declare class Subscriptions extends BaseResource {
763
898
  *
764
899
  * Only valid when the subscription's price is `usage_type:
765
900
  * "metered"`; a licensed subscription is rejected with `400
766
- * parameter_invalid`. Records accumulate until the renewal invoice
767
- * rolls them up (`amount_cents × sum(quantity)`); the record's
768
- * `invoice_id` stays `null` until then.
901
+ * parameter_invalid`. Records accumulate until the next period close
902
+ * rolls them into one invoice line; the record's `invoice_id` stays
903
+ * `null` until then. Records are immutable once written — they are the
904
+ * audit trail behind that line — so there is no update or delete.
769
905
  *
770
- * Supports `Idempotency-Key` replay: retrying with the same key
771
- * returns the same record instead of double-counting the usage,
772
- * which is what makes at-least-once reporting pipelines safe.
906
+ * Two dedupe mechanisms, covering different failures. The
907
+ * `Idempotency-Key` the SDK sends covers a retry of this HTTP request,
908
+ * including its own internal retries. `params.identifier` covers a
909
+ * retry of *your* call, which arrives as a new request with a new key.
910
+ * See {@link CreateUsageRecordParams.identifier}.
773
911
  */
774
912
  createUsageRecord<T = unknown>(id: string, params: CreateUsageRecordParams): Promise<T>;
775
913
  /**
@@ -785,6 +923,25 @@ declare class Subscriptions extends BaseResource {
785
923
  pageSize?: number;
786
924
  invoice_id?: string;
787
925
  }): AsyncIterableIterator<T>;
926
+ /**
927
+ * Price the pending usage, before the period close bills it.
928
+ *
929
+ * `listUsageRecords({ invoice_id: "pending" })` gives the quantity; this
930
+ * gives the money. `net_cents` / `tax_cents` / `gross_cents` are
931
+ * computed through the same rate or tier table and the same VAT
932
+ * resolution the close itself uses, so it is a forecast of the real
933
+ * invoice rather than an estimate.
934
+ *
935
+ * **Read `will_charge` before promising a customer an amount.** A period
936
+ * whose total is under `minimum_charge_cents` (EUR 1.00) is not charged,
937
+ * because the payment provider would refuse it. The usage is not lost:
938
+ * it stays pending and rolls into the next period, which is then billed
939
+ * for both.
940
+ *
941
+ * `open_invoice_id` names an earlier cycle that is invoiced and still
942
+ * unsettled; while one is open, this period cannot be charged.
943
+ */
944
+ retrieveUsageSummary<T = unknown>(id: string): Promise<T>;
788
945
  }
789
946
  declare class Refunds extends BaseResource {
790
947
  create<T = unknown>(params: CreateRefundParams): Promise<T>;
@@ -1104,7 +1261,7 @@ declare class RateLimitError extends BillKitError {
1104
1261
  });
1105
1262
  }
1106
1263
 
1107
- declare const VERSION = "0.2.1";
1264
+ declare const VERSION = "0.3.0";
1108
1265
 
1109
1266
  /**
1110
1267
  * Verify `BillKit-Signature: t=<unix>,v1=<hex>` headers.
@@ -1136,4 +1293,4 @@ interface VerifyWebhookOptions {
1136
1293
  }
1137
1294
  declare function verifyWebhookSignature<T = unknown>(options: VerifyWebhookOptions): Promise<T>;
1138
1295
 
1139
- 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, DEFAULT_RETRY_POLICY, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type EventsListParams, type IdempotencyOptions, InvalidRequestError, type ListParams, type ListResponseEnvelope, type LogContext, NOOP_LOGGER, type PaginateOptions, PermissionError, 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, WebhookVerificationError, paginate, verifyWebhookSignature };
1296
+ 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, 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, WebhookVerificationError, paginate, verifyWebhookSignature };