@delopay/sdk 0.139.0 → 0.141.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/README.md CHANGED
@@ -211,9 +211,14 @@ const opts = { headers: { 'X-Profile-Id': profileId } };
211
211
  **Browse plans and estimate cost** before creating anything:
212
212
 
213
213
  ```typescript
214
- // List purchasable plans (or addons) with their prices
214
+ // List plans (or addons) with their prices. An item the processor lists but
215
+ // cannot sell right now comes back with `available: false` and no prices;
216
+ // skip it rather than offering it.
215
217
  const plans = await delopay.subscriptions.getItems({ item_type: 'plan' }, opts);
216
- const priceId = plans[0]?.price_id[0]?.price_id;
218
+ const priceId = plans.find((item) => item.available)?.price_id[0]?.price_id;
219
+ if (!priceId) {
220
+ throw new Error('No purchasable plan on this shop');
221
+ }
217
222
 
218
223
  // Preview what the customer will be charged
219
224
  const estimate = await delopay.subscriptions.getEstimate({ item_price_id: priceId }, opts);
@@ -1779,6 +1779,45 @@ var Payments = class {
1779
1779
  options
1780
1780
  );
1781
1781
  }
1782
+ /**
1783
+ * The routing decision recorded behind each attempt of a payment: which rule
1784
+ * matched, which candidates routing produced and which filter removed each,
1785
+ * which volume bucket was drawn and what the counters read, which
1786
+ * configuration version was live.
1787
+ *
1788
+ * This is the only truthful account of **how the connector was chosen**.
1789
+ * `routing_approach` on the payment is seeded on creation and several paths —
1790
+ * mandate, pre-routed and pinned-account among them — return before it is
1791
+ * overwritten, so it can still read `default_fallback` on a payment that was
1792
+ * routed by a rule. Read {@link RoutingDecision.decision_kind} instead.
1793
+ *
1794
+ * An attempt with `decision: null` simply has no record: the recorder is
1795
+ * best-effort, attempts that never reached routing have nothing to record,
1796
+ * and attempts predating the record exist in quantity. It is not an error.
1797
+ *
1798
+ * `GET /payments/{paymentId}/routing-decisions`
1799
+ *
1800
+ * @param paymentId - The payment intent ID.
1801
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
1802
+ * override, and an `AbortSignal`.
1803
+ * @returns Every attempt returned for this payment, with its decision.
1804
+ *
1805
+ * @example
1806
+ * ```typescript
1807
+ * const { attempts } = await delopay.payments.routingDecisions('pay_abc123');
1808
+ * for (const attempt of attempts) {
1809
+ * if (!attempt.decision) continue;
1810
+ * console.log(attempt.connector, attempt.decision.decision_kind);
1811
+ * }
1812
+ * ```
1813
+ */
1814
+ async routingDecisions(paymentId, options) {
1815
+ return this.request(
1816
+ "GET",
1817
+ `/payments/${encodeURIComponent(paymentId)}/routing-decisions`,
1818
+ options
1819
+ );
1820
+ }
1782
1821
  /**
1783
1822
  * Soft-delete a payment. Only payments whose status is in the merchant's
1784
1823
  * delete policy (see {@link Payments.getDeletePolicy}) can be deleted;
@@ -3625,6 +3664,9 @@ var Verification = class {
3625
3664
  };
3626
3665
 
3627
3666
  // src/resources/webhooks.ts
3667
+ function isSubscriptionLifecycleWebhook(object) {
3668
+ return typeof object.transition_id === "string";
3669
+ }
3628
3670
  function hexToBytes(hex) {
3629
3671
  if (hex.length === 0 || hex.length % 2 !== 0) return null;
3630
3672
  const bytes = new Uint8Array(hex.length / 2);
@@ -5489,7 +5531,12 @@ var SURCHARGE_POSITIONS = [
5489
5531
  "cornerStart",
5490
5532
  "cornerEnd"
5491
5533
  ];
5492
- var NATIVE_ELEMENT_POSITIONS = ["top", "bottom"];
5534
+ var NATIVE_ELEMENT_POSITIONS = [
5535
+ "top",
5536
+ "belowFields",
5537
+ "belowCard",
5538
+ "bottom"
5539
+ ];
5493
5540
  var SURCHARGE_STYLES = [
5494
5541
  "plain",
5495
5542
  "underline",
@@ -5905,6 +5952,8 @@ var DEFAULT_BRANDING_BASE = {
5905
5952
  // The button is the surface a buyer recognises fastest; it leads its section
5906
5953
  // unless the merchant says otherwise.
5907
5954
  nativeElementPosition: "top",
5955
+ // Side by side — see the field.
5956
+ nativeElementStacked: false,
5908
5957
  surchargeStyle: "badge",
5909
5958
  surchargeSize: "sm",
5910
5959
  surchargeShape: "pill",
@@ -5972,6 +6021,8 @@ var DEFAULT_BRANDING_BASE = {
5972
6021
  airwallexCardPreset: "",
5973
6022
  // Off. With this on, no buyer can pay by card on the shop.
5974
6023
  airwallexHideCard: false,
6024
+ // Off: the section is named, like every other section on the surface.
6025
+ airwallexHideCardTitle: false,
5975
6026
  airwallexFieldChrome: "outlined",
5976
6027
  airwallexLabelStyle: "",
5977
6028
  airwallexFieldFontSize: "md",
@@ -6568,6 +6619,10 @@ function decodeBranding(source) {
6568
6619
  SURCHARGE_POSITIONS,
6569
6620
  DEFAULT_BRANDING.surchargePosition
6570
6621
  ),
6622
+ nativeElementStacked: parseBool(
6623
+ extras["nativeElementStacked"],
6624
+ DEFAULT_BRANDING.nativeElementStacked
6625
+ ),
6571
6626
  nativeElementPosition: pickEnum(
6572
6627
  extras["nativeElementPosition"],
6573
6628
  NATIVE_ELEMENT_POSITIONS,
@@ -6673,6 +6728,10 @@ function decodeBranding(source) {
6673
6728
  AIRWALLEX_CARD_PRESETS
6674
6729
  ),
6675
6730
  airwallexHideCard: parseBool(extras["airwallexHideCard"], DEFAULT_BRANDING.airwallexHideCard),
6731
+ airwallexHideCardTitle: parseBool(
6732
+ extras["airwallexHideCardTitle"],
6733
+ DEFAULT_BRANDING.airwallexHideCardTitle
6734
+ ),
6676
6735
  airwallexFieldChrome: pickEnum(
6677
6736
  extras["airwallexFieldChrome"],
6678
6737
  AIRWALLEX_FIELD_CHROMES,
@@ -6740,6 +6799,7 @@ function encodeBranding(branding, base) {
6740
6799
  showSurcharge: String(branding.showSurcharge),
6741
6800
  surchargePosition: branding.surchargePosition,
6742
6801
  nativeElementPosition: branding.nativeElementPosition,
6802
+ nativeElementStacked: String(branding.nativeElementStacked),
6743
6803
  surchargeStyle: branding.surchargeStyle,
6744
6804
  surchargeSize: branding.surchargeSize,
6745
6805
  surchargeShape: branding.surchargeShape,
@@ -6772,6 +6832,7 @@ function encodeBranding(branding, base) {
6772
6832
  // by accident, which is how `summaryOrder` was lost.
6773
6833
  airwallexCardPreset: branding.airwallexCardPreset,
6774
6834
  airwallexHideCard: String(branding.airwallexHideCard),
6835
+ airwallexHideCardTitle: String(branding.airwallexHideCardTitle),
6775
6836
  airwallexFieldChrome: branding.airwallexFieldChrome,
6776
6837
  airwallexLabelStyle: branding.airwallexLabelStyle,
6777
6838
  airwallexFieldFontSize: branding.airwallexFieldFontSize,
@@ -6913,6 +6974,7 @@ function parseImportedBranding(raw) {
6913
6974
  SURCHARGE_POSITIONS,
6914
6975
  dflt.surchargePosition
6915
6976
  ),
6977
+ nativeElementStacked: parseBool(root["nativeElementStacked"], dflt.nativeElementStacked),
6916
6978
  nativeElementPosition: pickEnum(
6917
6979
  root["nativeElementPosition"],
6918
6980
  NATIVE_ELEMENT_POSITIONS,
@@ -7017,6 +7079,7 @@ function parseImportedBranding(raw) {
7017
7079
  AIRWALLEX_CARD_PRESETS
7018
7080
  ),
7019
7081
  airwallexHideCard: parseBool(root["airwallexHideCard"], dflt.airwallexHideCard),
7082
+ airwallexHideCardTitle: parseBool(root["airwallexHideCardTitle"], dflt.airwallexHideCardTitle),
7020
7083
  airwallexFieldChrome: pickEnum(
7021
7084
  root["airwallexFieldChrome"],
7022
7085
  AIRWALLEX_FIELD_CHROMES,
@@ -7889,6 +7952,7 @@ export {
7889
7952
  DelopayError,
7890
7953
  DelopayAuthenticationError,
7891
7954
  Search,
7955
+ isSubscriptionLifecycleWebhook,
7892
7956
  Webhooks,
7893
7957
  Analytics,
7894
7958
  AnalyticsDashboard,
@@ -8055,4 +8119,4 @@ export {
8055
8119
  decodeNativePanes,
8056
8120
  encodeNativePanes
8057
8121
  };
8058
- //# sourceMappingURL=chunk-OMJ6MVD4.js.map
8122
+ //# sourceMappingURL=chunk-YZABVF2X.js.map