@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.
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ __export(index_exports, {
30
30
  BRANDING_EXPORT_VERSION: () => BRANDING_EXPORT_VERSION,
31
31
  CHECKBOX_CHECKED: () => CHECKBOX_CHECKED,
32
32
  CHECKBOX_UNCHECKED: () => CHECKBOX_UNCHECKED,
33
+ CHECKOUT_EVENT_KINDS: () => CHECKOUT_EVENT_KINDS,
33
34
  CUSTOM_CSS_MAX_LENGTH: () => CUSTOM_CSS_MAX_LENGTH,
34
35
  CUSTOM_FIELDS_MAX: () => CUSTOM_FIELDS_MAX,
35
36
  CUSTOM_FIELD_CONDITIONS_MAX: () => CUSTOM_FIELD_CONDITIONS_MAX,
@@ -49,7 +50,11 @@ __export(index_exports, {
49
50
  FeeProgramBuilder: () => FeeProgramBuilder,
50
51
  Files: () => Files,
51
52
  Forex: () => Forex,
53
+ NATIVE_PANES_MAX: () => NATIVE_PANES_MAX,
54
+ NATIVE_PANE_CATEGORY_KEYS: () => NATIVE_PANE_CATEGORY_KEYS,
55
+ NATIVE_PANE_ICON_KEYS: () => NATIVE_PANE_ICON_KEYS,
52
56
  Regions: () => Regions,
57
+ STRIPE_NATIVE_PANE_METHODS: () => STRIPE_NATIVE_PANE_METHODS,
53
58
  Search: () => Search,
54
59
  Subscriptions: () => Subscriptions,
55
60
  Webhooks: () => Webhooks,
@@ -60,6 +65,7 @@ __export(index_exports, {
60
65
  buttonPadValue: () => buttonPadValue,
61
66
  cloneBranding: () => cloneBranding,
62
67
  cloneCustomField: () => cloneCustomField,
68
+ cloneNativePane: () => cloneNativePane,
63
69
  customFieldContextFromMetadata: () => customFieldContextFromMetadata,
64
70
  customFieldIsTextLike: () => customFieldIsTextLike,
65
71
  customFieldOperatorTakesValue: () => customFieldOperatorTakesValue,
@@ -68,15 +74,19 @@ __export(index_exports, {
68
74
  decodeBadges: () => decodeBadges,
69
75
  decodeBranding: () => decodeBranding,
70
76
  decodeCustomFields: () => decodeCustomFields,
77
+ decodeNativePanes: () => decodeNativePanes,
71
78
  defaultBranding: () => defaultBranding,
72
79
  defaultCustomFieldVisibility: () => defaultCustomFieldVisibility,
80
+ defaultNativePane: () => defaultNativePane,
73
81
  defaultOperatorForSource: () => defaultOperatorForSource,
74
82
  encodeBadges: () => encodeBadges,
75
83
  encodeBranding: () => encodeBranding,
76
84
  encodeCustomFields: () => encodeCustomFields,
85
+ encodeNativePanes: () => encodeNativePanes,
77
86
  evaluateCustomFieldCondition: () => evaluateCustomFieldCondition,
78
87
  evaluateCustomFieldVisibility: () => evaluateCustomFieldVisibility,
79
88
  feeProgram: () => feeProgram,
89
+ focusedCheckoutUrl: () => focusedCheckoutUrl,
80
90
  fontStack: () => fontStack,
81
91
  fontWeightValue: () => fontWeightValue,
82
92
  inputPadValue: () => inputPadValue,
@@ -85,6 +95,7 @@ __export(index_exports, {
85
95
  isHexColor: () => isHexColor,
86
96
  leaf: () => leaf,
87
97
  logoDimensions: () => logoDimensions,
98
+ nativePaneMethodInfo: () => nativePaneMethodInfo,
88
99
  parseCustomFieldsLoose: () => parseCustomFieldsLoose,
89
100
  parseImportedBranding: () => parseImportedBranding,
90
101
  programToTree: () => programToTree,
@@ -583,6 +594,23 @@ var Connectors = class {
583
594
  if (params === void 0) return this.request("POST", path);
584
595
  return this.request("POST", path, { body: params });
585
596
  }
597
+ /**
598
+ * Register checkout/shop domains as Stripe payment method domains, so Apple
599
+ * Pay renders on those pages.
600
+ * `POST /account/{merchantId}/connectors/{connectorId}/stripe/payment-method-domains`
601
+ *
602
+ * Stripe connectors only. One call registers against a single credential set
603
+ * (`environment`, default `'live'`) — call twice to cover live and sandbox.
604
+ * Per-URL outcomes come back in `results`; a missing sandbox credential set
605
+ * is a request-level 400.
606
+ */
607
+ async registerStripePaymentMethodDomains(merchantId, connectorId, params) {
608
+ return this.request(
609
+ "POST",
610
+ `/account/${encodeURIComponent(merchantId)}/connectors/${encodeURIComponent(connectorId)}/stripe/payment-method-domains`,
611
+ { body: params }
612
+ );
613
+ }
586
614
  /** Get registered webhooks for a connector. `GET /account/{merchantId}/connectors/webhooks/{connectorId}` */
587
615
  async getWebhook(merchantId, connectorId) {
588
616
  return this.request(
@@ -4817,6 +4845,235 @@ function shadowFor(style) {
4817
4845
  return "none";
4818
4846
  }
4819
4847
  }
4848
+
4849
+ // src/nativePanes.ts
4850
+ var STRIPE_NATIVE_PANE_METHODS = [
4851
+ {
4852
+ key: "apple_pay",
4853
+ rail: "wallet",
4854
+ defaultLabel: "Apple Pay",
4855
+ defaultSublabel: "Pay with Apple Pay",
4856
+ defaultCategory: "wallet",
4857
+ defaultIcon: "apple"
4858
+ },
4859
+ {
4860
+ key: "google_pay",
4861
+ rail: "wallet",
4862
+ defaultLabel: "Google Pay",
4863
+ defaultSublabel: "Pay with Google Pay",
4864
+ defaultCategory: "wallet",
4865
+ defaultIcon: "google"
4866
+ },
4867
+ {
4868
+ key: "link",
4869
+ rail: "wallet",
4870
+ defaultLabel: "Link",
4871
+ defaultSublabel: "Pay with saved details",
4872
+ defaultCategory: "wallet",
4873
+ defaultIcon: "wallet"
4874
+ },
4875
+ {
4876
+ key: "klarna",
4877
+ rail: "redirect",
4878
+ defaultLabel: "Klarna",
4879
+ defaultSublabel: "Pay later or in instalments",
4880
+ defaultCategory: "bnpl",
4881
+ defaultIcon: "bnpl"
4882
+ },
4883
+ {
4884
+ key: "affirm",
4885
+ rail: "redirect",
4886
+ defaultLabel: "Affirm",
4887
+ defaultSublabel: "Pay over time",
4888
+ defaultCategory: "bnpl",
4889
+ defaultIcon: "bnpl"
4890
+ },
4891
+ {
4892
+ key: "ideal",
4893
+ rail: "redirect",
4894
+ defaultLabel: "iDEAL",
4895
+ defaultSublabel: "Pay from your bank",
4896
+ defaultCategory: "bank_redirect",
4897
+ defaultIcon: "bank"
4898
+ },
4899
+ // eps / p24 / bancontact were removed from the router catalog: Stripe
4900
+ // hard-requires billing fields the focused checkout never collects (full
4901
+ // name for EPS/Bancontact, email for Przelewy24), so their tiles could
4902
+ // never succeed. They may return behind billing-aware gating.
4903
+ {
4904
+ key: "alipay",
4905
+ rail: "redirect",
4906
+ defaultLabel: "Alipay",
4907
+ defaultSublabel: "Pay with Alipay",
4908
+ defaultCategory: "wallet",
4909
+ defaultIcon: "wallet"
4910
+ },
4911
+ {
4912
+ key: "revolut_pay",
4913
+ rail: "redirect",
4914
+ defaultLabel: "Revolut Pay",
4915
+ defaultSublabel: "Pay with Revolut",
4916
+ defaultCategory: "wallet",
4917
+ defaultIcon: "wallet"
4918
+ },
4919
+ {
4920
+ key: "amazon_pay",
4921
+ rail: "redirect",
4922
+ defaultLabel: "Amazon Pay",
4923
+ defaultSublabel: "Pay with Amazon",
4924
+ defaultCategory: "wallet",
4925
+ defaultIcon: "wallet"
4926
+ }
4927
+ ];
4928
+ var NATIVE_PANE_ICON_KEYS = [
4929
+ "wallet",
4930
+ "card",
4931
+ "bank",
4932
+ "apple",
4933
+ "google",
4934
+ "bnpl",
4935
+ "cash"
4936
+ ];
4937
+ var NATIVE_PANE_CATEGORY_KEYS = [
4938
+ "wallet",
4939
+ "card",
4940
+ "bnpl",
4941
+ "bank_redirect",
4942
+ "bank_transfer",
4943
+ "cash"
4944
+ ];
4945
+ var NATIVE_PANES_MAX = 12;
4946
+ function nativePaneMethodInfo(method) {
4947
+ return STRIPE_NATIVE_PANE_METHODS.find((m) => m.key === method);
4948
+ }
4949
+ function defaultNativePane(method) {
4950
+ const info = nativePaneMethodInfo(method);
4951
+ return {
4952
+ method,
4953
+ enabled: true,
4954
+ label: "",
4955
+ labelTranslations: {},
4956
+ sublabel: null,
4957
+ sublabelTranslations: {},
4958
+ category: "",
4959
+ icon: info?.defaultIcon ?? "",
4960
+ iconSvg: "",
4961
+ displayOrder: 0,
4962
+ visibility: "always",
4963
+ openIn: "tab"
4964
+ };
4965
+ }
4966
+ function cloneNativePane(pane) {
4967
+ return {
4968
+ ...pane,
4969
+ labelTranslations: { ...pane.labelTranslations },
4970
+ sublabelTranslations: { ...pane.sublabelTranslations }
4971
+ };
4972
+ }
4973
+ function isObject2(value) {
4974
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4975
+ }
4976
+ function parseTranslations2(raw) {
4977
+ if (!isObject2(raw)) return {};
4978
+ const out = {};
4979
+ for (const [locale, value] of Object.entries(raw)) {
4980
+ if (typeof value === "string" && value.length > 0) out[locale] = value;
4981
+ }
4982
+ return out;
4983
+ }
4984
+ function str(raw) {
4985
+ return typeof raw === "string" ? raw : "";
4986
+ }
4987
+ var DISPLAY_ORDER_MIN = -2147483648;
4988
+ var DISPLAY_ORDER_MAX = 2147483647;
4989
+ function clampDisplayOrder(raw) {
4990
+ if (!Number.isFinite(raw)) return 0;
4991
+ return Math.min(DISPLAY_ORDER_MAX, Math.max(DISPLAY_ORDER_MIN, Math.trunc(raw)));
4992
+ }
4993
+ function decodeNativePanes(raw) {
4994
+ if (!Array.isArray(raw)) return null;
4995
+ const decodeRow = (entry, method) => ({
4996
+ method,
4997
+ enabled: entry["enabled"] !== false,
4998
+ label: str(entry["label"]),
4999
+ labelTranslations: parseTranslations2(entry["label_translations"]),
5000
+ sublabel: typeof entry["sublabel"] === "string" ? entry["sublabel"] : null,
5001
+ sublabelTranslations: parseTranslations2(entry["sublabel_translations"]),
5002
+ category: str(entry["category"]),
5003
+ icon: str(entry["icon"]),
5004
+ iconSvg: str(entry["icon_svg"]),
5005
+ displayOrder: clampDisplayOrder(Number(entry["display_order"])),
5006
+ // Anything unrecognised degrades to `always` rather than dropping the row.
5007
+ visibility: entry["visibility"] === "embedded_only" ? "embedded_only" : "always",
5008
+ // Same tolerance: an unknown value degrades to the default `tab`.
5009
+ openIn: entry["open_in"] === "popup" ? "popup" : "tab"
5010
+ });
5011
+ const indexByMethod = /* @__PURE__ */ new Map();
5012
+ const out = [];
5013
+ for (const entry of raw) {
5014
+ if (out.length >= NATIVE_PANES_MAX) break;
5015
+ if (!isObject2(entry)) continue;
5016
+ const method = str(entry["method"]).trim();
5017
+ if (!method) continue;
5018
+ const kept = indexByMethod.get(method);
5019
+ if (kept !== void 0) {
5020
+ const enabled = entry["enabled"] !== false;
5021
+ const existing = out[kept];
5022
+ if (enabled && existing && !existing.enabled) out[kept] = decodeRow(entry, method);
5023
+ continue;
5024
+ }
5025
+ indexByMethod.set(method, out.length);
5026
+ out.push(decodeRow(entry, method));
5027
+ }
5028
+ return out;
5029
+ }
5030
+ function encodeNativePanes(panes) {
5031
+ const nonEmpty = (map) => {
5032
+ const entries = Object.entries(map).filter(([, v]) => v.trim().length > 0);
5033
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
5034
+ };
5035
+ return panes.slice(0, NATIVE_PANES_MAX).map((pane) => {
5036
+ const labelTranslations = nonEmpty(pane.labelTranslations);
5037
+ const sublabelTranslations = nonEmpty(pane.sublabelTranslations);
5038
+ return {
5039
+ method: pane.method,
5040
+ enabled: pane.enabled,
5041
+ ...pane.label.trim() ? { label: pane.label.trim() } : {},
5042
+ ...labelTranslations ? { label_translations: labelTranslations } : {},
5043
+ // `null` omits the key entirely (catalog default wins); `''` is sent
5044
+ // as-is because that is how the merchant hides the second line.
5045
+ ...pane.sublabel !== null ? { sublabel: pane.sublabel } : {},
5046
+ ...sublabelTranslations ? { sublabel_translations: sublabelTranslations } : {},
5047
+ ...pane.category.trim() ? { category: pane.category.trim() } : {},
5048
+ ...pane.icon.trim() ? { icon: pane.icon.trim() } : {},
5049
+ ...pane.iconSvg.trim() ? { icon_svg: pane.iconSvg.trim() } : {},
5050
+ // Clamped on encode too, not only decode: the router's strict i32 row
5051
+ // decode drops a row whole for a fractional or out-of-range value, so
5052
+ // writing e.g. 3.5 or Date.now() verbatim would silently delete the
5053
+ // pane at render while every read surface shows it healthy.
5054
+ display_order: clampDisplayOrder(pane.displayOrder),
5055
+ visibility: pane.visibility,
5056
+ open_in: pane.openIn
5057
+ };
5058
+ });
5059
+ }
5060
+ function focusedCheckoutUrl(params) {
5061
+ const base = params.checkoutBaseUrl.replace(/\/+$/, "");
5062
+ const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
5063
+ params.paymentId
5064
+ )}`;
5065
+ const query = new URLSearchParams({ pane: params.method });
5066
+ if (params.locale) query.set("locale", params.locale);
5067
+ if (params.customFieldsCollected) query.set("cf", "1");
5068
+ return `${path}?${query.toString()}`;
5069
+ }
5070
+ var CHECKOUT_EVENT_KINDS = [
5071
+ "native_pane_selected",
5072
+ "native_pane_tab_opened",
5073
+ "native_pane_tab_blocked",
5074
+ "native_pane_abandoned",
5075
+ "native_pane_returned"
5076
+ ];
4820
5077
  // Annotate the CommonJS export names for ESM import in node:
4821
5078
  0 && (module.exports = {
4822
5079
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
@@ -4829,6 +5086,7 @@ function shadowFor(style) {
4829
5086
  BRANDING_EXPORT_VERSION,
4830
5087
  CHECKBOX_CHECKED,
4831
5088
  CHECKBOX_UNCHECKED,
5089
+ CHECKOUT_EVENT_KINDS,
4832
5090
  CUSTOM_CSS_MAX_LENGTH,
4833
5091
  CUSTOM_FIELDS_MAX,
4834
5092
  CUSTOM_FIELD_CONDITIONS_MAX,
@@ -4848,7 +5106,11 @@ function shadowFor(style) {
4848
5106
  FeeProgramBuilder,
4849
5107
  Files,
4850
5108
  Forex,
5109
+ NATIVE_PANES_MAX,
5110
+ NATIVE_PANE_CATEGORY_KEYS,
5111
+ NATIVE_PANE_ICON_KEYS,
4851
5112
  Regions,
5113
+ STRIPE_NATIVE_PANE_METHODS,
4852
5114
  Search,
4853
5115
  Subscriptions,
4854
5116
  Webhooks,
@@ -4859,6 +5121,7 @@ function shadowFor(style) {
4859
5121
  buttonPadValue,
4860
5122
  cloneBranding,
4861
5123
  cloneCustomField,
5124
+ cloneNativePane,
4862
5125
  customFieldContextFromMetadata,
4863
5126
  customFieldIsTextLike,
4864
5127
  customFieldOperatorTakesValue,
@@ -4867,15 +5130,19 @@ function shadowFor(style) {
4867
5130
  decodeBadges,
4868
5131
  decodeBranding,
4869
5132
  decodeCustomFields,
5133
+ decodeNativePanes,
4870
5134
  defaultBranding,
4871
5135
  defaultCustomFieldVisibility,
5136
+ defaultNativePane,
4872
5137
  defaultOperatorForSource,
4873
5138
  encodeBadges,
4874
5139
  encodeBranding,
4875
5140
  encodeCustomFields,
5141
+ encodeNativePanes,
4876
5142
  evaluateCustomFieldCondition,
4877
5143
  evaluateCustomFieldVisibility,
4878
5144
  feeProgram,
5145
+ focusedCheckoutUrl,
4879
5146
  fontStack,
4880
5147
  fontWeightValue,
4881
5148
  inputPadValue,
@@ -4884,6 +5151,7 @@ function shadowFor(style) {
4884
5151
  isHexColor,
4885
5152
  leaf,
4886
5153
  logoDimensions,
5154
+ nativePaneMethodInfo,
4887
5155
  parseCustomFieldsLoose,
4888
5156
  parseImportedBranding,
4889
5157
  programToTree,