@delopay/sdk 0.188.0 → 0.190.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.js CHANGED
@@ -216,7 +216,7 @@ import {
216
216
  validatePanes,
217
217
  verticalGapValue,
218
218
  visibleCustomFields
219
- } from "./chunk-7M6HDH2Q.js";
219
+ } from "./chunk-YNJUCISZ.js";
220
220
  export {
221
221
  AIRWALLEX_AUTOFILL_TREATMENTS,
222
222
  AIRWALLEX_CARD_LAYOUTS,
package/dist/internal.cjs CHANGED
@@ -5291,6 +5291,25 @@ var Products = class {
5291
5291
  query: { ...query }
5292
5292
  });
5293
5293
  }
5294
+ /**
5295
+ * Which active prices of the named recurring products can start a
5296
+ * subscription on the shop's billing processor account, in the environment
5297
+ * the account is in now. `GET /products/billing-readiness`
5298
+ *
5299
+ * Reads only; subscribing still checks the processor's price before
5300
+ * anything is billed. Unknown ids, one-time products and archived prices
5301
+ * are left out of the answer.
5302
+ *
5303
+ * @param productIds - 1 to 100 product ids.
5304
+ * @param profileId - The shop the products belong to.
5305
+ */
5306
+ async billingReadiness(productIds, profileId, options) {
5307
+ return this.request("GET", "/products/billing-readiness", {
5308
+ ...this.scoped(profileId, options),
5309
+ // One comma-separated value, as the route reads it — not repeated keys.
5310
+ query: { product_ids: productIds.join(",") }
5311
+ });
5312
+ }
5294
5313
  /**
5295
5314
  * Change a product's name, description, image, metadata or category
5296
5315
  * (`category_id: null` makes it uncategorized).
@@ -5940,6 +5959,31 @@ var Subscriptions = class {
5940
5959
  ...options
5941
5960
  });
5942
5961
  }
5962
+ /**
5963
+ * {@link getItems}, with whether the list is only the first part of what the
5964
+ * processor holds. `GET /subscriptions/items`
5965
+ *
5966
+ * The backend states that in the `X-Delopay-Items-Truncated` response
5967
+ * header (Stripe Billing lists its first 100 products), which the plain
5968
+ * {@link getItems} cannot return. Without `limit` and `offset` every item
5969
+ * the billing account offers is listed, up to 500.
5970
+ */
5971
+ async getItemsPage(params, options) {
5972
+ let truncated = false;
5973
+ const items = await this.request(
5974
+ "GET",
5975
+ "/subscriptions/items",
5976
+ {
5977
+ query: params,
5978
+ ...options,
5979
+ onDownloadProgress: (event) => {
5980
+ truncated = event.headers.get("x-delopay-items-truncated")?.toLowerCase() === "true";
5981
+ options?.onDownloadProgress?.(event);
5982
+ }
5983
+ }
5984
+ );
5985
+ return { items, truncated };
5986
+ }
5943
5987
  /**
5944
5988
  * Pause a subscription. `POST /subscriptions/{subscriptionId}/pause`
5945
5989
  *
@@ -5960,13 +6004,64 @@ var Subscriptions = class {
5960
6004
  ...options
5961
6005
  });
5962
6006
  }
5963
- /** Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel` */
6007
+ /**
6008
+ * Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel`
6009
+ *
6010
+ * A subscription in a state it cannot be cancelled from is refused with
6011
+ * `DE_11`; `error.data.reason` then names why (`SubscriptionActionRefusal`).
6012
+ */
5964
6013
  async cancel(subscriptionId, params, options) {
5965
6014
  return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {
5966
6015
  body: params ?? {},
5967
6016
  ...options
5968
6017
  });
5969
6018
  }
