@delopay/sdk 0.146.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-NRLTXUV7.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.
@@ -2076,6 +2076,61 @@ var Payments = class {
2076
2076
  options
2077
2077
  );
2078
2078
  }
2079
+ /**
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
2082
+ * recording runs, whether a pause in it is expected — and the
2083
+ * `playback_id` every {@link Payments.replaySlice} call carries.
2084
+ *
2085
+ * A payment that was never recorded answers `200` with `slices: []` and
2086
+ * `session_id: null` — the ordinary case for every payment made before the
2087
+ * checkout started recording — not a `404`. `404` means the payment does not
2088
+ * exist. Fetch the slices in `sequence` order; a number missing from the
2089
+ * list is a gap, not the end.
2090
+ *
2091
+ * A `POST`, because it writes one audit row: the SDK retries `GET` on its
2092
+ * own, and a lost response must not open three playbacks. Calling this
2093
+ * again deliberately opens another playback.
2094
+ *
2095
+ * Requires the `PaymentReplay` permission on a dashboard session in addition
2096
+ * to payment read access.
2097
+ *
2098
+ * `POST /payments/{paymentId}/replay/playback`
2099
+ *
2100
+ * @param paymentId - The payment intent ID.
2101
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
2102
+ * override, and an `AbortSignal`.
2103
+ */
2104
+ async openReplayPlayback(paymentId, options) {
2105
+ return this.request(
2106
+ "POST",
2107
+ `/payments/${encodeURIComponent(paymentId)}/replay/playback`,
2108
+ options
2109
+ );
2110
+ }
2111
+ /**
2112
+ * One slice of the payment's stored checkout recording, read against an
2113
+ * open playback: the rrweb events the checkout recorded under that number.
2114
+ * `playbackId` and the numbers come from {@link Payments.openReplayPlayback};
2115
+ * a `playbackId` that names no playback of this payment opened by this
2116
+ * caller, and a number the manifest does not list, both answer `404`.
2117
+ * Not audited per slice — the playback was.
2118
+ *
2119
+ * `GET /payments/{paymentId}/replay/playback/{playbackId}/slices/{sequence}`
2120
+ *
2121
+ * @param paymentId - The payment intent ID.
2122
+ * @param playbackId - The playback, from `openReplayPlayback`.
2123
+ * @param sequence - The slice number, from the playback's manifest.
2124
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
2125
+ * override, and an `AbortSignal`.
2126
+ */
2127
+ async replaySlice(paymentId, playbackId, sequence, options) {
2128
+ return this.request(
2129
+ "GET",
2130
+ `/payments/${encodeURIComponent(paymentId)}/replay/playback/${encodeURIComponent(playbackId)}/slices/${encodeURIComponent(String(sequence))}`,
2131
+ options
2132
+ );
2133
+ }
2079
2134
  /**
2080
2135
  * Soft-delete a payment. Only payments whose status is in the merchant's
2081
2136
  * delete policy (see {@link Payments.getDeletePolicy}) can be deleted;
@@ -4633,6 +4688,15 @@ var Audit = class {
4633
4688
  };
4634
4689
 
4635
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
+ }
4636
4700
  var Settlement = class {
4637
4701
  constructor(request) {
4638
4702
  this.request = request;
@@ -4785,6 +4849,45 @@ var Settlement = class {
4785
4849
  { body: params, ...options }
4786
4850
  );
4787
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
+ }
4788
4891
  /**
4789
4892
  * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with
4790
4893
  * the same auth, retries and error handling as every other call — persist
@@ -4902,6 +5005,109 @@ var Settlement = class {
4902
5005
  options
4903
5006
  );
4904
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
+ }
4905
5111
  };
4906
5112
 
4907
5113
  // src/resources/operationLimits.ts
@@ -5259,7 +5465,7 @@ var Delopay = class {
5259
5465
  url += `?${qs}`;
5260
5466
  }
5261
5467
  }
5262
- const headers = {
5468
+ let headers = {
5263
5469
  ...this.jwtToken ? { Authorization: `Bearer ${this.jwtToken}` } : this.apiKey ? { "api-key": this.apiKey } : {},
5264
5470
  ...options?.headers
5265
5471
  };
@@ -5267,14 +5473,40 @@ var Delopay = class {
5267
5473
  if (options?.body && !isRawBody) {
5268
5474
  headers["Content-Type"] = "application/json";
5269
5475
  }
5270
- const idempotencyKey = findIdempotencyKey(headers)?.trim();
5271
- const isRetryable = method === "GET" || method === "DELETE" || idempotencyKey !== void 0 && idempotencyKey !== "";
5272
5476
  let serializedBody;
5273
5477
  if (isRawBody) {
5274
5478
  serializedBody = options?.body;
5275
5479
  } else if (options?.body) {
5276
5480
  serializedBody = JSON.stringify(options.body);
5277
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 !== "";
5278
5510
  const callerSignal = options?.signal;
5279
5511
  if (callerSignal?.aborted) {
5280
5512
  throw new DelopayError("Request aborted", {
@@ -7614,6 +7846,41 @@ var CheckoutSession = class {
7614
7846
  } catch {
7615
7847
  }
7616
7848
  }
7849
+ /**
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.
7853
+ *
7854
+ * **Not telemetry semantics, on purpose.** Unlike
7855
+ * {@link CheckoutSession.recordEvent}, this rejects with a `DelopayError`
7856
+ * like every other payment call, because the recorder has to tell the
7857
+ * answers apart: a `400` with code `IR_16` means the backend will not take
7858
+ * this recording (recording is off on that deployment, the recording is
7859
+ * full, the payment is already recording a different session, or this
7860
+ * number is stored with different content) and the recorder must stop; any
7861
+ * other `400` is the slice itself being refused; a transport failure may be
7862
+ * retried with the **same** bytes under the **same** number, which the
7863
+ * backend answers with `duplicate: true`.
7864
+ *
7865
+ * Pass `keepalive: true` for the last slice of a page that is navigating
7866
+ * away (a redirect rail); browsers refuse keepalive bodies over ~64 KiB, so
7867
+ * only a small final slice should carry it.
7868
+ *
7869
+ * `POST /payments/{paymentId}/replay/slice` (publishable key)
7870
+ */
7871
+ async storeReplaySlice(params, options) {
7872
+ const { keepalive, ...extras } = options ?? {};
7873
+ return this.client.request(
7874
+ "POST",
7875
+ `/payments/${encodeURIComponent(this.paymentId)}/replay/slice`,
7876
+ {
7877
+ body: { ...params, client_secret: this.requireClientSecret() },
7878
+ ...keepalive !== void 0 ? { keepalive } : {},
7879
+ ...extras,
7880
+ headers: this.pkHeaders(extras.headers)
7881
+ }
7882
+ );
7883
+ }
7617
7884
  /**
7618
7885
  * Confirm a subscription (PayPal approval rail). The client secret is
7619
7886
  * attached automatically; the shop's profile id travels as the
@@ -7638,20 +7905,6 @@ var CheckoutSession = class {
7638
7905
  }
7639
7906
  );
7640
7907
  }
7641
- /**
7642
- * The Paysepro rail catalog for the buyer's country.
7643
- *
7644
- * `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`
7645
- *
7646
- * @param country - Lowercase ISO 3166-1 alpha-2 country code.
7647
- */
7648
- async payseproMethods(country, options) {
7649
- return this.client.request("GET", `${this.linkBase}/paysepro/methods`, {
7650
- query: { cc: country },
7651
- ...options,
7652
- headers: this.bearerHeaders(options?.headers)
7653
- });
7654
- }
7655
7908
  /**
7656
7909
  * The e-Payouts rail catalog for the buyer's country, plus the set of
7657
7910
  * countries that have at least one vendor.
@@ -8587,7 +8840,7 @@ var AdminPortal = class {
8587
8840
  }
8588
8841
  /**
8589
8842
  * What the rail charged for one attempt of a transaction of ANY merchant,
8590
- * off the attempt's settlement line (be#843). `line_recorded: false` means
8843
+ * off the attempt's settlement line. `line_recorded: false` means
8591
8844
  * no line exists for the attempt; an absent amount is "no figure", never
8592
8845
  * zero.
8593
8846
  *