@delopay/sdk 0.158.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
  });
@@ -8494,12 +8709,29 @@ var CheckoutSession = class {
8494
8709
  * checkout payload with `card_connector_server_confirm: true`. Stripe refuses
8495
8710
  * a Stripe.js confirm of such an intent.
8496
8711
  *
8497
- * Send the ConfirmationToken the Payment Element (or Express Checkout
8498
- * Element) produced. The router judges the card's issuing country and the
8499
- * buyer's IP country against the shop's sell-to restrictions before Stripe
8500
- * authorises, and a refusal throws a `DelopayError` with code `DE_10`. When
8501
- * the answer's `status` is `requires_action`, run `stripe.handleNextAction`
8502
- * with its `client_secret`, then call this again without a token to finalize.
8712
+ * Send the PaymentMethod `stripe.createPaymentMethod` produced from the
8713
+ * Payment Element (or Express Checkout Element), which needs
8714
+ * `paymentMethodCreation: 'manual'` on the Elements instance. A
8715
+ * ConfirmationToken is refused with `400`: Stripe will not confirm such an
8716
+ * intent with one.
8717
+ *
8718
+ * The router judges the card's issuing country and the buyer's IP country
8719
+ * against the shop's sell-to restrictions before Stripe authorises, and a
8720
+ * refusal throws a `DelopayError` with code `DE_10`. When the answer's
8721
+ * `status` is `requires_action`, run `stripe.handleNextAction` with its
8722
+ * `client_secret` — safe, because the intent is `confirmation_method=manual`
8723
+ * and that secret confirms nothing without the secret key — then call this
8724
+ * again without a payment method to finalize.
8725
+ *
8726
+ * A PaymentMethod rules out what `stripe.createPaymentMethod` cannot
8727
+ * produce: Stripe names Amazon Pay and Klarna in the Express Checkout
8728
+ * Element, which need `stripe.createConfirmationToken` instead. Neither can
8729
+ * be paid through this route, so a caller must not offer them on a
8730
+ * server-confirmed intent — mount the Express Checkout Element with those
8731
+ * methods `'never'`, as DeloPay's own checkout does. The router drops only
8732
+ * the methods its server-side confirm cannot finish at all (BLIK and ACSS
8733
+ * pre-authorized debits) from the card form's mount, so the rest of the
8734
+ * selection still reaches the element and is the caller's to constrain.
8503
8735
  *
8504
8736
  * `POST /payment-link/{merchantId}/{paymentId}/stripe-confirm`
8505
8737
  */
@@ -8510,6 +8742,27 @@ var CheckoutSession = class {
8510
8742
  headers: this.bearerHeaders(options?.headers)
8511
8743
  });
8512
8744
  }
8745
+ /**
8746
+ * Ask whether NomuPay's COPYandPAY widget may submit a card, from the
8747
+ * form's pre-submit hook.
8748
+ *
8749
+ * Only for a checkout stamped `NomupayOppwaCheckoutData.submit_grant`: the
8750
+ * card form sits beside always-shown wallet buttons of another account, and
8751
+ * this answer closes those buttons before it allows the card. `authorized`
8752
+ * is `false` when the payment no longer waits for a payment method, or when
8753
+ * this is not the attempt's live card-form checkout; when a wallet beside it
8754
+ * is already being paid, the route answers an error instead. Submit the
8755
+ * widget only on `true`.
8756
+ *
8757
+ * `POST /payment-link/{merchantId}/{paymentId}/nomupay-card-authorization`
8758
+ */
8759
+ async nomupayCardAuthorization(params, options) {
8760
+ return this.client.request("POST", `${this.linkBase}/nomupay-card-authorization`, {
8761
+ body: params,
8762
+ ...options,
8763
+ headers: this.bearerHeaders(options?.headers)
8764
+ });
8765
+ }
8513
8766
  /**
8514
8767
  * The payment's current state — status polling for redirect/popup rails.
8515
8768
  *
@@ -9061,6 +9314,7 @@ var encodeNativePanes = encodePanes;
9061
9314
  Cards,
9062
9315
  CheckoutMethods,
9063
9316
  CheckoutSession,
9317
+ CostRules,
9064
9318
  DEFAULT_BADGES,
9065
9319
  DEFAULT_BADGES_DARK,
9066
9320
  DEFAULT_BRANDING,
@@ -9092,6 +9346,7 @@ var encodeNativePanes = encodePanes;
9092
9346
  PAYPAL_CARD_LAYOUTS,
9093
9347
  PAYPAL_LABEL_STYLES,
9094
9348
  PaypalDisputes,
9349
+ ProcessorCosts,
9095
9350
  RTL_CHECKOUT_LOCALES,
9096
9351
  Regions,
9097
9352
  Risk,