@delopay/sdk 0.147.0 → 0.149.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
@@ -169,7 +169,7 @@ import {
169
169
  validatePanes,
170
170
  verticalGapValue,
171
171
  visibleCustomFields
172
- } from "./chunk-CK3APM5M.js";
172
+ } from "./chunk-DQOEWKNX.js";
173
173
  export {
174
174
  AIRWALLEX_AUTOFILL_TREATMENTS,
175
175
  AIRWALLEX_CARD_LAYOUTS,
package/dist/internal.cjs CHANGED
@@ -1361,7 +1361,7 @@ var Events = class {
1361
1361
  }
1362
1362
  /**
1363
1363
  * Fire an outgoing webhook event by hand for one object.
1364
- * `POST /events/{merchant_id}/trigger` (be#318)
1364
+ * `POST /events/{merchant_id}/trigger`
1365
1365
  *
1366
1366
  * Not a replay — see {@link EventManualTriggerRequest}. Needs the
1367
1367
  * `WebhookEventTrigger` permission, which is separate from the one that
@@ -1384,7 +1384,7 @@ var Events = class {
1384
1384
  }
1385
1385
  /**
1386
1386
  * Fire an outgoing webhook event by hand (profile-scoped).
1387
- * `POST /events/profile/trigger` (be#318)
1387
+ * `POST /events/profile/trigger`
1388
1388
  *
1389
1389
  * The shop-user twin of {@link trigger}; the shop is taken from the auth
1390
1390
  * context, so `profile_id` on the body is ignored.
@@ -2077,9 +2077,8 @@ var Payments = class {
2077
2077
  );
2078
2078
  }
2079
2079
  /**
2080
- * Open a playback of the payment's stored checkout recording
2081
- * (delopay-backend#1501, delopay-control-center#779): the audited act of
2082
- * watching. Answers the manifest — which slices exist, how long the
2080
+ * Open a playback of the payment's stored checkout recording: the audited
2081
+ * act of watching. Answers the manifest — which slices exist, how long the
2083
2082
  * recording runs, whether a pause in it is expected — and the
2084
2083
  * `playback_id` every {@link Payments.replaySlice} call carries.
2085
2084
  *
@@ -4689,6 +4688,15 @@ var Audit = class {
4689
4688
  };
4690
4689
 
4691
4690
  // src/resources/settlement.ts
4691
+ function exportHeaders(options, accept) {
4692
+ const headers = new Headers(options?.headers);
4693
+ headers.set("Accept", accept);
4694
+ const output = {};
4695
+ headers.forEach((value, key) => {
4696
+ output[key] = value;
4697
+ });
4698
+ return output;
4699
+ }
4692
4700
  var Settlement = class {
4693
4701
  constructor(request) {
4694
4702
  this.request = request;
@@ -4841,6 +4849,45 @@ var Settlement = class {
4841
4849
  { body: params, ...options }
4842
4850
  );
4843
4851
  }
4852
+ /** Append one external transfer record. Send a stable idempotency_key for safe retries. */
4853
+ async recordStatementPayout(statementId, params, options) {
4854
+ return this.request(
4855
+ "POST",
4856
+ `/settlement/statements/${encodeURIComponent(statementId)}/payout`,
4857
+ {
4858
+ body: params,
4859
+ ...options,
4860
+ bodyIdempotencyKey: params.idempotency_key ?? null
4861
+ }
4862
+ );
4863
+ }
4864
+ /** Read individual transfer records, their signed total, and any overpayment. */
4865
+ async listStatementPayouts(statementId, options) {
4866
+ return this.request(
4867
+ "GET",
4868
+ `/settlement/statements/${encodeURIComponent(statementId)}/payouts`,
4869
+ options
4870
+ );
4871
+ }
4872
+ /** Record a transfer against a shop's month before its statement exists. */
4873
+ async recordAdvance(params, options) {
4874
+ return this.request("POST", "/settlement/advances", {
4875
+ body: params,
4876
+ ...options,
4877
+ bodyIdempotencyKey: params.idempotency_key ?? null
4878
+ });
4879
+ }
4880
+ async listAdvances(params, options) {
4881
+ return this.request("GET", "/settlement/advances", {
4882
+ query: {
4883
+ profile_id: params.profile_id,
4884
+ year: params.year,
4885
+ month: params.month,
4886
+ test_mode: params.test_mode
4887
+ },
4888
+ ...options
4889
+ });
4890
+ }
4844
4891
  /**
4845
4892
  * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with
4846
4893
  * the same auth, retries and error handling as every other call — persist
@@ -4958,6 +5005,109 @@ var Settlement = class {
4958
5005
  options
4959
5006
  );
4960
5007
  }
5008
+ /**
5009
+ * Calculate a period in its transaction currency. Requires a host-level
5010
+ * dashboard JWT and settlement read permission. Profile users and roles
5011
+ * restricted to selected connector accounts cannot read this aggregate.
5012
+ * Rates apply once to the period total. Unknown or estimated fees keep
5013
+ * dependent amounts provisional. Native money values remain integer strings.
5014
+ */
5015
+ async previewNative(params, options) {
5016
+ return this.request("POST", "/settlement/native/preview", { body: params, ...options });
5017
+ }
5018
+ /**
5019
+ * Recalculate and freeze an immutable report version. Requires settlement
5020
+ * edit permission. Explicitly allow provisional figures when source fees
5021
+ * are incomplete. A report records a calculation and sends no money.
5022
+ * Reuse the same idempotency key when retrying the same request.
5023
+ */
5024
+ async createNativeReport(params, options) {
5025
+ return this.request("POST", "/settlement/native/reports", {
5026
+ body: params,
5027
+ ...options,
5028
+ bodyIdempotencyKey: params.idempotency_key
5029
+ });
5030
+ }
5031
+ async retrieveNativeReport(reportId, options) {
5032
+ return this.request(
5033
+ "GET",
5034
+ `/settlement/native/reports/${encodeURIComponent(reportId)}`,
5035
+ options
5036
+ );
5037
+ }
5038
+ /** List report summaries without fetching every source row in each saved snapshot. */
5039
+ async listNativeReports(params, options) {
5040
+ return this.request("GET", "/settlement/native/reports", {
5041
+ query: {
5042
+ profile_id: params.profile_id,
5043
+ currency: params.currency,
5044
+ test_mode: params.test_mode,
5045
+ limit: params.limit,
5046
+ offset: params.offset
5047
+ },
5048
+ ...options
5049
+ });
5050
+ }
5051
+ /**
5052
+ * Record a transfer already made, under settlement write permission and
5053
+ * the caller's payout limits. This method never sends money. Native minor
5054
+ * units remain strings; negative records must name a same-scope reversal.
5055
+ * These records belong to the native ledger, separate from monthly USD
5056
+ * statement payouts and advances.
5057
+ */
5058
+ async recordNativePayout(params, options) {
5059
+ return this.request("POST", "/settlement/native/payouts", {
5060
+ body: params,
5061
+ ...options,
5062
+ bodyIdempotencyKey: params.idempotency_key
5063
+ });
5064
+ }
5065
+ async listNativePayouts(params, options) {
5066
+ return this.request("GET", "/settlement/native/payouts", {
5067
+ query: {
5068
+ profile_id: params.profile_id,
5069
+ currency: params.currency,
5070
+ test_mode: params.test_mode,
5071
+ limit: params.limit,
5072
+ offset: params.offset
5073
+ },
5074
+ ...options
5075
+ });
5076
+ }
5077
+ /** Refresh a bounded page of provider fee evidence. Follow next_offset while has_more is true. */
5078
+ async refreshNativeFees(params, options) {
5079
+ return this.request("POST", "/settlement/native/fees/refresh", { body: params, ...options });
5080
+ }
5081
+ async downloadNativeReportPdf(reportId, params, options) {
5082
+ return this.request("GET", `/settlement/native/reports/${encodeURIComponent(reportId)}/pdf`, {
5083
+ query: { include_transactions: params?.include_transactions },
5084
+ responseType: "blob",
5085
+ ...options
5086
+ });
5087
+ }
5088
+ /** Download the frozen source rows and calculation as CSV. */
5089
+ async downloadNativeReportCsv(reportId, options) {
5090
+ return this.request(
5091
+ "GET",
5092
+ `/settlement/native/reports/${encodeURIComponent(reportId)}/export`,
5093
+ {
5094
+ ...options,
5095
+ headers: exportHeaders(options, "text/csv"),
5096
+ responseType: "blob"
5097
+ }
5098
+ );
5099
+ }
5100
+ /** Export the frozen report as JSON, excluding host account-level costs. */
5101
+ async exportNativeReportJson(reportId, options) {
5102
+ return this.request(
5103
+ "GET",
5104
+ `/settlement/native/reports/${encodeURIComponent(reportId)}/export`,
5105
+ {
5106
+ ...options,
5107
+ headers: exportHeaders(options, "application/json")
5108
+ }
5109
+ );
5110
+ }
4961
5111
  };
