@delopay/sdk 0.162.1 → 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
@@ -67,6 +67,7 @@ __export(index_exports, {
67
67
  DelopayAuthenticationError: () => DelopayAuthenticationError,
68
68
  DelopayError: () => DelopayError,
69
69
  Export: () => Export,
70
+ ExternalRecords: () => ExternalRecords,
70
71
  FeatureMatrix: () => FeatureMatrix,
71
72
  FeeProgramBuilder: () => FeeProgramBuilder,
72
73
  Files: () => Files,
@@ -91,6 +92,7 @@ __export(index_exports, {
91
92
  PAYPAL_LABEL_STYLES: () => PAYPAL_LABEL_STYLES,
92
93
  PaypalDisputes: () => PaypalDisputes,
93
94
  ProcessorCosts: () => ProcessorCosts,
95
+ Products: () => Products,
94
96
  RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
95
97
  Regions: () => Regions,
96
98
  Risk: () => Risk,
@@ -1984,6 +1986,16 @@ var Payments = class {
1984
1986
  * Not the hosted-shop settlement API under `settlement.*`, which is host →
1985
1987
  * shop owner and manual; this is acquirer → merchant bank, per payment.
1986
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
+ *
1987
1999
  * `GET /payments/{paymentId}/settlement`
1988
2000
  *
1989
2001
  * @param paymentId - The payment intent ID.
@@ -2002,6 +2014,9 @@ var Payments = class {
2002
2014
  * if (attempt.status === 'paid_out') {
2003
2015
  * console.log(attempt.paid_out_at, attempt.payout_reference);
2004
2016
  * }
2017
+ * if (attempt.processor_cost_source === 'estimated') {
2018
+ * // Label it an estimate — it was derived from a cost schedule.
2019
+ * }
2005
2020
  * }
2006
2021
  * ```
2007
2022
  */
@@ -4669,6 +4684,142 @@ var CostRules = class {
4669
4684
  }
4670
4685
  };
4671
4686
 
4687
+ // src/resources/externalRecords.ts
4688
+ var ExternalRecords = class {
4689
+ constructor(request) {
4690
+ this.request = request;
4691
+ }
4692
+ /**
4693
+ * Record one out-of-band transition.
4694
+ * `POST /external-records`
4695
+ *
4696
+ * Which kinds a deployment answers for depends on the payment's connector
4697
+ * and on which arms are live: an arm that is not served answers `501`, which
4698
+ * is a statement about this rail rather than about the request.
4699
+ *
4700
+ * @param params - What happened, and why it is being recorded.
4701
+ */
4702
+ async create(params) {
4703
+ return this.request("POST", "/external-records", { body: params });
4704
+ }
4705
+ };
4706
+
4707
+ // src/resources/products.ts
4708
+ var Products = class {
4709
+ constructor(request) {
4710
+ this.request = request;
4711
+ }
4712
+ /** The shop scope every route here takes, as the backend expects it. */
4713
+ scoped(profileId, options) {
4714
+ return { ...options, headers: { "X-Profile-Id": profileId, ...options?.headers } };
4715
+ }
4716
+ /**
4717
+ * Create a product together with its prices.
4718
+ * `POST /products`
4719
+ *
4720
+ * @param params - The product, with at least one price.
4721
+ * @param profileId - The shop the product belongs to.
4722
+ */
4723
+ async create(params, profileId, options) {
4724
+ return this.request("POST", "/products", {
4725
+ body: params,
4726
+ ...this.scoped(profileId, options)
4727
+ });
4728
+ }
4729
+ /**
4730
+ * One page of the shop's catalogue.
4731
+ * `GET /products/list`
4732
+ *
4733
+ * Archived products are returned too unless `status` narrows them away —
4734
+ * they are what past charges refer to.
4735
+ */
4736
+ async list(params, profileId, options) {
4737
+ return this.request("GET", "/products/list", {
4738
+ query: params === void 0 ? void 0 : { ...params },
4739
+ ...this.scoped(profileId, options)
4740
+ });
4741
+ }
4742
+ /**
4743
+ * Retrieve one product with its prices.
4744
+ * `GET /products/{product_id}`
4745
+ */
4746
+ async retrieve(productId, profileId, options) {
4747
+ return this.request("GET", `/products/${encodeURIComponent(productId)}`, {
4748
+ ...this.scoped(profileId, options)
4749
+ });
4750
+ }
4751
+ /**
4752
+ * Change a product's name, description or metadata.
4753
+ * `POST /products/{product_id}`
4754
+ *
4755
+ * Its kind and its prices are not editable here — see the class note.
4756
+ */
4757
+ async update(productId, params, profileId, options) {
4758
+ return this.request("POST", `/products/${encodeURIComponent(productId)}`, {
4759
+ body: params,
4760
+ ...this.scoped(profileId, options)
4761
+ });
4762
+ }
4763
+ /**
4764
+ * Take a product off sale.
4765
+ * `POST /products/{product_id}/archive`
4766
+ *
4767
+ * It stays readable and keeps its prices: a payment made against it has to
4768
+ * remain explicable after it is withdrawn.
4769
+ */
4770
+ async archive(productId, profileId, options) {
4771
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/archive`, {
4772
+ ...this.scoped(profileId, options)
4773
+ });
4774
+ }
4775
+ /**
4776
+ * Put an archived product back on sale.
4777
+ * `POST /products/{product_id}/restore`
4778
+ */
4779
+ async restore(productId, profileId, options) {
4780
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/restore`, {
4781
+ ...this.scoped(profileId, options)
4782
+ });
4783
+ }
4784
+ /**
4785
+ * Add a price to an existing product.
4786
+ * `POST /products/{product_id}/prices`
4787
+ *
4788
+ * This is how a price changes: the new figure is added and the old price is
4789
+ * archived, so both remain readable.
4790
+ */
4791
+ async addPrice(productId, params, profileId, options) {
4792
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/prices`, {
4793
+ body: params,
4794
+ ...this.scoped(profileId, options)
4795
+ });
4796
+ }
4797
+ /**
4798
+ * Change a price's label, its default flag or its metadata.
4799
+ * `POST /products/{product_id}/prices/{price_id}`
4800
+ *
4801
+ * Not its amount, its currency or its interval: see the class note.
4802
+ */
4803
+ async updatePrice(productId, priceId, params, profileId, options) {
4804
+ return this.request(
4805
+ "POST",
4806
+ `/products/${encodeURIComponent(productId)}/prices/${encodeURIComponent(priceId)}`,
4807
+ { body: params, ...this.scoped(profileId, options) }
4808
+ );
4809
+ }
4810
+ /**
4811
+ * Take one price off sale, leaving the product on it.
4812
+ * `POST /products/{product_id}/prices/{price_id}/archive`
4813
+ */
4814
+ async archivePrice(productId, priceId, profileId, options) {
4815
+ return this.request(
4816
+ "POST",
4817
+ `/products/${encodeURIComponent(productId)}/prices/${encodeURIComponent(priceId)}/archive`,
4818
+ { ...this.scoped(profileId, options) }
4819
+ );
4820
+ }
4821
+ };
4822
+
4672
4823
  // src/resources/processorCosts.ts
4673
4824
  var ProcessorCosts = class {
4674
4825
  constructor(request) {
@@ -5101,6 +5252,65 @@ var Settlement = class {
5101
5252
  ...options
5102
5253
  });
5103
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
+ }
5104
5314
  /**
5105
5315
  * List generated settlement statements, newest first.
5106
5316
  *
@@ -5690,6 +5900,8 @@ var Delopay = class {
5690
5900
  this.availabilityOverrides = new AvailabilityOverrides(request);
5691
5901
  this.sellToRestrictions = new SellToRestrictions(request);
5692
5902
  this.costRules = new CostRules(request);
5903
+ this.externalRecords = new ExternalRecords(request);
5904
+ this.products = new Products(request);
5693
5905
  this.processorCosts = new ProcessorCosts(request);
5694
5906
  this.checkoutMethods = new CheckoutMethods(request);
5695
5907
  this.analytics = new Analytics(request);
@@ -9323,6 +9535,7 @@ var encodeNativePanes = encodePanes;
9323
9535
  DelopayAuthenticationError,
9324
9536
  DelopayError,
9325
9537
  Export,
9538
+ ExternalRecords,
9326
9539
  FeatureMatrix,
9327
9540
  FeeProgramBuilder,
9328
9541
  Files,
@@ -9347,6 +9560,7 @@ var encodeNativePanes = encodePanes;
9347
9560
  PAYPAL_LABEL_STYLES,
9348
9561
  PaypalDisputes,
9349
9562
  ProcessorCosts,
9563
+ Products,
9350
9564
  RTL_CHECKOUT_LOCALES,
9351
9565
  Regions,
9352
9566
  Risk,