@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.js CHANGED
@@ -46,6 +46,7 @@ import {
46
46
  DelopayAuthenticationError,
47
47
  DelopayError,
48
48
  Export,
49
+ ExternalRecords,
49
50
  FeatureMatrix,
50
51
  FeeProgramBuilder,
51
52
  Files,
@@ -70,6 +71,7 @@ import {
70
71
  PAYPAL_LABEL_STYLES,
71
72
  PaypalDisputes,
72
73
  ProcessorCosts,
74
+ Products,
73
75
  RTL_CHECKOUT_LOCALES,
74
76
  Regions,
75
77
  Risk,
@@ -195,7 +197,7 @@ import {
195
197
  validatePanes,
196
198
  verticalGapValue,
197
199
  visibleCustomFields
198
- } from "./chunk-P2KP3WRS.js";
200
+ } from "./chunk-GCJDY4KX.js";
199
201
  export {
200
202
  AIRWALLEX_AUTOFILL_TREATMENTS,
201
203
  AIRWALLEX_CARD_LAYOUTS,
@@ -244,6 +246,7 @@ export {
244
246
  DelopayAuthenticationError,
245
247
  DelopayError,
246
248
  Export,
249
+ ExternalRecords,
247
250
  FeatureMatrix,
248
251
  FeeProgramBuilder,
249
252
  Files,
@@ -268,6 +271,7 @@ export {
268
271
  PAYPAL_LABEL_STYLES,
269
272
  PaypalDisputes,
270
273
  ProcessorCosts,
274
+ Products,
271
275
  RTL_CHECKOUT_LOCALES,
272
276
  Regions,
273
277
  Risk,
package/dist/internal.cjs CHANGED
@@ -77,6 +77,7 @@ __export(internal_exports, {
77
77
  DelopayInternal: () => DelopayInternal,
78
78
  Diagnostic: () => Diagnostic,
79
79
  Export: () => Export,
80
+ ExternalRecords: () => ExternalRecords,
80
81
  FeatureMatrix: () => FeatureMatrix,
81
82
  FeeProgramBuilder: () => FeeProgramBuilder,
82
83
  Files: () => Files,
@@ -104,6 +105,7 @@ __export(internal_exports, {
104
105
  PlatformBilling: () => PlatformBilling,
105
106
  PlatformFees: () => PlatformFees,
106
107
  ProcessorCosts: () => ProcessorCosts,
108
+ Products: () => Products,
107
109
  RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
108
110
  Regions: () => Regions,
109
111
  Risk: () => Risk,
@@ -1997,6 +1999,16 @@ var Payments = class {
1997
1999
  * Not the hosted-shop settlement API under `settlement.*`, which is host →
1998
2000
  * shop owner and manual; this is acquirer → merchant bank, per payment.
1999
2001
  *
2002
+ * Each attempt also carries what the rail itself took for it —
2003
+ * `processor_cost_amount` with its own `processor_cost_currency` and
2004
+ * `processor_cost_exponent`, the `processor_cost_source` that says how the
2005
+ * figure was obtained, the `processor_cost_basis` behind an estimate, and
2006
+ * the `connector_method_code` it was priced under. Recorded for **every**
2007
+ * merchant, not only those that host shops. Never present an `estimated`
2008
+ * cost as an observation, and read an absent `processor_cost_source` as
2009
+ * "nothing was ever written", which is not the `unavailable` the rail
2010
+ * answers with.
2011
+ *
2000
2012
  * `GET /payments/{paymentId}/settlement`
2001
2013
  *
2002
2014
  * @param paymentId - The payment intent ID.
@@ -2015,6 +2027,9 @@ var Payments = class {
2015
2027
  * if (attempt.status === 'paid_out') {
2016
2028
  * console.log(attempt.paid_out_at, attempt.payout_reference);
2017
2029
  * }
2030
+ * if (attempt.processor_cost_source === 'estimated') {
2031
+ * // Label it an estimate — it was derived from a cost schedule.
2032
+ * }
2018
2033
  * }
2019
2034
  * ```
2020
2035
  */
@@ -4682,6 +4697,142 @@ var CostRules = class {
4682
4697
  }
4683
4698
  };
4684
4699
 
4700
+ // src/resources/externalRecords.ts
4701
+ var ExternalRecords = class {
4702
+ constructor(request) {
4703
+ this.request = request;
4704
+ }
4705
+ /**
4706
+ * Record one out-of-band transition.
4707
+ * `POST /external-records`
4708
+ *
4709
+ * Which kinds a deployment answers for depends on the payment's connector
4710
+ * and on which arms are live: an arm that is not served answers `501`, which
4711
+ * is a statement about this rail rather than about the request.
4712
+ *
4713
+ * @param params - What happened, and why it is being recorded.
4714
+ */
4715
+ async create(params) {
4716
+ return this.request("POST", "/external-records", { body: params });
4717
+ }
4718
+ };
4719
+
4720
+ // src/resources/products.ts
4721
+ var Products = class {
4722
+ constructor(request) {
4723
+ this.request = request;
4724
+ }
4725
+ /** The shop scope every route here takes, as the backend expects it. */
4726
+ scoped(profileId, options) {
4727
+ return { ...options, headers: { "X-Profile-Id": profileId, ...options?.headers } };
4728
+ }
4729
+ /**
4730
+ * Create a product together with its prices.
4731
+ * `POST /products`
4732
+ *
4733
+ * @param params - The product, with at least one price.
4734
+ * @param profileId - The shop the product belongs to.
4735
+ */
4736
+ async create(params, profileId, options) {
4737
+ return this.request("POST", "/products", {
4738
+ body: params,
4739
+ ...this.scoped(profileId, options)
4740
+ });
4741
+ }
4742
+ /**
4743
+ * One page of the shop's catalogue.
4744
+ * `GET /products/list`
4745
+ *
4746
+ * Archived products are returned too unless `status` narrows them away —
4747
+ * they are what past charges refer to.
4748
+ */
4749
+ async list(params, profileId, options) {
4750
+ return this.request("GET", "/products/list", {
4751
+ query: params === void 0 ? void 0 : { ...params },
4752
+ ...this.scoped(profileId, options)
4753
+ });
4754
+ }
4755
+ /**
4756
+ * Retrieve one product with its prices.
4757
+ * `GET /products/{product_id}`
4758
+ */
4759
+ async retrieve(productId, profileId, options) {
4760
+ return this.request("GET", `/products/${encodeURIComponent(productId)}`, {
4761
+ ...this.scoped(profileId, options)
4762
+ });
4763
+ }
4764
+ /**
4765
+ * Change a product's name, description or metadata.
4766
+ * `POST /products/{product_id}`
4767
+ *
4768
+ * Its kind and its prices are not editable here — see the class note.
4769
+ */
4770
+ async update(productId, params, profileId, options) {
4771
+ return this.request("POST", `/products/${encodeURIComponent(productId)}`, {
4772
+ body: params,
4773
+ ...this.scoped(profileId, options)
4774
+ });
4775
+ }
4776
+ /**
4777
+ * Take a product off sale.
4778
+ * `POST /products/{product_id}/archive`
4779
+ *
4780
+ * It stays readable and keeps its prices: a payment made against it has to
4781
+ * remain explicable after it is withdrawn.
4782
+ */
4783
+ async archive(productId, profileId, options) {
4784
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/archive`, {
4785
+ ...this.scoped(profileId, options)
4786
+ });
4787
+ }
4788
+ /**
4789
+ * Put an archived product back on sale.
4790
+ * `POST /products/{product_id}/restore`
4791
+ */
4792
+ async restore(productId, profileId, options) {
4793
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/restore`, {
4794
+ ...this.scoped(profileId, options)
4795
+ });
4796
+ }
4797
+ /**
4798
+ * Add a price to an existing product.
4799
+ * `POST /products/{product_id}/prices`
4800
+ *
4801
+ * This is how a price changes: the new figure is added and the old price is
4802
+ * archived, so both remain readable.
4803
+ */
4804
+ async addPrice(productId, params, profileId, options) {
4805
+ return this.request("POST", `/products/${encodeURIComponent(productId)}/prices`, {
4806
+ body: params,
4807
+ ...this.scoped(profileId, options)
4808
+ });
4809
+ }
4810
+ /**
4811
+ * Change a price's label, its default flag or its metadata.
4812
+ * `POST /products/{product_id}/prices/{price_id}`
4813
+ *
4814
+ * Not its amount, its currency or its interval: see the class note.
4815
+ */
4816
+ async updatePrice(productId, priceId, params, profileId, options) {
4817
+ return this.request(
4818
+ "POST",
4819
+ `/products/${encodeURIComponent(productId)}/prices/${encodeURIComponent(priceId)}`,
4820
+ { body: params, ...this.scoped(profileId, options) }
4821
+ );
4822
+ }
4823
+ /**
4824
+ * Take one price off sale, leaving the product on it.
4825
+ * `POST /products/{product_id}/prices/{price_id}/archive`
4826
+ */
4827
+ async archivePrice(productId, priceId, profileId, options) {
4828
+ return this.request(
4829
+ "POST",
4830
+ `/products/${encodeURIComponent(productId)}/prices/${encodeURIComponent(priceId)}/archive`,
4831
+ { ...this.scoped(profileId, options) }
4832
+ );
4833
+ }
4834
+ };
4835
+
4685
4836
  // src/resources/processorCosts.ts
4686
4837
  var ProcessorCosts = class {
4687
4838
  constructor(request) {
@@ -5114,6 +5265,65 @@ var Settlement = class {
5114
5265
  ...options
5115
5266
  });
5116
5267
  }
5268
+ /**
5269
+ * What a period's payments cost at the rails, grouped by shop, connector
5270
+ * and payment method. Answers for **every** merchant, including one that
5271
+ * hosts nobody — it reads the per-attempt settlement record rather than the
5272
+ * settlement lines, which exist only where hosting fees are configured.
5273
+ *
5274
+ * A sibling of {@link Settlement.cost} rather than a widening of it. That
5275
+ * endpoint is a profit statement whose revenue term is hosting income, and
5276
+ * a merchant who hosts nobody has none. This publishes cost and never
5277
+ * margin.
5278
+ *
5279
+ * Send `year` and `month` together to report one UTC calendar month, or
5280
+ * neither for the running month so far.
5281
+ *
5282
+ * **The response carries no period total, and a caller must not compute
5283
+ * one here.** Every figure keeps the unit the rail reported it in, and the
5284
+ * unit is part of each bucket's key, so adding two buckets is not addition.
5285
+ * Convert caller-side if you need one number, and say which rates you used.
5286
+ * The counts are totalled, because a count has no unit.
5287
+ *
5288
+ * Two distinctions not to flatten when rendering a bucket:
5289
+ * `cost_amount` covers `reported_count + estimated_count` attempts out of
5290
+ * `attempt_count` and is a lower bound whenever those disagree; and
5291
+ * `unavailable_count` (the rail says it has no figure) means something
5292
+ * different from `unwritten_count` (a gap in our own recording).
5293
+ *
5294
+ * **Merchant scope.** A token scoped to a single shop, a role narrowed to
5295
+ * specific connector accounts, or a role without the settlement-read
5296
+ * permission group is refused `403`: what a rail charged is the merchant's
5297
+ * own cost base, and here it is the whole response, so there is nothing
5298
+ * coherent to redact down to. Gate the surface on the caller's scope rather
5299
+ * than calling it and handling the failure.
5300
+ *
5301
+ * `GET /settlement/processor-cost`
5302
+ *
5303
+ * @example
5304
+ * ```typescript
5305
+ * const period = await delopay.settlement.processorCost({
5306
+ * test_mode: false,
5307
+ * year: 2026,
5308
+ * month: 7,
5309
+ * });
5310
+ * for (const bucket of period.buckets) {
5311
+ * // Each bucket is its own unit — render per bucket, never a sum.
5312
+ * console.log(bucket.connector, bucket.cost_amount, bucket.cost_currency);
5313
+ * }
5314
+ * ```
5315
+ */
5316
+ async processorCost(params, options) {
5317
+ return this.request("GET", "/settlement/processor-cost", {
5318
+ query: {
5319
+ profile_id: params?.profile_id,
5320
+ test_mode: params?.test_mode,
5321
+ year: params?.year,
5322
+ month: params?.month
5323
+ },
5324
+ ...options
5325
+ });
5326
+ }
5117
5327
  /**
5118
5328
  * List generated settlement statements, newest first.
5119
5329
  *
@@ -5703,6 +5913,8 @@ var Delopay = class {
5703
5913
  this.availabilityOverrides = new AvailabilityOverrides(request);
5704
5914
  this.sellToRestrictions = new SellToRestrictions(request);
5705
5915
  this.costRules = new CostRules(request);
5916
+ this.externalRecords = new ExternalRecords(request);
5917
+ this.products = new Products(request);
5706
5918
  this.processorCosts = new ProcessorCosts(request);
5707
5919
  this.checkoutMethods = new CheckoutMethods(request);
5708
5920
  this.analytics = new Analytics(request);
@@ -10750,6 +10962,7 @@ var DelopayInternal = class extends Delopay {
10750
10962
  DelopayInternal,
10751
10963
  Diagnostic,
10752
10964
  Export,
10965
+ ExternalRecords,
10753
10966
  FeatureMatrix,
10754
10967
  FeeProgramBuilder,
10755
10968
  Files,
@@ -10777,6 +10990,7 @@ var DelopayInternal = class extends Delopay {
10777
10990
  PlatformBilling,
10778
10991
  PlatformFees,
10779
10992
  ProcessorCosts,
10993
+ Products,
10780
10994
  RTL_CHECKOUT_LOCALES,
10781
10995
  Regions,
10782
10996
  Risk,