@billkit-eu/sdk 0.7.0 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@billkit-eu/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Official Node.js SDK for BillKit: a Stripe-Billing-shape multi-tenant SaaS API on Mollie.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
package/src/index.ts CHANGED
@@ -90,6 +90,7 @@ export type {
90
90
  IdempotencyOptions,
91
91
  InvoicesListParams,
92
92
  ListParams,
93
+ OneShotPaymentsListParams,
93
94
  PaymentsListParams,
94
95
  PriceTier,
95
96
  PricesListParams,
package/src/resources.ts CHANGED
@@ -71,6 +71,21 @@ export interface PaymentsListParams extends BaseListParams {
71
71
  expand?: string[];
72
72
  }
73
73
 
74
+ /**
75
+ * `oneShotPayments.list` params. `payments.list` lists subscription
76
+ * payments only; one-off charges are listed here, newest first.
77
+ * Failed, expired and still-open charges are included, so check `status`
78
+ * before counting a row as revenue.
79
+ */
80
+ export interface OneShotPaymentsListParams extends BaseListParams {
81
+ customer_id?: string;
82
+ /**
83
+ * One of `open`, `pending`, `authorized`, `paid`, `failed`, `expired`,
84
+ * `canceled`, `refunded`. Anything else is a `400` on `status`.
85
+ */
86
+ status?: string;
87
+ }
88
+
74
89
  /**
75
90
  * `invoices.list` params. The three id filters each narrow to one row's
76
91
  * worth of invoices: `payment_id` answers "which invoice did this charge
@@ -152,7 +167,8 @@ export interface CreateCustomerParams extends IdempotencyOptions {
152
167
 
153
168
  export interface UpdateCustomerParams extends IdempotencyOptions {
154
169
  email?: string;
155
- name?: string;
170
+ /** An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
171
+ name?: string | null;
156
172
  country_code?: string;
157
173
  metadata?: Record<string, string>;
158
174
  }
@@ -170,7 +186,7 @@ export interface CustomerListParams extends BaseListParams {
170
186
 
171
187
  /** Query parameters accepted by `GET /v1/products`. */
172
188
  export interface ProductsListParams extends BaseListParams {
173
- /** Expandable here: `prices`, `stats`. */
189
+ /** Expandable here: `prices`, `stats`, `default_price`. */
174
190
  expand?: string[];
175
191
  }
176
192
 
@@ -221,13 +237,22 @@ export interface CreateProductParams extends IdempotencyOptions {
221
237
 
222
238
  export interface UpdateProductParams extends IdempotencyOptions {
223
239
  name?: string;
224
- description?: string;
240
+ /** An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
241
+ description?: string | null;
225
242
  marketing_features?: string[];
226
243
  metadata?: Record<string, string>;
227
244
  /** Set false to stop selling a product without deleting history. */
228
245
  active?: boolean;
229
246
  /** See {@link CreateProductParams.allow_promotion_codes}. */
230
247
  allow_promotion_codes?: boolean;
248
+ /**
249
+ * The price the billing portal offers on that price's interval. Must be
250
+ * an active price of this product; anything else is a 400 on
251
+ * `default_price_id`. An explicit `null` **clears** the default and is
252
+ * sent as a JSON null rather than pruned (only `undefined` is dropped);
253
+ * omit the field to leave the default alone.
254
+ */
255
+ default_price_id?: string | null;
231
256
  }
232
257
 
233
258
  /**
@@ -596,7 +621,8 @@ export interface CreateWebhookEndpointParams extends IdempotencyOptions {
596
621
  export interface UpdateWebhookEndpointParams extends IdempotencyOptions {
597
622
  url?: string;
598
623
  enabled_events?: string[];
599
- description?: string;
624
+ /** An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
625
+ description?: string | null;
600
626
  status?: string;
601
627
  }
602
628
 
@@ -643,8 +669,10 @@ export interface CreateCouponParams extends IdempotencyOptions {
643
669
 
644
670
  export interface UpdateCouponParams extends IdempotencyOptions {
645
671
  active?: boolean;
646
- max_redemptions?: number;
647
- redeem_by?: number;
672
+ /** `null` removes the redemption cap. An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
673
+ max_redemptions?: number | null;
674
+ /** Epoch seconds. `null` removes the expiry. An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
675
+ redeem_by?: number | null;
648
676
  applies_to_price_ids?: string[];
649
677
  min_amount_cents?: number;
650
678
  }
@@ -674,7 +702,8 @@ export interface CreateTaxRateParams extends IdempotencyOptions {
674
702
 
675
703
  export interface UpdateTaxRateParams extends IdempotencyOptions {
676
704
  rate_basis_points?: number;
677
- display_name?: string;
705
+ /** An explicit `null` **clears** it and is sent as a JSON null rather than pruned (only `undefined` is dropped); omit the field to leave it alone. */
706
+ display_name?: string | null;
678
707
  inclusive?: boolean;
679
708
  active?: boolean;
680
709
  }
@@ -711,15 +740,20 @@ export interface CreditNotesListParams extends BaseListParams {
711
740
  * VAT is decided against and that an invoice prints.
712
741
  *
713
742
  * `country_code` is required on every call: there is nothing to leave
714
- * alone about a jurisdiction. Every other field is partial-update: omit
715
- * it to leave the stored value alone, or pass an explicit `null` to
716
- * clear it, because ceasing to be VAT registered (or moving office) is a
717
- * real event.
743
+ * alone about a jurisdiction. The address fields and
744
+ * `registration_number` are partial-update: omit one to leave the stored
745
+ * value alone, or pass an explicit `null` to clear it, because moving
746
+ * office is a real event.
747
+ *
748
+ * `vat_id` can be set once. After that, a different value or `null` is
749
+ * refused with a 400 (`param: "vat_id"`, reason `vat_id_locked`) and the
750
+ * call writes nothing; re-sending the stored number is accepted. BillKit
751
+ * invoices you reverse-charged against it, so support changes it.
718
752
  */
719
753
  export interface SetTenantBillingProfileParams extends IdempotencyOptions {
720
754
  /** ISO-3166-1 alpha-2, e.g. `"NL"`. */
721
755
  country_code: string;
722
- /** Your own EU VAT registration, or `null` to clear it. */
756
+ /** Your own EU VAT registration. Set once; support changes or clears it. */
723
757
  vat_id?: string | null;
724
758
  address_line1?: string | null;
725
759
  address_line2?: string | null;
@@ -963,7 +997,10 @@ export class Products extends BaseResource {
963
997
  return this.post<T, CreateProductParams>("/v1/products", params);
964
998
  }
965
999
 
966
- /** Expandable: `prices` (every price on the product), `stats`. */
1000
+ /**
1001
+ * Expandable: `prices` (every price on the product), `stats`, and
1002
+ * `default_price` (the price `default_price_id` names).
1003
+ */
967
1004
  retrieve<T = unknown>(id: string, options: ExpandOptions = {}): Promise<T> {
968
1005
  return this.get<T>(`/v1/products/${p(id)}`, options);
969
1006
  }
@@ -1080,6 +1117,20 @@ export class OneShotPayments extends BaseResource {
1080
1117
  retrieve<T = unknown>(id: string): Promise<T> {
1081
1118
  return this.get<T>(`/v1/checkout/one_shot/${p(id)}`);
1082
1119
  }
1120
+
1121
+ /** List one-off charges, newest first. Filter by `customer_id` and `status`. */
1122
+ list<T = unknown>(params: OneShotPaymentsListParams = {}): Promise<ListResponseEnvelope<T>> {
1123
+ return this.get<ListResponseEnvelope<T>>("/v1/checkout/one_shot", params);
1124
+ }
1125
+
1126
+ iter<T = unknown>(
1127
+ options: { pageSize?: number; customer_id?: string; status?: string } = {},
1128
+ ): AsyncIterableIterator<T> {
1129
+ return paginate<T>((page) => this.get("/v1/checkout/one_shot", page), {
1130
+ pageSize: options.pageSize,
1131
+ filters: { customer_id: options.customer_id, status: options.status },
1132
+ });
1133
+ }
1083
1134
  }
1084
1135
 
1085
1136
  export class Subscriptions extends BaseResource {
@@ -1764,7 +1815,20 @@ export class AuditLogs extends BaseResource {
1764
1815
  * refunds and disputes are separate flows.
1765
1816
  */
1766
1817
  export class Payments extends BaseResource {
1767
- /** Expandable: `customer`, `subscription`. */
1818
+ /**
1819
+ * Expandable: `customer`, `subscription`, `refund_eligibility`. The last
1820
+ * is retrieve-only (`list` refuses it with a `400`) and attaches
1821
+ * `refund_eligibility: { object: "refund_eligibility", eligible,
1822
+ * amount_cents, currency, days_remaining, window_ends_at, reason }`:
1823
+ * whether `refunds.create` for the remaining balance would succeed now,
1824
+ * applying the refund window and the price's refund policy, which
1825
+ * `amount_refundable_cents` does not. When `eligible` is false, `reason`
1826
+ * is one of `not_paid`, `unrefundable_type`, `window_expired`,
1827
+ * `fully_refunded`, `disputed`, `operation_pending` or
1828
+ * `plan_change_pending` (a plan change is settling: the full balance
1829
+ * cannot be refunded yet, a partial refund still can); treat any other
1830
+ * value as "not refundable".
1831
+ */
1768
1832
  retrieve<T = unknown>(id: string, options: ExpandOptions = {}): Promise<T> {
1769
1833
  return this.get<T>(`/v1/payments/${p(id)}`, options);
1770
1834
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.7.0";
1
+ export const VERSION = "0.8.0";