@billkit-eu/sdk 0.3.0 → 0.5.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 CHANGED
@@ -8,6 +8,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  Versioning is independent of the Python SDK; the two ship on their own cadence,
9
9
  so the numbers will diverge after this first release.
10
10
 
11
+ ## [0.5.0] - 2026-09-22
12
+
13
+ ### Changed
14
+ - `webhookEndpoints.getDelivery()` is now `retrieveDelivery()`. Every other
15
+ single-row fetch in every BillKit SDK is `retrieve`, and python and php
16
+ already spelled this one `retrieve_delivery` / `retrieveDelivery`, so node
17
+ was the outlier and the obvious name was a type error. `getDelivery` stays as
18
+ a deprecated alias — removing it would break callers over a naming
19
+ preference — and goes in the next major.
20
+
21
+ ### Fixed
22
+ - `CustomerListParams` is exported from the package entry point. The interface
23
+ documented the `provisional` filter but could not be imported, so callers
24
+ building the params object ahead of the call had nothing to type it with.
25
+
26
+ ## [0.4.0]
27
+
28
+ ### Added
29
+ - **`creditNotes`** — `retrieve`, `list`, `iter` and `retrievePdf`. A credit
30
+ note is the document that reverses an issued invoice; one is created for you
31
+ when a refund settles, so there is no `create` here. `list` takes
32
+ `invoice_id` to answer "was this sale credited, and by how much".
33
+ - **`invoices.void(id)`** — records that an invoice was never owed. It keeps
34
+ its number and stays readable; it just stops being a receivable.
35
+
36
+ A **paid** invoice is refused with a `ConflictError` whose `code` is
37
+ `"invoice_not_voidable"`. Once the money has moved, "never owed" is not
38
+ true — refund the payment instead, and a credit note is issued when the
39
+ refund settles. Voiding twice is a no-op.
40
+
11
41
  ## [0.3.0]
12
42
 
13
43
  ### Added
package/README.md CHANGED
@@ -92,19 +92,21 @@ The client exposes one accessor per resource family. Each mirrors the verbs from
92
92
 
93
93
  | Accessor | Verbs |
94
94
  | --- | --- |
95
- | `client.customers` | `create`, `retrieve`, `update`, `delete`, `list`, `iter` |
95
+ | `client.customers` | `create`, `retrieve`, `update`, `delete`, `list` (filter by `provisional`), `iter`, `setVatNumber`, `purge` |
96
96
  | `client.products` | `create`, `retrieve`, `update` (archive with `active: false`), `list`, `iter` |
97
97
  | `client.prices` | `create`, `retrieve`, `update` (archive with `active: false`, restore with `active: true`), `list`, `iter` |
98
98
  | `client.checkoutSessions` | `create`, `retrieve` |
99
99
  | `client.oneShotPayments` | `create`, `retrieve` |
100
100
  | `client.subscriptions` | `retrieve`, `list`, `iter` (filter by `customer_id`, `status`, `renewal_state`), `cancel`, `pause`, `resume`, `reactivate`, `previewUpdate`, `update`, `reauthorizePaymentMethod`, `createUsageRecord`, `listUsageRecords`, `iterUsageRecords`, `retrieveUsageSummary` |
101
101
  | `client.refunds` | `create`, `retrieve`, `list`, `iter` |
102
- | `client.webhookEndpoints` | `create`, `retrieve`, `update` (stop delivery with `status: "disabled"`), `delete`, `rotateSecret`, `list`, `iter`, `listDeliveries`, `iterDeliveries`, `getDelivery`, `redeliver` |
102
+ | `client.disputes` | `retrieve`, `list`, `iter` |
103
+ | `client.webhookEndpoints` | `create`, `retrieve`, `update` (stop delivery with `status: "disabled"`), `delete`, `rotateSecret`, `list`, `iter`, `listDeliveries`, `iterDeliveries`, `retrieveDelivery`, `redeliver` |
103
104
  | `client.events` | `retrieve`, `list`, `iter` (filter by `type`) |
104
105
  | `client.tenant` | `capabilities`, `portalBranding`, `setPortalBranding`, `rotateProviderCredential` |
105
106
  | `client.coupons` | `create`, `retrieve`, `update` (withdraw with `active: false`), `validate`, `list`, `iter` |
106
107
  | `client.taxRates` | `create`, `retrieve`, `update` (retire with `active: false`), `list`, `iter` |
107
- | `client.invoices` | `retrieve`, `retrievePdf`, `list`, `iter` |
108
+ | `client.invoices` | `retrieve`, `retrievePdf`, `list`, `iter`, `void` |
109
+ | `client.creditNotes` | `retrieve`, `retrievePdf`, `list`, `iter` (filter by `invoice_id`, `customer_id`) |
108
110
  | `client.auditLogs` | `retrieve`, `list`, `iter` (filter by `action`, `resource_type`, `actor_id`) |
109
111
  | `client.payments` | `retrieve`, `list`, `iter` |
110
112
  | `client.billingPortalSessions` | `create`, `revoke` |
@@ -225,14 +227,16 @@ const session = await client.checkoutSessions.create<{ client_secret: string }>(
225
227
  });
226
228
  ```
227
229
 
228
- ### Invoice PDFs
230
+ ### Invoice and credit-note PDFs
229
231
 
230
232
  ```ts
231
233
  const pdf = await client.invoices.retrievePdf("inv_123");
232
234
  await writeFile("invoice.pdf", Buffer.from(pdf));
