@delopay/sdk 0.78.0 → 0.79.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.js CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  BRANDING_EXPORT_VERSION,
10
10
  CHECKBOX_CHECKED,
11
11
  CHECKBOX_UNCHECKED,
12
+ CHECKOUT_EVENT_KINDS,
12
13
  CUSTOM_CSS_MAX_LENGTH,
13
14
  CUSTOM_FIELDS_MAX,
14
15
  CUSTOM_FIELD_CONDITIONS_MAX,
@@ -28,7 +29,11 @@ import {
28
29
  FeeProgramBuilder,
29
30
  Files,
30
31
  Forex,
32
+ NATIVE_PANES_MAX,
33
+ NATIVE_PANE_CATEGORY_KEYS,
34
+ NATIVE_PANE_ICON_KEYS,
31
35
  Regions,
36
+ STRIPE_NATIVE_PANE_METHODS,
32
37
  Search,
33
38
  Subscriptions,
34
39
  Webhooks,
@@ -39,6 +44,7 @@ import {
39
44
  buttonPadValue,
40
45
  cloneBranding,
41
46
  cloneCustomField,
47
+ cloneNativePane,
42
48
  customFieldContextFromMetadata,
43
49
  customFieldIsTextLike,
44
50
  customFieldOperatorTakesValue,
@@ -47,15 +53,19 @@ import {
47
53
  decodeBadges,
48
54
  decodeBranding,
49
55
  decodeCustomFields,
56
+ decodeNativePanes,
50
57
  defaultBranding,
51
58
  defaultCustomFieldVisibility,
59
+ defaultNativePane,
52
60
  defaultOperatorForSource,
53
61
  encodeBadges,
54
62
  encodeBranding,
55
63
  encodeCustomFields,
64
+ encodeNativePanes,
56
65
  evaluateCustomFieldCondition,
57
66
  evaluateCustomFieldVisibility,
58
67
  feeProgram,
68
+ focusedCheckoutUrl,
59
69
  fontStack,
60
70
  fontWeightValue,
61
71
  inputPadValue,
@@ -64,6 +74,7 @@ import {
64
74
  isHexColor,
65
75
  leaf,
66
76
  logoDimensions,
77
+ nativePaneMethodInfo,
67
78
  parseCustomFieldsLoose,
68
79
  parseImportedBranding,
69
80
  programToTree,
@@ -74,7 +85,7 @@ import {
74
85
  surfacePadValue,
75
86
  verticalGapValue,
76
87
  visibleCustomFields
77
- } from "./chunk-MX26LF5P.js";
88
+ } from "./chunk-TV4YASDP.js";
78
89
  export {
79
90
  ALL_CUSTOM_FIELD_CONDITION_SOURCES,
80
91
  ALL_CUSTOM_FIELD_OPERATORS,
@@ -86,6 +97,7 @@ export {
86
97
  BRANDING_EXPORT_VERSION,
87
98
  CHECKBOX_CHECKED,
88
99
  CHECKBOX_UNCHECKED,
100
+ CHECKOUT_EVENT_KINDS,
89
101
  CUSTOM_CSS_MAX_LENGTH,
90
102
  CUSTOM_FIELDS_MAX,
91
103
  CUSTOM_FIELD_CONDITIONS_MAX,
@@ -105,7 +117,11 @@ export {
105
117
  FeeProgramBuilder,
106
118
  Files,
107
119
  Forex,
120
+ NATIVE_PANES_MAX,
121
+ NATIVE_PANE_CATEGORY_KEYS,
122
+ NATIVE_PANE_ICON_KEYS,
108
123
  Regions,
124
+ STRIPE_NATIVE_PANE_METHODS,
109
125
  Search,
110
126
  Subscriptions,
111
127
  Webhooks,
@@ -116,6 +132,7 @@ export {
116
132
  buttonPadValue,
117
133
  cloneBranding,
118
134
  cloneCustomField,
135
+ cloneNativePane,
119
136
  customFieldContextFromMetadata,
120
137
  customFieldIsTextLike,
121
138
  customFieldOperatorTakesValue,
@@ -124,15 +141,19 @@ export {
124
141
  decodeBadges,
125
142
  decodeBranding,
126
143
  decodeCustomFields,
144
+ decodeNativePanes,
127
145
  defaultBranding,
128
146
  defaultCustomFieldVisibility,
147
+ defaultNativePane,
129
148
  defaultOperatorForSource,
130
149
  encodeBadges,
131
150
  encodeBranding,
132
151
  encodeCustomFields,
152
+ encodeNativePanes,
133
153
  evaluateCustomFieldCondition,
134
154
  evaluateCustomFieldVisibility,
135
155
  feeProgram,
156
+ focusedCheckoutUrl,
136
157
  fontStack,
137
158
  fontWeightValue,
138
159
  inputPadValue,
@@ -141,6 +162,7 @@ export {
141
162
  isHexColor,
142
163
  leaf,
143
164
  logoDimensions,
165
+ nativePaneMethodInfo,
144
166
  parseCustomFieldsLoose,
145
167
  parseImportedBranding,
146
168
  programToTree,
package/dist/internal.cjs CHANGED
@@ -33,6 +33,7 @@ __export(internal_exports, {
33
33
  BRANDING_EXPORT_VERSION: () => BRANDING_EXPORT_VERSION,
34
34
  CHECKBOX_CHECKED: () => CHECKBOX_CHECKED,
35
35
  CHECKBOX_UNCHECKED: () => CHECKBOX_UNCHECKED,
36
+ CHECKOUT_EVENT_KINDS: () => CHECKOUT_EVENT_KINDS,
36
37
  CUSTOM_CSS_MAX_LENGTH: () => CUSTOM_CSS_MAX_LENGTH,
37
38
  CUSTOM_FIELDS_MAX: () => CUSTOM_FIELDS_MAX,
38
39
  CUSTOM_FIELD_CONDITIONS_MAX: () => CUSTOM_FIELD_CONDITIONS_MAX,
@@ -59,9 +60,13 @@ __export(internal_exports, {
59
60
  Files: () => Files,
60
61
  Forex: () => Forex,
61
62
  Gsm: () => Gsm,
63
+ NATIVE_PANES_MAX: () => NATIVE_PANES_MAX,
64
+ NATIVE_PANE_CATEGORY_KEYS: () => NATIVE_PANE_CATEGORY_KEYS,
65
+ NATIVE_PANE_ICON_KEYS: () => NATIVE_PANE_ICON_KEYS,
62
66
  PlatformBilling: () => PlatformBilling,
63
67
  PlatformFees: () => PlatformFees,
64
68
  Regions: () => Regions,
69
+ STRIPE_NATIVE_PANE_METHODS: () => STRIPE_NATIVE_PANE_METHODS,
65
70
  Search: () => Search,
66
71
  Subscriptions: () => Subscriptions,
67
72
  Webhooks: () => Webhooks,
@@ -72,6 +77,7 @@ __export(internal_exports, {
72
77
  buttonPadValue: () => buttonPadValue,
73
78
  cloneBranding: () => cloneBranding,
74
79
  cloneCustomField: () => cloneCustomField,
80
+ cloneNativePane: () => cloneNativePane,
75
81
  customFieldContextFromMetadata: () => customFieldContextFromMetadata,
76
82
  customFieldIsTextLike: () => customFieldIsTextLike,
77
83
  customFieldOperatorTakesValue: () => customFieldOperatorTakesValue,
@@ -80,15 +86,19 @@ __export(internal_exports, {
80
86
  decodeBadges: () => decodeBadges,
81
87
  decodeBranding: () => decodeBranding,
82
88
  decodeCustomFields: () => decodeCustomFields,
89
+ decodeNativePanes: () => decodeNativePanes,
83
90
  defaultBranding: () => defaultBranding,
84
91
  defaultCustomFieldVisibility: () => defaultCustomFieldVisibility,
92
+ defaultNativePane: () => defaultNativePane,
85
93
  defaultOperatorForSource: () => defaultOperatorForSource,
86
94
  encodeBadges: () => encodeBadges,
87
95
  encodeBranding: () => encodeBranding,
88
96
  encodeCustomFields: () => encodeCustomFields,
97
+ encodeNativePanes: () => encodeNativePanes,
89
98
  evaluateCustomFieldCondition: () => evaluateCustomFieldCondition,
90
99
  evaluateCustomFieldVisibility: () => evaluateCustomFieldVisibility,
91
100
  feeProgram: () => feeProgram,
101
+ focusedCheckoutUrl: () => focusedCheckoutUrl,
92
102
  fontStack: () => fontStack,
93
103
  fontWeightValue: () => fontWeightValue,
94
104
  inputPadValue: () => inputPadValue,
@@ -97,6 +107,7 @@ __export(internal_exports, {
97
107
  isHexColor: () => isHexColor,
98
108
  leaf: () => leaf,
99
109
  logoDimensions: () => logoDimensions,
110
+ nativePaneMethodInfo: () => nativePaneMethodInfo,
100
111
  parseCustomFieldsLoose: () => parseCustomFieldsLoose,
101
112
  parseImportedBranding: () => parseImportedBranding,
102
113
  programToTree: () => programToTree,
@@ -4830,6 +4841,230 @@ function shadowFor(style) {
4830
4841
  }
4831
4842
  }
4832
4843
 
4844
+ // src/nativePanes.ts
4845
+ var STRIPE_NATIVE_PANE_METHODS = [
4846
+ {
4847
+ key: "apple_pay",
4848
+ rail: "wallet",
4849
+ defaultLabel: "Apple Pay",
4850
+ defaultSublabel: "Pay with Apple Pay",
4851
+ defaultCategory: "wallet",
4852
+ defaultIcon: "apple"
4853
+ },
4854
+ {
4855
+ key: "google_pay",
4856
+ rail: "wallet",
4857
+ defaultLabel: "Google Pay",
4858
+ defaultSublabel: "Pay with Google Pay",
4859
+ defaultCategory: "wallet",
4860
+ defaultIcon: "google"
4861
+ },
4862
+ {
4863
+ key: "link",
4864
+ rail: "wallet",
4865
+ defaultLabel: "Link",
4866
+ defaultSublabel: "Pay with saved details",
4867
+ defaultCategory: "wallet",
4868
+ defaultIcon: "wallet"
4869
+ },
4870
+ {
4871
+ key: "klarna",
4872
+ rail: "redirect",
4873
+ defaultLabel: "Klarna",
4874
+ defaultSublabel: "Pay later or in instalments",
4875
+ defaultCategory: "bnpl",
4876
+ defaultIcon: "bnpl"
4877
+ },
4878
+ {
4879
+ key: "affirm",
4880
+ rail: "redirect",
4881
+ defaultLabel: "Affirm",
4882
+ defaultSublabel: "Pay over time",
4883
+ defaultCategory: "bnpl",
4884
+ defaultIcon: "bnpl"
4885
+ },
4886
+ {
4887
+ key: "ideal",
4888
+ rail: "redirect",
4889
+ defaultLabel: "iDEAL",
4890
+ defaultSublabel: "Pay from your bank",
4891
+ defaultCategory: "bank_redirect",
4892
+ defaultIcon: "bank"
4893
+ },
4894
+ // eps / p24 / bancontact were removed from the router catalog: Stripe
4895
+ // hard-requires billing fields the focused checkout never collects (full
4896
+ // name for EPS/Bancontact, email for Przelewy24), so their tiles could
4897
+ // never succeed. They may return behind billing-aware gating.
4898
+ {
4899
+ key: "alipay",
4900
+ rail: "redirect",
4901
+ defaultLabel: "Alipay",
4902
+ defaultSublabel: "Pay with Alipay",
4903
+ defaultCategory: "wallet",
4904
+ defaultIcon: "wallet"
4905
+ },
4906
+ {
4907
+ key: "revolut_pay",
4908
+ rail: "redirect",
4909
+ defaultLabel: "Revolut Pay",
4910
+ defaultSublabel: "Pay with Revolut",
4911
+ defaultCategory: "wallet",
4912
+ defaultIcon: "wallet"
4913
+ },
4914
+ {
4915
+ key: "amazon_pay",
4916
+ rail: "redirect",
4917
+ defaultLabel: "Amazon Pay",
4918
+ defaultSublabel: "Pay with Amazon",
4919
+ defaultCategory: "wallet",
4920
+ defaultIcon: "wallet"
4921
+ }
4922
+ ];
4923
+ var NATIVE_PANE_ICON_KEYS = [
4924
+ "wallet",
4925
+ "card",
4926
+ "bank",
4927
+ "apple",
4928
+ "google",
4929
+ "bnpl",
4930
+ "cash"
4931
+ ];
4932
+ var NATIVE_PANE_CATEGORY_KEYS = [
4933
+ "wallet",
4934
+ "card",
4935
+ "bnpl",
4936
+ "bank_redirect",
4937
+ "bank_transfer",
4938
+ "cash"
4939
+ ];
4940
+ var NATIVE_PANES_MAX = 12;
4941
+ function nativePaneMethodInfo(method) {
4942
+ return STRIPE_NATIVE_PANE_METHODS.find((m) => m.key === method);
4943
+ }
4944
+ function defaultNativePane(method) {
4945
+ const info = nativePaneMethodInfo(method);
4946
+ return {
4947
+ method,
4948
+ enabled: true,
4949
+ label: "",
4950
+ labelTranslations: {},
4951
+ sublabel: null,
4952
+ sublabelTranslations: {},
4953
+ category: "",
4954
+ icon: info?.defaultIcon ?? "",
4955
+ iconSvg: "",
4956
+ displayOrder: 0,
4957
+ visibility: "always"
4958
+ };
4959
+ }
4960
+ function cloneNativePane(pane) {
4961
+ return {
4962
+ ...pane,
4963
+ labelTranslations: { ...pane.labelTranslations },
4964
+ sublabelTranslations: { ...pane.sublabelTranslations }
4965
+ };
4966
+ }
4967
+ function isObject2(value) {
4968
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4969
+ }
4970
+ function parseTranslations2(raw) {
4971
+ if (!isObject2(raw)) return {};
4972
+ const out = {};
4973
+ for (const [locale, value] of Object.entries(raw)) {
4974
+ if (typeof value === "string" && value.length > 0) out[locale] = value;
4975
+ }
4976
+ return out;
4977
+ }
4978
+ function str(raw) {
4979
+ return typeof raw === "string" ? raw : "";
4980
+ }
4981
+ var DISPLAY_ORDER_MIN = -2147483648;
4982
+ var DISPLAY_ORDER_MAX = 2147483647;
4983
+ function clampDisplayOrder(raw) {
4984
+ if (!Number.isFinite(raw)) return 0;
4985
+ return Math.min(DISPLAY_ORDER_MAX, Math.max(DISPLAY_ORDER_MIN, Math.trunc(raw)));
4986
+ }
4987
+ function decodeNativePanes(raw) {
4988
+ if (!Array.isArray(raw)) return null;
4989
+ const decodeRow = (entry, method) => ({
4990
+ method,
4991
+ enabled: entry["enabled"] !== false,
4992
+ label: str(entry["label"]),
4993
+ labelTranslations: parseTranslations2(entry["label_translations"]),
4994
+ sublabel: typeof entry["sublabel"] === "string" ? entry["sublabel"] : null,
4995
+ sublabelTranslations: parseTranslations2(entry["sublabel_translations"]),
4996
+ category: str(entry["category"]),
4997
+ icon: str(entry["icon"]),
4998
+ iconSvg: str(entry["icon_svg"]),
4999
+ displayOrder: clampDisplayOrder(Number(entry["display_order"])),
5000
+ // Anything unrecognised degrades to `always` rather than dropping the row.
5001
+ visibility: entry["visibility"] === "embedded_only" ? "embedded_only" : "always"
5002
+ });
5003
+ const indexByMethod = /* @__PURE__ */ new Map();
5004
+ const out = [];
5005
+ for (const entry of raw) {
5006
+ if (out.length >= NATIVE_PANES_MAX) break;
5007
+ if (!isObject2(entry)) continue;
5008
+ const method = str(entry["method"]).trim();
5009
+ if (!method) continue;
5010
+ const kept = indexByMethod.get(method);
5011
+ if (kept !== void 0) {
5012
+ const enabled = entry["enabled"] !== false;
5013
+ const existing = out[kept];
5014
+ if (enabled && existing && !existing.enabled) out[kept] = decodeRow(entry, method);
5015
+ continue;
5016
+ }
5017
+ indexByMethod.set(method, out.length);
5018
+ out.push(decodeRow(entry, method));
5019
+ }
5020
+ return out;
5021
+ }
5022
+ function encodeNativePanes(panes) {
5023
+ const nonEmpty = (map) => {
5024
+ const entries = Object.entries(map).filter(([, v]) => v.trim().length > 0);
5025
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
5026
+ };
5027
+ return panes.slice(0, NATIVE_PANES_MAX).map((pane) => {
5028
+ const labelTranslations = nonEmpty(pane.labelTranslations);
5029
+ const sublabelTranslations = nonEmpty(pane.sublabelTranslations);
5030
+ return {
5031
+ method: pane.method,
5032
+ enabled: pane.enabled,
5033
+ ...pane.label.trim() ? { label: pane.label.trim() } : {},
5034
+ ...labelTranslations ? { label_translations: labelTranslations } : {},
5035
+ // `null` omits the key entirely (catalog default wins); `''` is sent
5036
+ // as-is because that is how the merchant hides the second line.
5037
+ ...pane.sublabel !== null ? { sublabel: pane.sublabel } : {},
5038
+ ...sublabelTranslations ? { sublabel_translations: sublabelTranslations } : {},
5039
+ ...pane.category.trim() ? { category: pane.category.trim() } : {},
5040
+ ...pane.icon.trim() ? { icon: pane.icon.trim() } : {},
5041
+ ...pane.iconSvg.trim() ? { icon_svg: pane.iconSvg.trim() } : {},
5042
+ // Clamped on encode too, not only decode: the router's strict i32 row
5043
+ // decode drops a row whole for a fractional or out-of-range value, so
5044
+ // writing e.g. 3.5 or Date.now() verbatim would silently delete the
5045
+ // pane at render while every read surface shows it healthy.
5046
+ display_order: clampDisplayOrder(pane.displayOrder),
5047
+ visibility: pane.visibility
5048
+ };
5049
+ });
5050
+ }
5051
+ function focusedCheckoutUrl(params) {
5052
+ const base = params.checkoutBaseUrl.replace(/\/+$/, "");
5053
+ const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(
5054
+ params.paymentId
5055
+ )}`;
5056
+ const query = new URLSearchParams({ pane: params.method });
5057
+ if (params.locale) query.set("locale", params.locale);
5058
+ if (params.customFieldsCollected) query.set("cf", "1");
5059
+ return `${path}?${query.toString()}`;
5060
+ }
5061
+ var CHECKOUT_EVENT_KINDS = [
5062
+ "native_pane_selected",
5063
+ "native_pane_tab_opened",
5064
+ "native_pane_tab_blocked",
5065
+ "native_pane_abandoned"
5066
+ ];
5067
+
4833
5068
  // src/internal/resources/admin.ts
4834
5069
  var Admin = class {
4835
5070
  constructor(request) {
@@ -5407,6 +5642,7 @@ var DelopayInternal = class extends Delopay {
5407
5642
  BRANDING_EXPORT_VERSION,
5408
5643
  CHECKBOX_CHECKED,
5409
5644
  CHECKBOX_UNCHECKED,
5645
+ CHECKOUT_EVENT_KINDS,
5410
5646
  CUSTOM_CSS_MAX_LENGTH,
5411
5647
  CUSTOM_FIELDS_MAX,
5412
5648
  CUSTOM_FIELD_CONDITIONS_MAX,
@@ -5433,9 +5669,13 @@ var DelopayInternal = class extends Delopay {
5433
5669
  Files,
5434
5670
  Forex,
5435
5671
  Gsm,
5672
+ NATIVE_PANES_MAX,
5673
+ NATIVE_PANE_CATEGORY_KEYS,
5674
+ NATIVE_PANE_ICON_KEYS,
5436
5675
  PlatformBilling,
5437
5676
  PlatformFees,
5438
5677
  Regions,
5678
+ STRIPE_NATIVE_PANE_METHODS,
5439
5679
  Search,
5440
5680
  Subscriptions,
5441
5681
  Webhooks,
@@ -5446,6 +5686,7 @@ var DelopayInternal = class extends Delopay {
5446
5686
  buttonPadValue,
5447
5687
  cloneBranding,
5448
5688
  cloneCustomField,
5689
+ cloneNativePane,
5449
5690
  customFieldContextFromMetadata,
5450
5691
  customFieldIsTextLike,
5451
5692
  customFieldOperatorTakesValue,
@@ -5454,15 +5695,19 @@ var DelopayInternal = class extends Delopay {
5454
5695
  decodeBadges,
5455
5696
  decodeBranding,
5456
5697
  decodeCustomFields,
5698
+ decodeNativePanes,
5457
5699
  defaultBranding,
5458
5700
  defaultCustomFieldVisibility,
5701
+ defaultNativePane,
5459
5702
  defaultOperatorForSource,
5460
5703
  encodeBadges,
5461
5704
  encodeBranding,
5462
5705
  encodeCustomFields,
5706
+ encodeNativePanes,
5463
5707
  evaluateCustomFieldCondition,
5464
5708
  evaluateCustomFieldVisibility,
5465
5709
  feeProgram,
5710
+ focusedCheckoutUrl,
5466
5711
  fontStack,
5467
5712
  fontWeightValue,
5468
5713
  inputPadValue,
@@ -5471,6 +5716,7 @@ var DelopayInternal = class extends Delopay {
5471
5716
  isHexColor,
5472
5717
  leaf,
5473
5718
  logoDimensions,
5719
+ nativePaneMethodInfo,
5474
5720
  parseCustomFieldsLoose,
5475
5721
  parseImportedBranding,
5476
5722
  programToTree,