@delopay/sdk 0.189.0 → 0.192.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
@@ -3315,6 +3315,12 @@ var Routing = class {
3315
3315
  * Every account named must belong to this shop; one that does not is refused.
3316
3316
  * So is an amount cap without a `currency`, and a payment cap with one.
3317
3317
  *
3318
+ * An account may appear twice — a payment count and a budget — and never
3319
+ * twice in one `unit`. Re-send a range with its `limit_max`, or it is stored
3320
+ * as its bottom. Never re-send `current_limit` as `set_current_limit`: the
3321
+ * value read belongs to the window it was read in, and pinning it into a
3322
+ * window that has since reset is a limit nobody chose.
3323
+ *
3318
3324
  * `PUT /routing/connector-caps/{profileId}`
3319
3325
  */
3320
3326
  async setConnectorCaps(profileId, params) {
@@ -4276,6 +4282,33 @@ var Users = class {
4276
4282
  async changeMemberScope(params) {
4277
4283
  return this.request("POST", "/user/employees/change-scope", { body: params });
4278
4284
  }
4285
+ /**
4286
+ * One member of your merchant, with the person fields the member list
4287
+ * omits. `GET /user/employees/{user_id}/details`
4288
+ *
4289
+ * Answers only for a member `listUsersInLineage` shows you. Any other id,
4290
+ * unknown or not yours, is a 404 `UR_68` with `data.reason:
4291
+ * 'member_not_found'`.
4292
+ */
4293
+ async getTeamMemberDetails(userId) {
4294
+ return this.request("GET", `/user/employees/${encodeURIComponent(userId)}/details`);
4295
+ }
4296
+ /**
4297
+ * Replace a team member's password with a temporary one, returned once.
4298
+ * `POST /user/employees/{user_id}/reset-password`
4299
+ *
4300
+ * Needs the *Users* write permission and the *Impersonation* permission,
4301
+ * and the member must be one you could sign in as with
4302
+ * `impersonateEmployee`. The member's sessions end, and their next sign-in
4303
+ * asks them to choose a new password. Two-factor authentication is left as
4304
+ * it is. `TeamMemberDetails.can_reset_password` answers the same rule. A
4305
+ * refusal is a `UR_68` error whose `data` is a {@link TeamMemberRefusal}.
4306
+ */
4307
+ async resetTeamMemberPassword(userId, params) {
4308
+ return this.request("POST", `/user/employees/${encodeURIComponent(userId)}/reset-password`, {
4309
+ body: params
4310
+ });
4311
+ }
4279
4312
  /** Sign in via OIDC. `POST /user/oidc` */
4280
4313
  async signInOidc(params) {
4281
4314
  return this.request("POST", "/user/oidc", { body: params });
@@ -5278,6 +5311,25 @@ var Products = class {
5278
5311
  query: { ...query }
5279
5312
  });
5280
5313
  }
5314
+ /**
5315
+ * Which active prices of the named recurring products can start a
5316
+ * subscription on the shop's billing processor account, in the environment
5317
+ * the account is in now. `GET /products/billing-readiness`
5318
+ *
5319
+ * Reads only; subscribing still checks the processor's price before
5320
+ * anything is billed. Unknown ids, one-time products and archived prices
5321
+ * are left out of the answer.
5322
+ *
5323
+ * @param productIds - 1 to 100 product ids.
5324
+ * @param profileId - The shop the products belong to.
5325
+ */
5326
+ async billingReadiness(productIds, profileId, options) {
5327
+ return this.request("GET", "/products/billing-readiness", {
5328
+ ...this.scoped(profileId, options),
5329
+ // One comma-separated value, as the route reads it — not repeated keys.
5330
+ query: { product_ids: productIds.join(",") }
5331
+ });
5332
+ }
5281
5333
  /**
5282
5334
  * Change a product's name, description, image, metadata or category
5283
5335
  * (`category_id: null` makes it uncategorized).
@@ -5927,6 +5979,31 @@ var Subscriptions = class {
5927
5979
  ...options
5928
5980
  });
5929
5981
  }
5982
+ /**
5983
+ * {@link getItems}, with whether the list is only the first part of what the
5984
+ * processor holds. `GET /subscriptions/items`
5985
+ *
5986
+ * The backend states that in the `X-Delopay-Items-Truncated` response
5987
+ * header (Stripe Billing lists its first 100 products), which the plain
5988
+ * {@link getItems} cannot return. Without `limit` and `offset` every item
5989
+ * the billing account offers is listed, up to 500.
5990
+ */
5991
+ async getItemsPage(params, options) {
5992
+ let truncated = false;
5993
+ const items = await this.request(
5994
+ "GET",
5995
+ "/subscriptions/items",
5996
+ {
5997
+ query: params,
5998
+ ...options,
5999
+ onDownloadProgress: (event) => {
6000
+ truncated = event.headers.get("x-delopay-items-truncated")?.toLowerCase() === "true";
6001
+ options?.onDownloadProgress?.(event);
6002
+ }
6003
+ }
6004
+ );
6005
+ return { items, truncated };
6006
+ }
5930
6007
  /**
5931
6008
  * Pause a subscription. `POST /subscriptions/{subscriptionId}/pause`
5932
6009
  *
@@ -5947,13 +6024,64 @@ var Subscriptions = class {
5947
6024
  ...options
5948
6025
  });
5949
6026
  }
5950
- /** Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel` */
6027
+ /**
6028
+ * Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel`
6029
+ *
6030
+ * A subscription in a state it cannot be cancelled from is refused with
6031
+ * `DE_11`; `error.data.reason` then names why (`SubscriptionActionRefusal`).
6032
+ */
5951
6033
  async cancel(subscriptionId, params, options) {
5952
6034
  return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {
5953
6035
  body: params ?? {},
5954
6036
  ...options
5955
6037
  });
5956
6038
  }
6039
+ /**
6040
+ * Read 1 to 50 subscriptions back from their billing processor and mirror
6041
+ * what it reports. `POST /subscriptions/sync`
6042
+ *
6043
+ * Nothing is written at the processor. A status is mirrored only with the
6044
+ * time the processor stamped it with, and never over a newer event already
6045
+ * recorded; a plan only with its own stamp. One result per id, in request
6046
+ * order; one that fails does not stop the others.
6047
+ */
6048
+ async sync(params, options) {
6049
+ return this.request("POST", "/subscriptions/sync", { body: params, ...options });
6050
+ }
6051
+ /**
6052
+ * Read one subscription back from its billing processor and mirror what it
6053
+ * reports, as {@link sync} does, with what the processor reported beside
6054
+ * what the mirror now holds. `POST /subscriptions/{subscriptionId}/sync`
6055
+ */
6056
+ async syncOne(subscriptionId, options) {
6057
+ return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/sync`, {
6058
+ ...options
6059
+ });
6060
+ }
6061
+ /**
6062
+ * List the subscriptions a billing account holds at its processor, and how
6063
+ * each relates to DeloPay's: already held, new (its buyer is a DeloPay
6064
+ * customer), needing a customer, ended, or not adoptable here.
6065
+ * `POST /subscriptions/import/preview`
6066
+ *
6067
+ * Reads only; nothing is written here or at the processor. Creem and
6068
+ * Stripe Billing can be listed; PayPal cannot, which `capabilities` states
6069
+ * (`reason_code: 'listing_unsupported'`).
6070
+ */
6071
+ async importPreview(params, options) {
6072
+ return this.request("POST", "/subscriptions/import/preview", { body: params, ...options });
6073
+ }
6074
+ /**
6075
+ * Take 1 to 25 processor subscriptions over, each through {@link adopt}
6076
+ * with every one of its checks, one after another.
6077
+ * `POST /subscriptions/import/apply`
6078
+ *
6079
+ * One result per selection, in request order; one refused does not stop
6080
+ * the others.
6081
+ */
6082
+ async importApply(params, options) {
6083
+ return this.request("POST", "/subscriptions/import/apply", { body: params, ...options });
6084
+ }
5957
6085
  /**
5958
6086
  * Resolve which of the given payments were raised by a subscription.
5959
6087
  * `POST /subscriptions/payments/lookup`
@@ -10213,6 +10341,38 @@ var CheckoutSession = class {
10213
10341
  }
10214
10342
  );
10215
10343
  }
10344
+ /**
10345
+ * The status a buyer coming back from the processor's checkout may read:
10346
+ * the subscription's status, and whether the processor has reported it yet
10347
+ * (`awaiting_processor`). Construct the session with the `sub_…` id in the
10348
+ * `paymentId` slot.
10349
+ *
10350
+ * Authenticated with the return token (`rt`) the return URL carried, sent as
10351
+ * `Authorization: Bearer <rt>`. That token reads only this, for a day; it is
10352
+ * never the client secret, which this call does not send.
10353
+ *
10354
+ * `GET /subscriptions/return-status/{merchantId}/{subscriptionId}`
10355
+ */
10356
+ async subscriptionReturnStatus(returnToken, options) {
10357
+ if (!returnToken) {
10358
+ throw new DelopayError("This call requires the return token (rt) from the return URL", {
10359
+ status: 0,
10360
+ code: "MISSING_CREDENTIAL",
10361
+ type: "invalid_request"
10362
+ });
10363
+ }
10364
+ return this.client.request(
10365
+ "GET",
10366
+ `/subscriptions/return-status/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
10367
+ {
10368
+ ...options,
10369
+ headers: {
10370
+ ...withoutCredentialHeaders(options?.headers),
10371
+ Authorization: `Bearer ${returnToken}`
10372
+ }
10373
+ }
10374
+ );
10375
+ }
10216
10376
  /**
10217
10377
  * Confirm a subscription (PayPal approval rail). The client secret is
10218
10378
  * attached automatically; the shop's profile id travels as the