@delopay/sdk 0.365.0 → 0.368.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.
@@ -935,9 +935,9 @@ var Connectors = class {
935
935
  * to a single event.
936
936
  */
937
937
  async registerWebhook(merchantId, connectorId, params) {
938
- const path = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
939
- if (params === void 0) return this.request("POST", path);
940
- return this.request("POST", path, { body: params });
938
+ const path2 = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;
939
+ if (params === void 0) return this.request("POST", path2);
940
+ return this.request("POST", path2, { body: params });
941
941
  }
942
942
  /**
943
943
  * Register checkout/shop domains as Stripe payment method domains, so Apple
@@ -1735,11 +1735,11 @@ function negotiated(options, format, presentation) {
1735
1735
  }
1736
1736
  return format === "json" ? { ...options, headers } : { ...options, headers, responseType: "blob" };
1737
1737
  }
1738
- function runExport(request, method, path, base, options) {
1738
+ function runExport(request, method, path2, base, options) {
1739
1739
  const format = options?.format ?? "json";
1740
1740
  return downloadExport(
1741
1741
  request,
1742
- { method, path, request: negotiated(base, format, options?.presentation), format },
1742
+ { method, path: path2, request: negotiated(base, format, options?.presentation), format },
1743
1743
  options
1744
1744
  );
1745
1745
  }
@@ -2000,6 +2000,34 @@ var ChargebackPrevention = class {
2000
2000
  async retrieveCase(caseId) {
2001
2001
  return this.request("GET", `/chargeback-prevention/cases/${encodeURIComponent(caseId)}`);
2002
2002
  }
2003
+ /**
2004
+ * The refund rule of every connected account and environment; version `0`
2005
+ * and off for one never saved. Needs a merchant-wide key or sign-in.
2006
+ */
2007
+ async listRefundRules() {
2008
+ return this.request("GET", "/chargeback-prevention/refund-rules");
2009
+ }
2010
+ /**
2011
+ * Save a refund rule over the version read. Dashboard sign-in only, by a
2012
+ * merchant-wide user who may write refunds; an API key is refused. A rule
2013
+ * saved since the version named is not overwritten: the call fails.
2014
+ */
2015
+ async saveRefundRule(body) {
2016
+ return this.request("PUT", "/chargeback-prevention/refund-rules", { body });
2017
+ }
2018
+ /**
2019
+ * What the stored rule, or unsaved `settings`, would do with each open
2020
+ * alert of the account now. Nothing is refunded.
2021
+ */
2022
+ async previewRefundRule(body) {
2023
+ return this.request("POST", "/chargeback-prevention/refund-rules/preview", { body });
2024
+ }
2025
+ /** What the merchant's refund rules did, newest first. */
2026
+ async listRefundActions(params) {
2027
+ return this.request("GET", "/chargeback-prevention/refund-actions", {
2028
+ query: params
2029
+ });
2030
+ }
2003
2031
  };
2004
2032
 
2005
2033
  // src/resources/paypalDisputes.ts
