@delopay/sdk 0.163.0 → 0.164.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.cjs CHANGED
@@ -1986,6 +1986,16 @@ var Payments = class {
1986
1986
  * Not the hosted-shop settlement API under `settlement.*`, which is host →
1987
1987
  * shop owner and manual; this is acquirer → merchant bank, per payment.
1988
1988
  *
1989
+ * Each attempt also carries what the rail itself took for it —
1990
+ * `processor_cost_amount` with its own `processor_cost_currency` and
1991
+ * `processor_cost_exponent`, the `processor_cost_source` that says how the
1992
+ * figure was obtained, the `processor_cost_basis` behind an estimate, and
1993
+ * the `connector_method_code` it was priced under. Recorded for **every**
1994
+ * merchant, not only those that host shops. Never present an `estimated`
1995
+ * cost as an observation, and read an absent `processor_cost_source` as
1996
+ * "nothing was ever written", which is not the `unavailable` the rail
1997
+ * answers with.
1998
+ *
1989
1999
  * `GET /payments/{paymentId}/settlement`
1990
2000
  *
1991
2001
  * @param paymentId - The payment intent ID.
@@ -2004,6 +2014,9 @@ var Payments = class {
2004
2014
  * if (attempt.status === 'paid_out') {
2005
2015
  * console.log(attempt.paid_out_at, attempt.payout_reference);
2006
2016
  * }
2017
+ * if (attempt.processor_cost_source === 'estimated') {
2018
+ * // Label it an estimate — it was derived from a cost schedule.
2019
+ * }
2007
2020
  * }
2008
2021
  * ```
2009
2022
  */
@@ -5239,6 +5252,65 @@ var Settlement = class {
5239
5252
  ...options
5240
5253
  });
5241
5254
  }
5255
+ /**
5256
+ * What a period's payments cost at the rails, grouped by shop, connector
5257
+ * and payment method. Answers for **every** merchant, including one that
5258
+ * hosts nobody — it reads the per-attempt settlement record rather than the
5259
+ * settlement lines, which exist only where hosting fees are configured.
5260
+ *
5261
+ * A sibling of {@link Settlement.cost} rather than a widening of it. That
5262
+ * endpoint is a profit statement whose revenue term is hosting income, and
5263
+ * a merchant who hosts nobody has none. This publishes cost and never
5264
+ * margin.
5265
+ *
5266
+ * Send `year` and `month` together to report one UTC calendar month, or
5267
+ * neither for the running month so far.
5268
+ *
5269
+ * **The response carries no period total, and a caller must not compute
5270
+ * one here.** Every figure keeps the unit the rail reported it in, and the
5271
+ * unit is part of each bucket's key, so adding two buckets is not addition.
5272
+ * Convert caller-side if you need one number, and say which rates you used.
5273
+ * The counts are totalled, because a count has no unit.
5274
+ *
5275
+ * Two distinctions not to flatten when rendering a bucket:
5276
+ * `cost_amount` covers `reported_count + estimated_count` attempts out of
5277
+ * `attempt_count` and is a lower bound whenever those disagree; and
5278
+ * `unavailable_count` (the rail says it has no figure) means something
5279
+ * different from `unwritten_count` (a gap in our own recording).
5280
+ *
5281
+ * **Merchant scope.** A token scoped to a single shop, a role narrowed to
5282
+ * specific connector accounts, or a role without the settlement-read
5283
+ * permission group is refused `403`: what a rail charged is the merchant's
5284
+ * own cost base, and here it is the whole response, so there is nothing
5285
+ * coherent to redact down to. Gate the surface on the caller's scope rather
5286
+ * than calling it and handling the failure.
5287
+ *
5288
+ * `GET /settlement/processor-cost`
5289
+ *
5290
+ * @example
5291
+ * ```typescript
5292
+ * const period = await delopay.settlement.processorCost({
5293
+ * test_mode: false,
5294
+ * year: 2026,
5295
+ * month: 7,
5296
+ * });
5297
+ * for (const bucket of period.buckets) {
5298
+ * // Each bucket is its own unit — render per bucket, never a sum.
5299
+ * console.log(bucket.connector, bucket.cost_amount, bucket.cost_currency);
5300
+ * }
5301
+ * ```
5302
+ */
5303
+ async processorCost(params, options) {
5304
+ return this.request("GET", "/settlement/processor-cost", {
5305
+ query: {
5306
+ profile_id: params?.profile_id,
5307
+ test_mode: params?.test_mode,
5308
+ year: params?.year,
5309
+ month: params?.month
5310
+ },
5311
+ ...options
5312
+ });
5313
+ }
5242
5314
  /**
5243
5315
  * List generated settlement statements, newest first.
5244
5316
  *