@delopay/sdk 0.100.0 → 0.101.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.cjs CHANGED
@@ -219,8 +219,7 @@ var ApiKeys = class {
219
219
  // JWT-authenticated routes under `/account/{merchantId}/profile/api-keys`.
220
220
  // The caller's shop (business profile) comes from the JWT, never from the
221
221
  // request, so a shop-scoped user can only mint/list/manage keys pinned to
222
- // their own shop. Requires a backend with profile-scoped API key support
223
- // (DeloPay-net/delopay-backend#344).
222
+ // their own shop. Requires a backend with profile-scoped API key support.
224
223
  /**
225
224
  * Create a new API key pinned to the caller's shop (business profile).
226
225
  * `POST /account/{merchantId}/profile/api-keys`
@@ -3818,6 +3817,53 @@ var Subscriptions = class {
3818
3817
  async lookupPayments(params, options) {
3819
3818
  return this.request("POST", "/subscriptions/payments/lookup", { body: params, ...options });
3820
3819
  }
3820
+ /**
3821
+ * One subscription's billing history, newest cycle first.
3822
+ * `GET /subscriptions/{subscriptionId}/invoices`
3823
+ *
3824
+ * {@link retrieve} carries only the *latest* invoice, which is the current
3825
+ * cycle — a subscription that has renewed monthly for a year has one of those
3826
+ * and twelve of these. Use this wherever a merchant needs to see what a
3827
+ * subscription has actually billed, in particular on self-charging processors
3828
+ * (Creem, PayPal) where each renewal is charged by the processor and mirrored
3829
+ * here rather than raised as a DeloPay payment.
3830
+ *
3831
+ * Two things to render honestly, both decided rather than incidental:
3832
+ *
3833
+ * - `amount` is **gross** and `refunded_amount` sits beside it. Do not net
3834
+ * them: the difference between the two is not a smaller charge.
3835
+ * - A `refunded_amount` of `null` is "not reported" and must not render as
3836
+ * `0`. Likewise a processor-hosted origination records a bootstrap invoice
3837
+ * at `0` before the buyer has paid anything, so a zero amount on such a
3838
+ * subscription is a placeholder rather than a free cycle.
3839
+ *
3840
+ * Profile-scoped like every other subscription route.
3841
+ */
3842
+ async listInvoices(subscriptionId, params, options) {
3843
+ return this.request("GET", `/subscriptions/${encodeURIComponent(subscriptionId)}/invoices`, {
3844
+ query: params,
3845
+ ...options
3846
+ });
3847
+ }
3848
+ /**
3849
+ * Which billing processor this shop's subscriptions run on.
3850
+ * `GET /subscriptions/billing_processor`
3851
+ *
3852
+ * The same mapping is derivable from the connector inventory
3853
+ * (`GET /account/{merchant_id}/connectors`), but that route is gated by a
3854
+ * connector-read permission granted independently of subscriptions — so a
3855
+ * role authorised to create subscriptions could be unable to learn which
3856
+ * processor it was creating them on. This answers under the same
3857
+ * authorization as the rest of the subscription API.
3858
+ *
3859
+ * Reach for it when the client must branch on the processor *before* calling
3860
+ * — origination differs by processor, and guessing is destructive. Resolve
3861
+ * the shop's `billing_processor_id` first: a shop that runs no subscriptions
3862
+ * has none assigned, and this route has no identity to report for it.
3863
+ */
3864
+ async getBillingProcessor(options) {
3865
+ return this.request("GET", "/subscriptions/billing_processor", { ...options });
3866
+ }
3821
3867
  };
3822
3868
 
3823
3869
  // src/resources/settlement.ts
@@ -5725,7 +5771,7 @@ var CheckoutSession = class {
5725
5771
  * own types and runtime gates — hence the loose return type.
5726
5772
  *
5727
5773
  * `theme` is the route's one declared query parameter (a named checkout
5728
- * variant, backend#793). `locale` travels as `Accept-Language` — the only
5774
+ * variant). `locale` travels as `Accept-Language` — the only
5729
5775
  * channel the backend's locale resolution reads; a `?locale=` query is
5730
5776
  * silently ignored by this route.
5731
5777
  *
@@ -5880,10 +5926,17 @@ var CheckoutSession = class {
5880
5926
  /**
5881
5927
  * A short-lived VGS Collect session for browser-side card capture.
5882
5928
  *
5883
- * A 404 or a 400 carrying the "shop has no vault" code means the shop
5884
- * has no vault configured; other errors must NOT be treated that way (a
5885
- * refused vault falling back to an unprotected card pane is exactly the
5886
- * bug this endpoint's error contract exists to prevent).
5929
+ * **Exactly one refusal means "this shop has no vault": a 400 carrying
5930
+ * `IR_19`.** Every other refusal means a vault exists and could not be used,
5931
+ * and answering it by falling back to the processor's own card pane sends an
5932
+ * unprotected card number to the very processor the shop pays to hide it
5933
+ * from — the bug this endpoint's error contract exists to prevent.
5934
+ *
5935
+ * A **404 is not benign.** The router answers it when the shop's vault
5936
+ * account cannot be found — the state a shop is left in when its vault
5937
+ * connector is deleted while the profile keeps naming the id: it still
5938
+ * reports the vault as enabled and still expects its cards cloaked. The same
5939
+ * status also covers a payment that does not exist.
5887
5940
  *
5888
5941
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
5889
5942
  */