@@ -2712,15 +2740,15 @@ var Payments = class {
2712
2740
  * ```
2713
2741
  */
2714
2742
  async retrieve(paymentId, options) {
2715
- const path = `/payments/${encodeURIComponent(paymentId)}`;
2716
- if (options === void 0) return this.request("GET", path);
2743
+ const path2 = `/payments/${encodeURIComponent(paymentId)}`;
2744
+ if (options === void 0) return this.request("GET", path2);
2717
2745
  const query = {};
2718
2746
  if (options.force_sync !== void 0) query["force_sync"] = options.force_sync;
2719
2747
  if (options.all_keys_required !== void 0) {
2720
2748
  query["all_keys_required"] = options.all_keys_required;
2721
2749
  }
2722
- if (Object.keys(query).length === 0) return this.request("GET", path);
2723
- return this.request("GET", path, { query });
2750
+ if (Object.keys(query).length === 0) return this.request("GET", path2);
2751
+ return this.request("GET", path2, { query });
2724
2752
  }
2725
2753
  /**
2726
2754
  * The payment's buyer risk evaluations, newest first (at most 50): each
@@ -3075,6 +3103,36 @@ var Payments = class {
3075
3103
  options
3076
3104
  );
3077
3105
  }
3106
+ /**
3107
+ * The statement name and suffix each attempt of a payment asked for and was
3108
+ * sent to its provider with. A name the merchant, the shop or the connector
3109
+ * account configures replaces the payment's own: `name_ignored` /
3110
+ * `suffix_ignored` say the payment's value was not used, and a `null` sent
3111
+ * value leaves the provider account's own default.
3112
+ *
3113
+ * Only attempts with a record are listed: one that carried no name and was
3114
+ * sent none, or ran before the record existed, is absent.
3115
+ *
3116
+ * `GET /payments/{paymentId}/statement-descriptors`
3117
+ *
3118
+ * @param paymentId - The payment intent ID.
3119
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
3120
+ * override, and an `AbortSignal`.
3121
+ *
3122
+ * @example
3123
+ * ```typescript
3124
+ * const { attempts } = await delopay.payments.statementDescriptors('pay_abc123');
3125
+ * const last = attempts.at(-1);
3126
+ * if (last?.name_ignored) console.log(`Sent as ${last.sent_name}`);
3127
+ * ```
3128
+ */
3129
+ async statementDescriptors(paymentId, options) {
3130
+ return this.request(
3131
+ "GET",
3132
+ `/payments/${encodeURIComponent(paymentId)}/statement-descriptors`,
3133
+ options
3134
+ );
3135
+ }
3078
3136
  /**
3079
3137
  * Open a playback of the payment's stored checkout recording: the audited
3080
3138
  * act of watching. Answers the manifest — which slices exist, how long the
@@ -3600,9 +3658,9 @@ var Projects = class {
3600
3658
  * @returns The project.
3601
3659
  */
3602
3660
  async retrieve(projectId, merchantId) {
3603
- const path = `/projects/${encodeURIComponent(projectId)}`;
3604
- if (merchantId === void 0) return this.request("GET", path);
3605
- return this.request("GET", path, { query: { merchant_id: merchantId } });
3661
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
3662
+ if (merchantId === void 0) return this.request("GET", path2);
3663
+ return this.request("GET", path2, { query: { merchant_id: merchantId } });
3606
3664
  }
3607
3665
  /**
3608
3666
  * Update a project's details, or move it with `parent_id` (omitted keeps the
@@ -3620,9 +3678,9 @@ var Projects = class {
3620
3678
  * @returns The updated project.
3621
3679
  */
3622
3680
  async update(projectId, params, merchantId, options) {
3623
- const path = `/projects/${encodeURIComponent(projectId)}`;
3624
- if (merchantId === void 0) return this.request("PUT", path, { body: params, ...options });
3625
- return this.request("PUT", path, {
3681
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
3682
+ if (merchantId === void 0) return this.request("PUT", path2, { body: params, ...options });
3683
+ return this.request("PUT", path2, {
3626
3684
  body: params,
3627
3685
  query: { merchant_id: merchantId },
3628
3686
  ...options
@@ -3639,9 +3697,9 @@ var Projects = class {
3639
3697
  * @returns The deleted project object.
3640
3698
  */
3641
3699
  async delete(projectId, merchantId) {
3642
- const path = `/projects/${encodeURIComponent(projectId)}`;
3643
- if (merchantId === void 0) return this.request("DELETE", path);
3644
- return this.request("DELETE", path, { query: { merchant_id: merchantId } });
3700
+ const path2 = `/projects/${encodeURIComponent(projectId)}`;
3701
+ if (merchantId === void 0) return this.request("DELETE", path2);
3702
+ return this.request("DELETE", path2, { query: { merchant_id: merchantId } });
3645
3703
  }
3646
3704
  /**
3647
3705
  * List all projects for a merchant, at every level, as a flat array. Rebuild
@@ -4646,9 +4704,9 @@ var Shops = class {
4646
4704
  * ```
4647
4705
  */
4648
4706
  async stats(merchantId, shopId, period) {
4649
- const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
4650
- if (period === void 0) return this.request("GET", path);
4651
- return this.request("GET", path, { query: { period: String(period) } });
4707
+ const path2 = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;
4708
+ if (period === void 0) return this.request("GET", path2);
4709
+ return this.request("GET", path2, { query: { period: String(period) } });
4652
4710
  }
4653
4711
  /**
4654
4712
  * Upload a logo file for a shop. The file is stored in Delopay's configured
@@ -7933,6 +7991,69 @@ var Products = class {
7933
7991
  }
7934
7992
  };
7935
7993
 
7994
+ // src/resources/support.ts
7995
+ var path = (id) => `/support/conversations/${encodeURIComponent(id)}`;
7996
+ var Support = class {
7997
+ constructor(request) {
7998
+ this.request = request;
7999
+ }
8000
+ /** Start a conversation with its first message. `POST /support/conversations` */
8001
+ async create(body) {
8002
+ return this.request("POST", "/support/conversations", { body });
8003
+ }
8004
+ /** The conversations the caller may read. `GET /support/conversations` */
8005
+ async list(query) {
8006
+ return this.request("GET", "/support/conversations", {
8007
+ query: query === void 0 ? void 0 : { ...query }
8008
+ });
8009
+ }
8010
+ /** One conversation. `GET /support/conversations/{id}` */
8011
+ async retrieve(id) {
8012
+ return this.request("GET", path(id));
8013
+ }
8014
+ /** A conversation's messages. `GET /support/conversations/{id}/messages` */
8015
+ async messages(id, query) {
8016
+ return this.request("GET", `${path(id)}/messages`, {
8017
+ query: query === void 0 ? void 0 : { ...query }
8018
+ });
8019
+ }
8020
+ /** Answer in a conversation. `POST /support/conversations/{id}/messages` */
8021
+ async reply(id, body) {
8022
+ return this.request("POST", `${path(id)}/messages`, { body });
8023
+ }
8024
+ /**
8025
+ * Upload a file for a message. PNG, JPEG, WebP, PDF, text, MP4 or WebM, read from the
8026
+ * content; 10 MB, a video 25 MB. It belongs to the caller until a message names it in
8027
+ * `attachments`. Uploading again with the same `clientUploadId` returns the same file.
8028
+ * `POST /support/conversations/{id}/attachments`
8029
+ */
8030
+ async uploadAttachment(id, file, clientUploadId, fileName) {
8031
+ const form = new FormData();
8032
+ form.append("client_upload_id", clientUploadId);
8033
+ if (fileName === void 0) form.append("file", file);
8034
+ else form.append("file", file, fileName);
8035
+ return this.request("POST", `${path(id)}/attachments`, { body: form });
8036
+ }
8037
+ /**
8038
+ * Fetch a file once its scan is clean. Refused with `support_attachment_checking` while
8039
+ * the scan runs, and `support_attachment_blocked` after a block.
8040
+ * `GET /support/conversations/{id}/attachments/{fileId}`
8041
+ */
8042
+ async downloadAttachment(id, fileId) {
8043
+ return this.request("GET", `${path(id)}/attachments/${encodeURIComponent(fileId)}`, {
8044
+ responseType: "blob"
8045
+ });
8046
+ }
8047
+ /**
8048
+ * Clear the merchant's unread mark and read the conversation as it is now.
8049
+ * Someone acting as somebody else leaves the mark in place.
8050
+ * `POST /support/conversations/{id}/read`
8051
+ */
8052
+ async markRead(id) {
8053
+ return this.request("POST", `${path(id)}/read`);
8054
+ }
8055
+ };
8056
+
7936
8057
  // src/resources/invoices.ts
