@delopay/sdk 0.189.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/README.md +61 -0
- package/dist/{chunk-7M6HDH2Q.js → chunk-YNJUCISZ.js} +129 -2
- package/dist/chunk-YNJUCISZ.js.map +1 -0
- package/dist/index.cjs +128 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +511 -9
- package/dist/index.d.ts +511 -9
- package/dist/index.js +1 -1
- package/dist/internal.cjs +128 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7M6HDH2Q.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5278,6 +5278,25 @@ var Products = class {
|
|
|
5278
5278
|
query: { ...query }
|
|
5279
5279
|
});
|
|
5280
5280
|
}
|
|
5281
|
+
/**
|
|
5282
|
+
* Which active prices of the named recurring products can start a
|
|
5283
|
+
* subscription on the shop's billing processor account, in the environment
|
|
5284
|
+
* the account is in now. `GET /products/billing-readiness`
|
|
5285
|
+
*
|
|
5286
|
+
* Reads only; subscribing still checks the processor's price before
|
|
5287
|
+
* anything is billed. Unknown ids, one-time products and archived prices
|
|
5288
|
+
* are left out of the answer.
|
|
5289
|
+
*
|
|
5290
|
+
* @param productIds - 1 to 100 product ids.
|
|
5291
|
+
* @param profileId - The shop the products belong to.
|
|
5292
|
+
*/
|
|
5293
|
+
async billingReadiness(productIds, profileId, options) {
|
|
5294
|
+
return this.request("GET", "/products/billing-readiness", {
|
|
5295
|
+
...this.scoped(profileId, options),
|
|
5296
|
+
// One comma-separated value, as the route reads it — not repeated keys.
|
|
5297
|
+
query: { product_ids: productIds.join(",") }
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5281
5300
|
/**
|
|
5282
5301
|
* Change a product's name, description, image, metadata or category
|
|
5283
5302
|
* (`category_id: null` makes it uncategorized).
|
|
@@ -5927,6 +5946,31 @@ var Subscriptions = class {
|
|
|
5927
5946
|
...options
|
|
5928
5947
|
});
|
|
5929
5948
|
}
|
|
5949
|
+
/**
|
|
5950
|
+
* {@link getItems}, with whether the list is only the first part of what the
|
|
5951
|
+
* processor holds. `GET /subscriptions/items`
|
|
5952
|
+
*
|
|
5953
|
+
* The backend states that in the `X-Delopay-Items-Truncated` response
|
|
5954
|
+
* header (Stripe Billing lists its first 100 products), which the plain
|
|
5955
|
+
* {@link getItems} cannot return. Without `limit` and `offset` every item
|
|
5956
|
+
* the billing account offers is listed, up to 500.
|
|
5957
|
+
*/
|
|
5958
|
+
async getItemsPage(params, options) {
|
|
5959
|
+
let truncated = false;
|
|
5960
|
+
const items = await this.request(
|
|
5961
|
+
"GET",
|
|
5962
|
+
"/subscriptions/items",
|
|
5963
|
+
{
|
|
5964
|
+
query: params,
|
|
5965
|
+
...options,
|
|
5966
|
+
onDownloadProgress: (event) => {
|
|
5967
|
+
truncated = event.headers.get("x-delopay-items-truncated")?.toLowerCase() === "true";
|
|
5968
|
+
options?.onDownloadProgress?.(event);
|
|
5969
|
+
}
|
|
5970
|
+
}
|
|
5971
|
+
);
|
|
5972
|
+
return { items, truncated };
|
|
5973
|
+
}
|
|
5930
5974
|
/**
|
|
5931
5975
|
* Pause a subscription. `POST /subscriptions/{subscriptionId}/pause`
|
|
5932
5976
|
*
|
|
@@ -5947,13 +5991,64 @@ var Subscriptions = class {
|
|
|
5947
5991
|
...options
|
|
5948
5992
|
});
|
|
5949
5993
|
}
|
|
5950
|
-
/**
|
|
5994
|
+
/**
|
|
5995
|
+
* Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel`
|
|
5996
|
+
*
|
|
5997
|
+
* A subscription in a state it cannot be cancelled from is refused with
|
|
5998
|
+
* `DE_11`; `error.data.reason` then names why (`SubscriptionActionRefusal`).
|
|
5999
|
+
*/
|
|
5951
6000
|
async cancel(subscriptionId, params, options) {
|
|
5952
6001
|
return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {
|
|
5953
6002
|
body: params ?? {},
|
|
5954
6003
|
...options
|
|
5955
6004
|
});
|
|
5956
6005
|
}
|
|
6006
|
+
/**
|
|
6007
|
+
* Read 1 to 50 subscriptions back from their billing processor and mirror
|
|
6008
|
+
* what it reports. `POST /subscriptions/sync`
|
|
6009
|
+
*
|
|
6010
|
+
* Nothing is written at the processor. A status is mirrored only with the
|
|
6011
|
+
* time the processor stamped it with, and never over a newer event already
|
|
6012
|
+
* recorded; a plan only with its own stamp. One result per id, in request
|
|
6013
|
+
* order; one that fails does not stop the others.
|
|
6014
|
+
*/
|
|
6015
|
+
async sync(params, options) {
|
|
6016
|
+
return this.request("POST", "/subscriptions/sync", { body: params, ...options });
|
|
6017
|
+
}
|
|
6018
|
+
/**
|
|
6019
|
+
* Read one subscription back from its billing processor and mirror what it
|
|
6020
|
+
* reports, as {@link sync} does, with what the processor reported beside
|
|
6021
|
+
* what the mirror now holds. `POST /subscriptions/{subscriptionId}/sync`
|
|
6022
|
+
*/
|
|
6023
|
+
async syncOne(subscriptionId, options) {
|
|
6024
|
+
return this.request("POST", `/subscriptions/${encodeURIComponent(subscriptionId)}/sync`, {
|
|
6025
|
+
...options
|
|
6026
|
+
});
|
|
6027
|
+
}
|
|
6028
|
+
/**
|
|
6029
|
+
* List the subscriptions a billing account holds at its processor, and how
|
|
6030
|
+
* each relates to DeloPay's: already held, new (its buyer is a DeloPay
|
|
6031
|
+
* customer), needing a customer, ended, or not adoptable here.
|
|
6032
|
+
* `POST /subscriptions/import/preview`
|
|
6033
|
+
*
|
|
6034
|
+
* Reads only; nothing is written here or at the processor. Creem and
|
|
6035
|
+
* Stripe Billing can be listed; PayPal cannot, which `capabilities` states
|
|
6036
|
+
* (`reason_code: 'listing_unsupported'`).
|
|
6037
|
+
*/
|
|
6038
|
+
async importPreview(params, options) {
|
|
6039
|
+
return this.request("POST", "/subscriptions/import/preview", { body: params, ...options });
|
|
6040
|
+
}
|
|
6041
|
+
/**
|
|
6042
|
+
* Take 1 to 25 processor subscriptions over, each through {@link adopt}
|
|
6043
|
+
* with every one of its checks, one after another.
|
|
6044
|
+
* `POST /subscriptions/import/apply`
|
|
6045
|
+
*
|
|
6046
|
+
* One result per selection, in request order; one refused does not stop
|
|
6047
|
+
* the others.
|
|
6048
|
+
*/
|
|
6049
|
+
async importApply(params, options) {
|
|
6050
|
+
return this.request("POST", "/subscriptions/import/apply", { body: params, ...options });
|
|
6051
|
+
}
|
|
5957
6052
|
/**
|
|
5958
6053
|
* Resolve which of the given payments were raised by a subscription.
|
|
5959
6054
|
* `POST /subscriptions/payments/lookup`
|
|
@@ -10213,6 +10308,38 @@ var CheckoutSession = class {
|
|
|
10213
10308
|
}
|
|
10214
10309
|
);
|
|
10215
10310
|
}
|
|
10311
|
+
/**
|
|
10312
|
+
* The status a buyer coming back from the processor's checkout may read:
|
|
10313
|
+
* the subscription's status, and whether the processor has reported it yet
|
|
10314
|
+
* (`awaiting_processor`). Construct the session with the `sub_…` id in the
|
|
10315
|
+
* `paymentId` slot.
|
|
10316
|
+
*
|
|
10317
|
+
* Authenticated with the return token (`rt`) the return URL carried, sent as
|
|
10318
|
+
* `Authorization: Bearer <rt>`. That token reads only this, for a day; it is
|
|
10319
|
+
* never the client secret, which this call does not send.
|
|
10320
|
+
*
|
|
10321
|
+
* `GET /subscriptions/return-status/{merchantId}/{subscriptionId}`
|
|
10322
|
+
*/
|
|
10323
|
+
async subscriptionReturnStatus(returnToken, options) {
|
|
10324
|
+
if (!returnToken) {
|
|
10325
|
+
throw new DelopayError("This call requires the return token (rt) from the return URL", {
|
|
10326
|
+
status: 0,
|
|
10327
|
+
code: "MISSING_CREDENTIAL",
|
|
10328
|
+
type: "invalid_request"
|
|
10329
|
+
});
|
|
10330
|
+
}
|
|
10331
|
+
return this.client.request(
|
|
10332
|
+
"GET",
|
|
10333
|
+
`/subscriptions/return-status/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
|
|
10334
|
+
{
|
|
10335
|
+
...options,
|
|
10336
|
+
headers: {
|
|
10337
|
+
...withoutCredentialHeaders(options?.headers),
|
|
10338
|
+
Authorization: `Bearer ${returnToken}`
|
|
10339
|
+
}
|
|
10340
|
+
}
|
|
10341
|
+
);
|
|
10342
|
+
}
|
|
10216
10343
|
/**
|
|
10217
10344
|
* Confirm a subscription (PayPal approval rail). The client secret is
|
|
10218
10345
|
* attached automatically; the shop's profile id travels as the
|