235
+
236
+ const credit = await client.creditNotes.retrievePdf("cn_123");
233
237
  ```
234
238
 
235
- Returns the raw bytes. S3-backed deployments answer with a redirect to a presigned URL, which is followed transparently under the SDK's own timeout and retry policy, so both storage adapters look the same from here. A deployment with PDF rendering disabled throws a `ServerError` with `code: "rendering_pending"`; `retrieve()` still gives you the structured invoice to render yourself.
239
+ Returns the raw bytes. S3-backed deployments answer with a redirect to a presigned URL, which is followed transparently under the SDK's own timeout and retry policy, so both storage adapters look the same from here — and the API key is never sent to the storage host, because the presigned URL carries its own credential. A deployment with PDF rendering disabled throws a `ServerError` with `code: "rendering_pending"`; `retrieve()` still gives you the structured document to render yourself.
236
240
 
237
241
  ## Auto-pagination
238
242
 
package/dist/index.cjs CHANGED
@@ -462,9 +462,23 @@ var WebhookEndpoints = class extends BaseResource {
462
462
  );
463
463
  }
464
464
  /** Fetch one delivery row for inspection before deciding to redeliver. */
465
- getDelivery(endpointId, deliveryId) {
465
+ retrieveDelivery(endpointId, deliveryId) {
466
466
  return this.get(`/v1/webhook_endpoints/${endpointId}/deliveries/${deliveryId}`);
467
467
  }
468
+ /**
469
+ * @deprecated Renamed to {@link WebhookEndpoints.retrieveDelivery}.
470
+ *
471
+ * Every other single-row fetch in every BillKit SDK is `retrieve`; this
472
+ * one method was `get`, which meant reaching for the obvious name and
473
+ * getting a type error. The python and php clients already spell it
474
+ * `retrieve_delivery` / `retrieveDelivery`, so node was the outlier.
475
+ *
476
+ * Kept as an alias because removing it would break callers for a naming
477
+ * preference. It will go in the next major.
478
+ */
479
+ getDelivery(endpointId, deliveryId) {
480
+ return this.retrieveDelivery(endpointId, deliveryId);
481
+ }
468
482
  /**
469
483
  * Re-enqueue a delivery row for the dispatcher.
470
484
  *
@@ -620,6 +634,46 @@ var Invoices = class extends BaseResource {
620
634
  iter(options = {}) {
621
635
  return paginate((p) => this.get("/v1/invoices", p), { pageSize: options.pageSize });
622
636
  }
637
+ /**
638
+ * Void an invoice: state that the sale was never owed.
639
+ *
640
+ * The invoice keeps its number and stays readable — a gapless series
641
+ * cannot lose a row — and stops being a receivable. Use it for an
642
+ * invoice that should not have been issued.
643
+ *
644
+ * A **paid** invoice is refused with a `ConflictError` whose `code` is
645
+ * `"invoice_not_voidable"`. That is deliberate rather than a
646
+ * limitation: once the money has moved, "never owed" is false, and the
647
+ * document that reverses a real sale is a credit note — refund the
648
+ * payment and one is issued when the refund settles.
649
+ *
650
+ * Idempotent: re-voiding an already-void invoice returns it unchanged.
651
+ */
652
+ void(id, params = {}) {
653
+ return this.post(`/v1/invoices/${id}/void`, params);
654
+ }
655
+ };
656
+ var CreditNotes = class extends BaseResource {
657
+ retrieve(id) {
658
+ return this.get(`/v1/credit_notes/${id}`);
659
+ }
660
+ /**
661
+ * Download the rendered credit note PDF as raw bytes. Same storage
662
+ * split as {@link Invoices.retrievePdf}: bytes inline or a followed
663
+ * `302`, and `501 rendering_pending` on a deployment with no renderer.
664
+ */
665
+ retrievePdf(id) {
666
+ return this.t.requestBinary({ method: "GET", path: `/v1/credit_notes/${id}/pdf` });
667
+ }
668
+ list(params = {}) {
669
+ return this.get("/v1/credit_notes", params);
670
+ }
671
+ iter(options = {}) {
672
+ return paginate((p) => this.get("/v1/credit_notes", p), {
673
+ pageSize: options.pageSize,
674
+ filters: { invoice_id: options.invoice_id, customer_id: options.customer_id }
675
+ });
676
+ }
623
677
  };
624
678
  var AuditLogs = class extends BaseResource {
625
679
  retrieve(id) {
@@ -797,7 +851,7 @@ function sleep(ms) {
797
851
  }
798
852
 
799
853
  // src/version.ts
800
- var VERSION = "0.3.0";
854
+ var VERSION = "0.5.0";
801
855
 
802
856
  // src/transport.ts
803
857
  var DEFAULT_BASE_URL = "https://api.billkit.eu";
@@ -1031,6 +1085,7 @@ var BillKit = class {
1031
1085
  coupons;
1032
1086
  taxRates;
1033
1087
  invoices;
1088
+ creditNotes;
1034
1089
  auditLogs;
1035
1090
  payments;
1036
1091
  billingPortalSessions;
@@ -1053,6 +1108,7 @@ var BillKit = class {
1053
1108
  this.coupons = new Coupons(transport);
1054
1109
  this.taxRates = new TaxRates(transport);
1055
1110
  this.invoices = new Invoices(transport);
1111
+ this.creditNotes = new CreditNotes(transport);
1056
1112
  this.auditLogs = new AuditLogs(transport);
1057
1113
  this.payments = new Payments(transport);
1058
1114
  this.billingPortalSessions = new BillingPortalSessions(transport);