@delopay/sdk 0.159.0 → 0.162.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
@@ -58,6 +58,7 @@ __export(index_exports, {
58
58
  Cards: () => Cards,
59
59
  CheckoutMethods: () => CheckoutMethods,
60
60
  CheckoutSession: () => CheckoutSession,
61
+ CostRules: () => CostRules,
61
62
  DEFAULT_BADGES: () => DEFAULT_BADGES,
62
63
  DEFAULT_BADGES_DARK: () => DEFAULT_BADGES_DARK,
63
64
  DEFAULT_BRANDING: () => DEFAULT_BRANDING,
@@ -89,6 +90,7 @@ __export(index_exports, {
89
90
  PAYPAL_CARD_LAYOUTS: () => PAYPAL_CARD_LAYOUTS,
90
91
  PAYPAL_LABEL_STYLES: () => PAYPAL_LABEL_STYLES,
91
92
  PaypalDisputes: () => PaypalDisputes,
93
+ ProcessorCosts: () => ProcessorCosts,
92
94
  RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
93
95
  Regions: () => Regions,
94
96
  Risk: () => Risk,
@@ -2909,8 +2911,9 @@ var Routing = class {
2909
2911
  });
2910
2912
  }
2911
2913
  /**
2912
- * A shop's lifetime per-connector payment caps, each with how much of it is
2913
- * already spent.
2914
+ * A shop's per-connector caps, each with its unit and window and how much of
2915
+ * the current window is spent (`used`) or held by payments in flight
2916
+ * (`reserved`).
2914
2917
  *
2915
2918
  * `GET /routing/connector-caps/{profileId}`
2916
2919
  */
@@ -2935,13 +2938,17 @@ var Routing = class {
2935
2938
  return this.request("GET", `/routing/volume-counters/${encodeURIComponent(profileId)}`);
2936
2939
  }
2937
2940
  /**
2938
- * Replace a shop's per-connector payment caps.
2941
+ * Replace a shop's per-connector caps.
2939
2942
  *
2940
2943
  * Whole-set replacement, not a patch: the list sent becomes the complete set
2941
2944
  * of capped connectors, and an empty list clears them all — which is how
2942
2945
  * acquirer onboarding finishes, the new account ceasing to be a special case.
2946
+ * Re-send every other cap with its `unit`, `window` and `currency` as read:
2947
+ * an amount cap sent back without its `unit` is refused, because it carries a
2948
+ * currency and would otherwise be a payment count.
2943
2949
  *
2944
2950
  * Every account named must belong to this shop; one that does not is refused.
2951
+ * So is an amount cap without a `currency`, and a payment cap with one.
2945
2952
  *
2946
2953
  * `PUT /routing/connector-caps/{profileId}`
2947
2954
  */
@@ -4607,6 +4614,161 @@ var SellToRestrictions = class {
4607
4614
  }
4608
4615
  };
4609
4616
 
4617
+ // src/resources/costRules.ts
4618
+ var CostRules = class {
4619
+ constructor(request) {
4620
+ this.request = request;
4621
+ }
4622
+ /**
4623
+ * Every cost rule of the merchant.
4624
+ * `GET /cost-rules`
4625
+ *
4626
+ * @param merchantId - The merchant account ID.
4627
+ */
4628
+ async list(merchantId) {
4629
+ return this.request("GET", "/cost-rules", { query: { merchant_id: merchantId } });
4630
+ }
4631
+ /**
4632
+ * Record a cost rule.
4633
+ * `POST /cost-rules`
4634
+ *
4635
+ * @param params - The rule.
4636
+ * @param merchantId - The merchant account ID.
4637
+ */
4638
+ async create(params, merchantId) {
4639
+ return this.request("POST", "/cost-rules", {
4640
+ body: params,
4641
+ query: { merchant_id: merchantId }
4642
+ });
4643
+ }
4644
+ /**
4645
+ * Close, deactivate or rename a cost rule.
4646
+ * `PUT /cost-rules/{rule_id}`
4647
+ *
4648
+ * @param ruleId - The rule ID.
4649
+ * @param params - What to change.
4650
+ * @param merchantId - The merchant account ID.
4651
+ */
4652
+ async update(ruleId, params, merchantId) {
4653
+ return this.request("PUT", `/cost-rules/${encodeURIComponent(ruleId)}`, {
4654
+ body: params,
4655
+ query: { merchant_id: merchantId }
4656
+ });
4657
+ }
4658
+ /**
4659
+ * Delete a cost rule.
4660
+ * `DELETE /cost-rules/{rule_id}`
4661
+ *
4662
+ * @param ruleId - The rule ID.
4663
+ * @param merchantId - The merchant account ID.
4664
+ */
4665
+ async delete(ruleId, merchantId) {
4666
+ return this.request("DELETE", `/cost-rules/${encodeURIComponent(ruleId)}`, {
4667
+ query: { merchant_id: merchantId }
4668
+ });
4669
+ }
4670
+ };
4671
+
4672
+ // src/resources/processorCosts.ts
4673
+ var ProcessorCosts = class {
4674
+ constructor(request) {
4675
+ this.request = request;
4676
+ }
4677
+ /**
4678
+ * Every processor cost schedule of the merchant.
4679
+ * `GET /processor-costs`
4680
+ *
4681
+ * @param merchantId - The merchant account ID.
4682
+ */
4683
+ async list(merchantId) {
4684
+ return this.request("GET", "/processor-costs", { query: { merchant_id: merchantId } });
4685
+ }
4686
+ /**
4687
+ * Record a processor cost schedule.
4688
+ * `POST /processor-costs`
4689
+ *
4690
+ * A `shop_id` that is well formed but not a shop of this merchant is
4691
+ * answered `404` and nothing is recorded: a rate scoped to a shop the
4692
+ * merchant does not own would price no attempt, leaving every line it was
4693
+ * meant to price `unavailable` while the screen showed a configured rate.
4694
+ *
4695
+ * @param params - The schedule.
4696
+ * @param merchantId - The merchant account ID.
4697
+ */
4698
+ async create(params, merchantId) {
4699
+ return this.request("POST", "/processor-costs", {
4700
+ body: params,
4701
+ query: { merchant_id: merchantId }
4702
+ });
4703
+ }
4704
+ /**
4705
+ * Record several schedules at once, all or none — copy a price list across
4706
+ * methods or shops.
4707
+ * `POST /processor-costs/bulk`
4708
+ *
4709
+ * 1 to 200 entries. Every entry is validated before anything is stored: an
4710
+ * invalid one is answered `422` naming its index, and nothing is stored.
4711
+ * The answer lists the created schedules in request order.
4712
+ *
4713
+ * @param params - The schedules.
4714
+ * @param merchantId - The merchant account ID.
4715
+ */
4716
+ async bulkCreate(params, merchantId) {
4717
+ return this.request("POST", "/processor-costs/bulk", {
4718
+ body: params,
4719
+ query: { merchant_id: merchantId }
4720
+ });
4721
+ }
4722
+ /**
4723
+ * Close, deactivate or annotate a schedule. The rate is not editable.
4724
+ * `PUT /processor-costs/{schedule_id}`
4725
+ *
4726
+ * @param scheduleId - The schedule ID.
4727
+ * @param params - What to change.
4728
+ * @param merchantId - The merchant account ID.
4729
+ */
4730
+ async update(scheduleId, params, merchantId) {
4731
+ return this.request("PUT", `/processor-costs/${encodeURIComponent(scheduleId)}`, {
4732
+ body: params,
4733
+ query: { merchant_id: merchantId }
4734
+ });
4735
+ }
4736
+ /**
4737
+ * Close a schedule at `effective_from` and open its successor with the same
4738
+ * scope and the same end, in one step: no transaction is priced by both
4739
+ * rates, and none falls between them.
4740
+ * `POST /processor-costs/{schedule_id}/replace`
4741
+ *
4742
+ * Answers the successor schedule. An `effective_from` outside the old
4743
+ * schedule's window, an inactive schedule, or one a concurrent replacement
4744
+ * already moved is answered `400` — retry against the schedule as it now
4745
+ * stands rather than forcing the write.
4746
+ *
4747
+ * @param scheduleId - The schedule to replace.
4748
+ * @param params - The new rate.
4749
+ * @param merchantId - The merchant account ID.
4750
+ */
4751
+ async replace(scheduleId, params, merchantId) {
4752
+ return this.request("POST", `/processor-costs/${encodeURIComponent(scheduleId)}/replace`, {
4753
+ body: params,
4754
+ query: { merchant_id: merchantId }
4755
+ });
4756
+ }
4757
+ /**
4758
+ * Delete a schedule. Restates nothing: every figure it derived is already
4759
+ * stamped on the settlement lines it priced.
4760
+ * `DELETE /processor-costs/{schedule_id}`
4761
+ *
4762
+ * @param scheduleId - The schedule ID.
4763
+ * @param merchantId - The merchant account ID.
4764
+ */
4765
+ async delete(scheduleId, merchantId) {
4766
+ return this.request("DELETE", `/processor-costs/${encodeURIComponent(scheduleId)}`, {
4767
+ query: { merchant_id: merchantId }
4768
+ });
4769
+ }
4770
+ };
4771
+
4610
4772
  // src/resources/checkoutMethods.ts
4611
4773
  var CheckoutMethods = class {
4612
4774
  constructor(request) {
@@ -5527,6 +5689,8 @@ var Delopay = class {
5527
5689
  this.regions = new Regions(request);
5528
5690
  this.availabilityOverrides = new AvailabilityOverrides(request);
5529
5691
  this.sellToRestrictions = new SellToRestrictions(request);
5692
+ this.costRules = new CostRules(request);
5693
+ this.processorCosts = new ProcessorCosts(request);
5530
5694
  this.checkoutMethods = new CheckoutMethods(request);
5531
5695
  this.analytics = new Analytics(request);
5532
5696
  this.analyticsDashboard = new AnalyticsDashboard(request);
@@ -8416,11 +8580,62 @@ var CheckoutSession = class {
8416
8580
  *
8417
8581
  * `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`
8418
8582
  *
8583
+ * Pass `{ paypalSdk: true }` from a checkout drawing an experimental PayPal
8584
+ * SDK pane to also receive e-Payouts' PayPal client id
8585
+ * (`paypal_client_id`, `paypal_currency`); it is present only when `ppal`
8586
+ * is among the methods.
8587
+ *
8419
8588
  * @param country - Lowercase ISO 3166-1 alpha-2 country code.
8420
8589
  */
8421
8590
  async epayoutsMethods(country, options) {
8591
+ const { paypalSdk, merchantConnectorId, ...extras } = options ?? {};
8422
8592
  return this.client.request("GET", `${this.linkBase}/epayouts/methods`, {
8423
- query: { cc: country },
8593
+ query: paypalSdk ? {
8594
+ cc: country,
8595
+ paypal_sdk: "true",
8596
+ ...merchantConnectorId ? { merchant_connector_id: merchantConnectorId } : {}
8597
+ } : { cc: country },
8598
+ ...extras,
8599
+ headers: this.bearerHeaders(extras.headers)
8600
+ });
8601
+ }
8602
+ /**
8603
+ * The PayPal order for the payment's e-Payouts access code, from the PayPal
8604
+ * SDK's `createOrder` on an experimental PayPal SDK pane — after the payment
8605
+ * was confirmed through that pane, which mints the code.
8606
+ *
8607
+ * The router reads the order off e-Payouts' own PayPal page for the code, so
8608
+ * `amount` and `currency` are what e-Payouts charges for it. Repeated calls
8609
+ * answer the same order, so a cancelled PayPal popup is retried with the same
8610
+ * code. When `captured` is `true` a capture was already reported: create no
8611
+ * order and wait for the payment's status instead.
8612
+ *
8613
+ * `POST /payment-link/{merchantId}/{paymentId}/epayouts/paypal-order`
8614
+ */
8615
+ async epayoutsPaypalOrder(options) {
8616
+ return this.client.request("POST", `${this.linkBase}/epayouts/paypal-order`, {
8617
+ ...options,
8618
+ headers: this.bearerHeaders(options?.headers)
8619
+ });
8620
+ }
8621
+ /**
8622
+ * Report a PayPal order's progress from `onApprove` on an experimental PayPal
8623
+ * SDK pane: the approval, before asking PayPal to capture — and capture only
8624
+ * once the router has it — then the capture PayPal answered, or a decline.
8625
+ * When the approval's answer is lost, do not capture: report `NOT_CAPTURED`
8626
+ * instead, which releases an approval the router may have recorded.
8627
+ *
8628
+ * The router records each on the payment and relays a capture that took money
8629
+ * to e-Payouts the way e-Payouts' own PayPal page does. It does not mark the
8630
+ * payment paid: that happens only on e-Payouts' notification, so poll the
8631
+ * payment's status afterwards. A repeated report is answered, not recorded
8632
+ * twice.
8633
+ *
8634
+ * `POST /payment-link/{merchantId}/{paymentId}/epayouts/paypal-capture`
8635
+ */
8636
+ async epayoutsPaypalCapture(params, options) {
8637
+ return this.client.request("POST", `${this.linkBase}/epayouts/paypal-capture`, {
8638
+ body: params,
8424
8639
  ...options,
8425
8640
  headers: this.bearerHeaders(options?.headers)
8426
8641
  });
@@ -9099,6 +9314,7 @@ var encodeNativePanes = encodePanes;
9099
9314
  Cards,
9100
9315
  CheckoutMethods,
9101
9316
  CheckoutSession,
9317
+ CostRules,
9102
9318
  DEFAULT_BADGES,
9103
9319
  DEFAULT_BADGES_DARK,
9104
9320
  DEFAULT_BRANDING,
@@ -9130,6 +9346,7 @@ var encodeNativePanes = encodePanes;
9130
9346
  PAYPAL_CARD_LAYOUTS,
9131
9347
  PAYPAL_LABEL_STYLES,
9132
9348
  PaypalDisputes,
9349
+ ProcessorCosts,
9133
9350
  RTL_CHECKOUT_LOCALES,
9134
9351
  Regions,
9135
9352
  Risk,