7937
8058
  var Invoices = class {
7938
8059
  constructor(request) {
@@ -10401,8 +10522,8 @@ var LiveEventStream = class {
10401
10522
  return toLiveStreamEvent(dispatch.event, this._lastEventId, this._retry);
10402
10523
  }
10403
10524
  };
10404
- async function openLiveStream(openStream, path, options = {}) {
10405
- const connection = await openStream(path, {
10525
+ async function openLiveStream(openStream, path2, options = {}) {
10526
+ const connection = await openStream(path2, {
10406
10527
  ...options.lastEventId ? { lastEventId: options.lastEventId } : {},
10407
10528
  ...options.signal ? { signal: options.signal } : {},
10408
10529
  ...options.idleTimeoutMs !== void 0 ? { idleTimeoutMs: options.idleTimeoutMs } : {},
@@ -10589,8 +10710,8 @@ var ProcessorImports = class {
10589
10710
 
10590
10711
  // src/resources/deploymentBranding.ts
10591
10712
  function brandingAssetPath(asset, version) {
10592
- const path = `/branding/assets/${encodeURIComponent(asset)}`;
10593
- return version ? `${path}?v=${encodeURIComponent(version)}` : path;
10713
+ const path2 = `/branding/assets/${encodeURIComponent(asset)}`;
10714
+ return version ? `${path2}?v=${encodeURIComponent(version)}` : path2;
10594
10715
  }
10595
10716
  var Branding = class {
10596
10717
  constructor(request, baseUrl) {
@@ -10924,6 +11045,7 @@ var Delopay = class {
10924
11045
  this.costRules = new CostRules(request);
10925
11046
  this.externalRecords = new ExternalRecords(request);
10926
11047
  this.products = new Products(request);
11048
+ this.support = new Support(request);
10927
11049
  this.invoices = new Invoices(request);
10928
11050
  this.invoiceSettings = new InvoiceSettingsResource(request);
10929
11051
  this.processorCosts = new ProcessorCosts(request);
@@ -10984,8 +11106,8 @@ var Delopay = class {
10984
11106
  return response;
10985
11107
  }
10986
11108
  /** `path` on the base URL, with the query string `query` makes. */
10987
- buildUrl(path, query) {
10988
- let url = `${this.baseUrl}${path}`;
11109
+ buildUrl(path2, query) {
11110
+ let url = `${this.baseUrl}${path2}`;
10989
11111
  if (query) {
10990
11112
  const params = new URLSearchParams();
10991
11113
  for (const [key, value] of Object.entries(query)) {
@@ -11055,8 +11177,8 @@ var Delopay = class {
11055
11177
  * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and
11056
11178
  * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.
11057
11179
  */
11058
- async openEventStream(path, options = {}) {
11059
- const url = this.buildUrl(path, options.query);
11180
+ async openEventStream(path2, options = {}) {
11181
+ const url = this.buildUrl(path2, options.query);
11060
11182
  const lastEventId = options.lastEventId ?? "";
11061
11183
  const headers = {
11062
11184
  ...this.authHeaders(),
@@ -11096,7 +11218,7 @@ var Delopay = class {
11096
11218
  `Network error: ${cause instanceof Error ? cause.message : String(cause ?? "stream failed")}`,
11097
11219
  { status: 0, code: "NETWORK", type: "network_error" }
11098
11220
  );
11099
- this.log("request", { method: "GET", url: redactUrlForLogging(url), path });
11221
+ this.log("request", { method: "GET", url: redactUrlForLogging(url), path: path2 });
11100
11222
  startIdleTimer();
11101
11223
  let response;
11102
11224
  try {
@@ -11108,7 +11230,7 @@ var Delopay = class {
11108
11230
  throw network(err);
11109
11231
  }
11110
11232
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11111
- this.log("response", { status: response.status, method: "GET", path, requestId });
11233
+ this.log("response", { status: response.status, method: "GET", path: path2, requestId });
11112
11234
  if (!response.ok) {
11113
11235
  const error = await errorFromResponse(response, requestId);
11114
11236
  release();
@@ -11194,8 +11316,8 @@ var Delopay = class {
11194
11316
  * @throws {DelopayAuthenticationError} On 401 responses.
11195
11317
  * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.
11196
11318
  */
11197
- async request(method, path, options) {
11198
- const url = this.buildUrl(path, options?.query);
11319
+ async request(method, path2, options) {
11320
+ const url = this.buildUrl(path2, options?.query);
11199
11321
  let headers = {
11200
11322
  ...this.authHeaders(),
11201
11323
  ...this.profileHeaders(options?.headers),
@@ -11259,7 +11381,7 @@ var Delopay = class {
11259
11381
  const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);
11260
11382
  retryAfterOverrideMs = null;
11261
11383
  await new Promise((resolve) => setTimeout(resolve, delay));
11262
- emit("retry", { attempt, maxRetries: this.maxRetries, method, path });
11384
+ emit("retry", { attempt, maxRetries: this.maxRetries, method, path: path2 });
11263
11385
  }
11264
11386
  const timeoutCtrl = new AbortController();
11265
11387
  let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);
@@ -11272,7 +11394,7 @@ var Delopay = class {
11272
11394
  callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal]
11273
11395
  );
11274
11396
  try {
11275
- emit("request", { method, url: safeUrl(), path });
11397
+ emit("request", { method, url: safeUrl(), path: path2 });
11276
11398
  const response = await fetch(url, {
11277
11399
  method,
11278
11400
  headers,
@@ -11281,7 +11403,7 @@ var Delopay = class {
11281
11403
  ...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
11282
11404
  });
11283
11405
  const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
11284
- emit("response", { status: response.status, method, path, requestId });
11406
+ emit("response", { status: response.status, method, path: path2, requestId });
11285
11407
  if (!response.ok) {
11286
11408
  const error = await errorFromResponse(response, requestId);
11287
11409
  const isTransientStatus = response.status >= 500 || response.status === 429;
@@ -16613,7 +16735,7 @@ function encodePanes(panes) {
16613
16735
  var OPAQUE_PAYMENT_LINK_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
16614
16736
  function focusedCheckoutUrl(params) {
16615
16737
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16616
- const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16738
+ const path2 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16617
16739
  params.paymentId
16618
16740
  )}`;
16619
16741
  const query = new URLSearchParams({ pane: params.method });
@@ -16623,16 +16745,16 @@ function focusedCheckoutUrl(params) {
16623
16745
  if (merchantConnectorId) query.set("mca", merchantConnectorId);
16624
16746
  if (params.locale) query.set("locale", params.locale);
16625
16747
  if (params.customFieldsCollected) query.set("cf", "1");
16626
- return `${path}?${query.toString()}`;
16748
+ return `${path2}?${query.toString()}`;
16627
16749
  }
16628
16750
  function checkoutEntryUrl(params) {
16629
16751
  const base = params.checkoutBaseUrl.replace(/\/+$/, "");
16630
- const path = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16752
+ const path2 = params.paymentLinkId && OPAQUE_PAYMENT_LINK_ID.test(params.paymentLinkId) ? `${base}/pay/${params.paymentLinkId}` : `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
16631
16753
  params.paymentId
16632
16754
  )}`;
16633
16755
  const query = new URLSearchParams({ entry: params.entry.trim() });
16634
16756
  if (params.locale) query.set("locale", params.locale);
16635
- return `${path}?${query.toString()}`;
16757
+ return `${path2}?${query.toString()}`;
16636
16758
  }
16637
16759
  function isCheckoutOpenEntryMessage(data) {
16638
16760
  if (typeof data !== "object" || data === null) return false;
@@ -16698,6 +16820,7 @@ export {
16698
16820
  CostRules,
16699
16821
  ExternalRecords,
16700
16822
  Products,
16823
+ Support,
16701
16824
  Invoices,
16702
16825
  InvoiceSettingsResource,
16703
16826
  ProcessorCosts,
@@ -16967,4 +17090,4 @@ export {
16967
17090
  decodeNativePanes,
16968
17091
  encodeNativePanes
16969
17092
  };
16970
- //# sourceMappingURL=chunk-DBE6IDBL.js.map
17093
+ //# sourceMappingURL=chunk-RD3HP3EY.js.map