6019
+ /**
6020
+ * Read 1 to 50 subscriptions back from their billing processor and mirror
6021
+ * what it reports. `POST /subscriptions/sync`
6022
+ *
6023
+ * Nothing is written at the processor. A status is mirrored only with the
6024
+ * time the processor stamped it with, and never over a newer event already
6025
+ * recorded; a plan only with its own stamp. One result per id, in request
6026
+ * order; one that fails does not stop the others.
6027
+ */
6028
+ async sync(params, options) {
6029
+ return this.request("POST", "/subscriptions/sync", { body: params, ...options });
6030
+ }
6031
+ /**
6032
+ * Read one subscription back from its billing processor and mirror what it
6033
+ * reports, as {@link sync} does, with what the processor reported beside
6034
+ * what the mirror now holds. `POST /subscriptions/{subscriptionId}/sync`
6035
+ */
6036
+ async syncOne(subscriptionId, options) {
6037
+ return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/sync`, {
6038
+ ...options
6039
+ });
6040
+ }
6041
+ /**
6042
+ * List the subscriptions a billing account holds at its processor, and how
6043
+ * each relates to DeloPay's: already held, new (its buyer is a DeloPay
6044
+ * customer), needing a customer, ended, or not adoptable here.
6045
+ * `POST /subscriptions/import/preview`
6046
+ *
6047
+ * Reads only; nothing is written here or at the processor. Creem and
6048
+ * Stripe Billing can be listed; PayPal cannot, which `capabilities` states
6049
+ * (`reason_code: 'listing_unsupported'`).
6050
+ */
6051
+ async importPreview(params, options) {
6052
+ return this.request("POST", "/subscriptions/import/preview", { body: params, ...options });
6053
+ }
6054
+ /**
6055
+ * Take 1 to 25 processor subscriptions over, each through {@link adopt}
6056
+ * with every one of its checks, one after another.
6057
+ * `POST /subscriptions/import/apply`
6058
+ *
6059
+ * One result per selection, in request order; one refused does not stop
6060
+ * the others.
6061
+ */
6062
+ async importApply(params, options) {
6063
+ return this.request("POST", "/subscriptions/import/apply", { body: params, ...options });
6064
+ }
5970
6065
  /**
5971
6066
  * Resolve which of the given payments were raised by a subscription.
5972
6067
  * `POST /subscriptions/payments/lookup`
@@ -10226,6 +10321,38 @@ var CheckoutSession = class {
10226
10321
  }
10227
10322
  );
10228
10323
  }
10324
+ /**
10325
+ * The status a buyer coming back from the processor's checkout may read:
10326
+ * the subscription's status, and whether the processor has reported it yet
10327
+ * (`awaiting_processor`). Construct the session with the `sub_…` id in the
10328
+ * `paymentId` slot.
10329
+ *
10330
+ * Authenticated with the return token (`rt`) the return URL carried, sent as
10331
+ * `Authorization: Bearer <rt>`. That token reads only this, for a day; it is
10332
+ * never the client secret, which this call does not send.
10333
+ *
10334
+ * `GET /subscriptions/return-status/{merchantId}/{subscriptionId}`
10335
+ */
10336
+ async subscriptionReturnStatus(returnToken, options) {
10337
+ if (!returnToken) {
10338
+ throw new DelopayError("This call requires the return token (rt) from the return URL", {
10339
+ status: 0,
10340
+ code: "MISSING_CREDENTIAL",
10341
+ type: "invalid_request"
10342
+ });
10343
+ }
10344
+ return this.client.request(
10345
+ "GET",
10346
+ `/subscriptions/return-status/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
10347
+ {
10348
+ ...options,
10349
+ headers: {
10350
+ ...withoutCredentialHeaders(options?.headers),
10351
+ Authorization: `Bearer ${returnToken}`
10352
+ }
10353
+ }
10354
+ );
10355
+ }
10229
10356
  /**
10230
10357
  * Confirm a subscription (PayPal approval rail). The client secret is
10231
10358
  * attached automatically; the shop's profile id travels as the