4962
5112
 
4963
5113
  // src/resources/operationLimits.ts
@@ -5315,7 +5465,7 @@ var Delopay = class {
5315
5465
  url += `?${qs}`;
5316
5466
  }
5317
5467
  }
5318
- const headers = {
5468
+ let headers = {
5319
5469
  ...this.jwtToken ? { Authorization: `Bearer ${this.jwtToken}` } : this.apiKey ? { "api-key": this.apiKey } : {},
5320
5470
  ...options?.headers
5321
5471
  };
@@ -5323,14 +5473,40 @@ var Delopay = class {
5323
5473
  if (options?.body && !isRawBody) {
5324
5474
  headers["Content-Type"] = "application/json";
5325
5475
  }
5326
- const idempotencyKey = findIdempotencyKey(headers)?.trim();
5327
- const isRetryable = method === "GET" || method === "DELETE" || idempotencyKey !== void 0 && idempotencyKey !== "";
5328
5476
  let serializedBody;
5329
5477
  if (isRawBody) {
5330
5478
  serializedBody = options?.body;
5331
5479
  } else if (options?.body) {
5332
5480
  serializedBody = JSON.stringify(options.body);
5333
5481
  }
5482
+ let idempotencyKey = findIdempotencyKey(headers)?.trim();
5483
+ if (options && Object.prototype.hasOwnProperty.call(options, "bodyIdempotencyKey")) {
5484
+ const bodyKey = options?.bodyIdempotencyKey;
5485
+ const serialized = !isRawBody && typeof serializedBody === "string" ? JSON.parse(serializedBody) : null;
5486
+ const actualKey = serialized && typeof serialized === "object" && !Array.isArray(serialized) ? serialized.idempotency_key ?? null : null;
5487
+ const suppliedHeaders = Object.keys(headers).filter(
5488
+ (name) => name.toLowerCase() === "idempotency-key"
5489
+ );
5490
+ if (bodyKey !== null && typeof bodyKey !== "string" || actualKey !== bodyKey || suppliedHeaders.some(
5491
+ (name) => headers[name] !== bodyKey || headers[name]?.trim() !== headers[name]
5492
+ )) {
5493
+ throw new DelopayError("Request retry keys must match the JSON body key", {
5494
+ status: 0,
5495
+ code: "IDEMPOTENCY_KEY_MISMATCH",
5496
+ type: "invalid_request"
5497
+ });
5498
+ }
5499
+ idempotencyKey = bodyKey?.trim();
5500
+ if (suppliedHeaders.length > 0) {
5501
+ headers = {
5502
+ ...Object.fromEntries(
5503
+ Object.entries(headers).filter(([name]) => name.toLowerCase() !== "idempotency-key")
5504
+ ),
5505
+ "Idempotency-Key": idempotencyKey ?? ""
5506
+ };
5507
+ }
5508
+ }
5509
+ const isRetryable = method === "GET" || method === "DELETE" || idempotencyKey !== void 0 && idempotencyKey !== "";
5334
5510
  const callerSignal = options?.signal;
5335
5511
  if (callerSignal?.aborted) {
5336
5512
  throw new DelopayError("Request aborted", {
@@ -7671,10 +7847,9 @@ var CheckoutSession = class {
7671
7847
  }
7672
7848
  }
7673
7849
  /**
7674
- * Store one slice of the buyer's checkout recording on our own side
7675
- * (delopay-backend#1501, delopay-control-center#779). Called by the hosted
7676
- * checkout as the buyer works through the page; the client secret is
7677
- * attached automatically.
7850
+ * Store one slice of the buyer's checkout recording on our own side.
7851
+ * Called by the hosted checkout as the buyer works through the page; the
7852
+ * client secret is attached automatically.
7678
7853
  *
7679
7854
  * **Not telemetry semantics, on purpose.** Unlike
7680
7855
  * {@link CheckoutSession.recordEvent}, this rejects with a `DelopayError`
@@ -7730,20 +7905,6 @@ var CheckoutSession = class {
7730
7905
  }
7731
7906
  );
7732
7907
  }
7733
- /**
7734
- * The Paysepro rail catalog for the buyer's country.
7735
- *
7736
- * `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`
7737
- *
7738
- * @param country - Lowercase ISO 3166-1 alpha-2 country code.
7739
- */
7740
- async payseproMethods(country, options) {
7741
- return this.client.request("GET", `${this.linkBase}/paysepro/methods`, {
7742
- query: { cc: country },
7743
- ...options,
7744
- headers: this.bearerHeaders(options?.headers)
7745
- });
7746
- }
7747
7908
  /**
7748
7909
  * The e-Payouts rail catalog for the buyer's country, plus the set of
7749
7910
  * countries that have at least one vendor.
@@ -8679,7 +8840,7 @@ var AdminPortal = class {
8679
8840
  }
8680
8841
  /**
8681
8842
  * What the rail charged for one attempt of a transaction of ANY merchant,
8682
- * off the attempt's settlement line (be#843). `line_recorded: false` means
8843
+ * off the attempt's settlement line. `line_recorded: false` means
8683
8844
  * no line exists for the attempt; an absent amount is "no figure", never
8684
8845
  * zero.
8685
8846
  *