@delopay/sdk 0.78.0 → 0.80.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.
@@ -483,6 +483,23 @@ var Connectors = class {
483
483
  if (params === void 0) return this.request("POST", path);
484
484
  return this.request("POST", path, { body: params });
485
485
  }
486
+ /**
487
+ * Register checkout/shop domains as Stripe payment method domains, so Apple
488
+ * Pay renders on those pages.
489
+ * `POST /account/{merchantId}/connectors/{connectorId}/stripe/payment-method-domains`
490
+ *
491
+ * Stripe connectors only. One call registers against a single credential set
492
+ * (`environment`, default `'live'`) — call twice to cover live and sandbox.
493
+ * Per-URL outcomes come back in `results`; a missing sandbox credential set
494
+ * is a request-level 400.
495
+ */
496
+ async registerStripePaymentMethodDomains(merchantId, connectorId, params) {
497
+ return this.request(
498
+ "POST",
499
+ `/account/${encodeURIComponent(merchantId)}/connectors/${encodeURIComponent(connectorId)}/stripe/payment-method-domains`,
500
+ { body: params }
501
+ );
502
+ }
486
503
  /** Get registered webhooks for a connector. `GET /account/{merchantId}/connectors/webhooks/{connectorId}` */
487
504
  async getWebhook(merchantId, connectorId) {
488
505
  return this.request(
@@ -4718,6 +4735,235 @@ function shadowFor(style) {
4718
4735
  }
4719
4736
  }
4720
4737
 
4738
+ // src/nativePanes.ts
4739
+ var STRIPE_NATIVE_PANE_METHODS = [
4740
+ {
4741
+ key: "apple_pay",
4742
+ rail: "wallet",
4743
+ defaultLabel: "Apple Pay",
4744
+ defaultSublabel: "Pay with Apple Pay",
4745
+ defaultCategory: "wallet",
4746
+ defaultIcon: "apple"
4747
+ },
4748
+ {
4749
+ key: "google_pay",
4750
+ rail: "wallet",
4751
+ defaultLabel: "Google Pay",
4752
+ defaultSublabel: "Pay with Google Pay",
4753
+ defaultCategory: "wallet",
4754
+ defaultIcon: "google"
4755
+ },
4756
+ {
4757
+ key: "link",
4758
+ rail: "wallet",
4759
+ defaultLabel: "Link",
4760
+ defaultSublabel: "Pay with saved details",
4761
+ defaultCategory: "wallet",
4762
+ defaultIcon: "wallet"
4763
+ },
4764
+ {
4765
+ key: "klarna",
4766
+ rail: "redirect",
4767
+ defaultLabel: "Klarna",
4768
+ defaultSublabel: "Pay later or in instalments",
4769
+ defaultCategory: "bnpl",
4770
+ defaultIcon: "bnpl"
4771
+ },
4772
+ {
4773
+ key: "affirm",
4774
+ rail: "redirect",
4775
+ defaultLabel: "Affirm",
4776
+ defaultSublabel: "Pay over time",
4777
+ defaultCategory: "bnpl",
4778
+ defaultIcon: "bnpl"
4779
+ },
4780
+ {
4781
+ key: "ideal",
4782
+ rail: "redirect",
4783
+ defaultLabel: "iDEAL",
4784
+ defaultSublabel: "Pay from your bank",
4785
+ defaultCategory: "bank_redirect",
4786
+ defaultIcon: "bank"
4787
+ },
4788
+ // eps / p24 / bancontact were removed from the router catalog: Stripe
4789
+ // hard-requires billing fields the focused checkout never collects (full
4790
+ // name for EPS/Bancontact, email for Przelewy24), so their tiles could
4791
+ // never succeed. They may return behind billing-aware gating.
4792
+ {
4793
+ key: "alipay",
4794
+ rail: "redirect",
4795
+ defaultLabel: "Alipay",
4796
+ defaultSublabel: "Pay with Alipay",
4797
+ defaultCategory: "wallet",
4798
+ defaultIcon: "wallet"
4799
+ },
4800
+ {
4801
+ key: "revolut_pay",
4802
+ rail: "redirect",
4803
+ defaultLabel: "Revolut Pay",
4804
+ defaultSublabel: "Pay with Revolut",
4805
+ defaultCategory: "wallet",
4806
+ defaultIcon: "wallet"
4807
+ },
4808
+ {
4809
+ key: "amazon_pay",
4810
+ rail: "redirect",
4811
+ defaultLabel: "Amazon Pay",
4812
+ defaultSublabel: "Pay with Amazon",
4813
+ defaultCategory: "wallet",
4814
+ defaultIcon: "wallet"
4815
+ }
4816
+ ];
4817
+ var NATIVE_PANE_ICON_KEYS = [
4818
+ "wallet",
4819
+ "card",
4820
+ "bank",
4821
+ "apple",
4822
+ "google",
4823
+ "bnpl",
4824
+ "cash"
4825
+ ];
4826
+ var NATIVE_PANE_CATEGORY_KEYS = [
4827
+ "wallet",
4828
+ "card",
4829
+ "bnpl",
4830
+ "bank_redirect",
4831
+ "bank_transfer",
4832
+ "cash"
4833
+ ];
4834
+ var NATIVE_PANES_MAX = 12;
4835
+ function nativePaneMethodInfo(method) {
4836
+ return STRIPE_NATIVE_PANE_METHODS.find((m) => m.key === method);
4837
+ }
4838
+ function defaultNativePane(method) {
4839
+ const info = nativePaneMethodInfo(method);
4840
+ return {
4841
+ method,
4842
+ enabled: true,
4843
+ label: "",
4844
+ labelTranslations: {},
4845
+ sublabel: null,
4846
+ sublabelTranslations: {},
4847
+ category: "",
4848
+ icon: info?.defaultIcon ?? "",
4849
+ iconSvg: "",
4850
+ displayOrder: 0,
4851
+ visibility: "always",
4852
+ openIn: "tab"
4853
+ };
4854
+ }
4855
+ function cloneNativePane(pane) {
4856
+ return {
4857
+ ...pane,
4858
+ labelTranslations: { ...pane.labelTranslations },
4859
+ sublabelTranslations: { ...pane.sublabelTranslations }
4860
+ };
4861
+ }
4862
+ function isObject2(value) {
4863
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4864
+ }
4865
+ function parseTranslations2(raw) {
4866
+ if (!isObject2(raw)) return {};
4867
+ const out = {};
4868
+ for (const [locale, value] of Object.entries(raw)) {
4869
+ if (typeof value === "string" && value.length > 0) out[locale] = value;
4870
+ }
4871
+ return out;
4872
+ }
4873
+ function str(raw) {
4874
+ return typeof raw === "string" ? raw : "";
4875
+ }
4876
+ var DISPLAY_ORDER_MIN = -2147483648;
4877
+ var DISPLAY_ORDER_MAX = 2147483647;
4878
+ function clampDisplayOrder(raw) {
4879
+ if (!Number.isFinite(raw)) return 0;
4880
+ return Math.min(DISPLAY_ORDER_MAX, Math.max(DISPLAY_ORDER_MIN, Math.trunc(raw)));
4881
+ }
4882
+ function decodeNativePanes(raw) {
4883
+ if (!Array.isArray(raw)) return null;
4884
+ const decodeRow = (entry, method) => ({
4885
+ method,
4886
+ enabled: entry["enabled"] !== false,
4887
+ label: str(entry["label"]),
4888
+ labelTranslations: parseTranslations2(entry["label_translations"]),
4889
+ sublabel: typeof entry["sublabel"] === "string" ? entry["sublabel"] : null,
4890
+ sublabelTranslations: parseTranslations2(entry["sublabel_translations"]),
4891
+ category: str(entry["category"]),
4892
+ icon: str(entry["icon"]),
4893
+ iconSvg: str(entry["icon_svg"]),
4894
+ displayOrder: clampDisplayOrder(Number(entry["display_order"])),
4895
+ // Anything unrecognised degrades to `always` rather than dropping the row.
4896
+ visibility: entry["visibility"] === "embedded_only" ? "embedded_only" : "always",
4897
+ // Same tolerance: an unknown value degrades to the default `tab`.
4898
+ openIn: entry["open_in"] === "popup" ? "popup" : "tab"
4899
+ });
4900
+ const indexByMethod = /* @__PURE__ */ new Map();
4901
+ const out = [];
4902
+ for (const entry of raw) {
4903
+ if (out.length >= NATIVE_PANES_MAX) break;
4904
+ if (!isObject2(entry)) continue;
4905
+ const method = str(entry["method"]).trim();
4906
+ if (!method) continue;
4907
+ const kept = indexByMethod.get(method);
4908
+ if (kept !== void 0) {
4909
+ const enabled = entry["enabled"] !== false;
4910
+ const existing = out[kept];
4911
+ if (enabled && existing && !existing.enabled) out[kept] = decodeRow(entry, method);
4912
+ continue;
4913
+ }
4914
+ indexByMethod.set(method, out.length);
4915
+ out.push(decodeRow(entry, method));
4916
+ }
4917
+ return out;
4918
+ }
4919
+ function encodeNativePanes(panes) {
4920
+ const nonEmpty = (map) => {
4921
+ const entries = Object.entries(map).filter(([, v]) => v.trim().length > 0);
4922
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
4923
+ };
4924
+ return panes.slice(0, NATIVE_PANES_MAX).map((pane) => {
4925
+ const labelTranslations = nonEmpty(pane.labelTranslations);
4926
+ const sublabelTranslations = nonEmpty(pane.sublabelTranslations);
4927
+ return {
4928
+ method: pane.method,
4929
+ enabled: pane.enabled,
4930
+ ...pane.label.trim() ? { label: pane.label.trim() } : {},
4931
+ ...labelTranslations ? { label_translations: labelTranslations } : {},
4932
+ // `null` omits the key entirely (catalog default wins); `''` is sent
4933
+ // as-is because that is how the merchant hides the second line.
4934
+ ...pane.sublabel !== null ? { sublabel: pane.sublabel } : {},
4935
+ ...sublabelTranslations ? { sublabel_translations: sublabelTranslations } : {},
4936
+ ...pane.category.trim() ? { category: pane.category.trim() } : {},
4937
+ ...pane.icon.trim() ? { icon: pane.icon.trim() } : {},
4938
+ ...pane.iconSvg.trim() ? { icon_svg: pane.iconSvg.trim() } : {},
4939
+ // Clamped on encode too, not only decode: the router's strict i32 row
4940
+ // decode drops a row whole for a fractional or out-of-range value, so
4941
+ // writing e.g. 3.5 or Date.now() verbatim would silently delete the
4942
+ // pane at render while every read surface shows it healthy.
4943
+ display_order: clampDisplayOrder(pane.displayOrder),
4944
+ visibility: pane.visibility,
4945
+ open_in: pane.openIn
4946
+ };
4947
+ });
4948
+ }
4949
+ function focusedCheckoutUrl(params) {
4950
+ const base = params.checkoutBaseUrl.replace(/\/+$/, "");
4951
+ const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
4952
+ params.paymentId
4953
+ )}`;
4954
+ const query = new URLSearchParams({ pane: params.method });
4955
+ if (params.locale) query.set("locale", params.locale);
4956
+ if (params.customFieldsCollected) query.set("cf", "1");
4957
+ return `${path}?${query.toString()}`;
4958
+ }
4959
+ var CHECKOUT_EVENT_KINDS = [
4960
+ "native_pane_selected",
4961
+ "native_pane_tab_opened",
4962
+ "native_pane_tab_blocked",
4963
+ "native_pane_abandoned",
4964
+ "native_pane_returned"
4965
+ ];
4966
+
4721
4967
  export {
4722
4968
  DelopayError,
4723
4969
  DelopayAuthenticationError,
@@ -4793,6 +5039,17 @@ export {
4793
5039
  buildBrandingExport,
4794
5040
  parseImportedBranding,
4795
5041
  applyBrandingVariables,
4796
- shadowFor
5042
+ shadowFor,
5043
+ STRIPE_NATIVE_PANE_METHODS,
5044
+ NATIVE_PANE_ICON_KEYS,
5045
+ NATIVE_PANE_CATEGORY_KEYS,
5046
+ NATIVE_PANES_MAX,
5047
+ nativePaneMethodInfo,
5048
+ defaultNativePane,
5049
+ cloneNativePane,
5050
+ decodeNativePanes,
5051
+ encodeNativePanes,
5052
+ focusedCheckoutUrl,
5053
+ CHECKOUT_EVENT_KINDS
4797
5054
  };
4798
- //# sourceMappingURL=chunk-MX26LF5P.js.map
5055
+ //# sourceMappingURL=chunk-PHKXFVHZ.js.map