@delopay/sdk 0.77.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/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,
@@ -1165,10 +1176,45 @@ var PaymentMethods = class {
1165
1176
  return this.request("DELETE", `/payment-methods/${encodeURIComponent(methodId)}`);
1166
1177
  }
1167
1178
  /**
1168
- * List payment methods using a client secret.
1179
+ * List the payment methods available for a payment — the discovery endpoint a
1180
+ * custom checkout renders its tiles from.
1169
1181
  *
1170
- * @param params - Filter by `client_secret`.
1171
- * @returns Array of payment methods.
1182
+ * Callable with a publishable key plus the payment's `client_secret`, so it
1183
+ * runs from the browser. The returned set is already filtered by country,
1184
+ * order value and the merchant's availability rules, and each entry carries
1185
+ * `display` (name + icon slug) and `amount_limits` (the order values it stays
1186
+ * available for) so you do not have to maintain either alongside.
1187
+ *
1188
+ * This is *not* the customer's saved methods — see {@link listForCustomer}.
1189
+ *
1190
+ * @param params - `client_secret`, plus optional `country`, `amount` and filters.
1191
+ * @returns The methods available for the payment, grouped by payment method.
1192
+ *
1193
+ * @example
1194
+ * ```typescript
1195
+ * const { payment_methods } = await delopay.paymentMethods.list({
1196
+ * client_secret: 'pay_abc_secret_xyz',
1197
+ * country: 'DE',
1198
+ * amount: 25000,
1199
+ * });
1200
+ *
1201
+ * for (const group of payment_methods) {
1202
+ * for (const method of group.payment_method_types) {
1203
+ * // Re-check availability yourself as the cart total changes, instead of
1204
+ * // re-listing on every keystroke.
1205
+ * const limits = method.amount_limits;
1206
+ * const available =
1207
+ * !limits ||
1208
+ * ((limits.min_amount == null || cartTotal >= limits.min_amount) &&
1209
+ * (limits.max_amount == null || cartTotal <= limits.max_amount) &&
1210
+ * !limits.excluded_ranges.some(
1211
+ * (band) => cartTotal >= band.min_amount && cartTotal <= band.max_amount,
1212
+ * ));
1213
+ *
1214
+ * if (available) render(method.display?.display_name, method.display?.icon_slug);
1215
+ * }
1216
+ * }
1217
+ * ```
1172
1218
  */
1173
1219
  async list(params) {
1174
1220
  return this.request("GET", "/payment-methods", {
@@ -4795,6 +4841,230 @@ function shadowFor(style) {
4795
4841
  }
4796
4842
  }
4797
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
+
4798
5068
  // src/internal/resources/admin.ts
4799
5069
  var Admin = class {
4800
5070
  constructor(request) {
@@ -5372,6 +5642,7 @@ var DelopayInternal = class extends Delopay {
5372
5642
  BRANDING_EXPORT_VERSION,
5373
5643
  CHECKBOX_CHECKED,
5374
5644
  CHECKBOX_UNCHECKED,
5645
+ CHECKOUT_EVENT_KINDS,
5375
5646
  CUSTOM_CSS_MAX_LENGTH,
5376
5647
  CUSTOM_FIELDS_MAX,
5377
5648
  CUSTOM_FIELD_CONDITIONS_MAX,
@@ -5398,9 +5669,13 @@ var DelopayInternal = class extends Delopay {
5398
5669
  Files,
5399
5670
  Forex,
5400
5671
  Gsm,
5672
+ NATIVE_PANES_MAX,
5673
+ NATIVE_PANE_CATEGORY_KEYS,
5674
+ NATIVE_PANE_ICON_KEYS,
5401
5675
  PlatformBilling,
5402
5676
  PlatformFees,
5403
5677
  Regions,
5678
+ STRIPE_NATIVE_PANE_METHODS,
5404
5679
  Search,
5405
5680
  Subscriptions,
5406
5681
  Webhooks,
@@ -5411,6 +5686,7 @@ var DelopayInternal = class extends Delopay {
5411
5686
  buttonPadValue,
5412
5687
  cloneBranding,
5413
5688
  cloneCustomField,
5689
+ cloneNativePane,
5414
5690
  customFieldContextFromMetadata,
5415
5691
  customFieldIsTextLike,
5416
5692
  customFieldOperatorTakesValue,
@@ -5419,15 +5695,19 @@ var DelopayInternal = class extends Delopay {
5419
5695
  decodeBadges,
5420
5696
  decodeBranding,
5421
5697
  decodeCustomFields,
5698
+ decodeNativePanes,
5422
5699
  defaultBranding,
5423
5700
  defaultCustomFieldVisibility,
5701
+ defaultNativePane,
5424
5702
  defaultOperatorForSource,
5425
5703
  encodeBadges,
5426
5704
  encodeBranding,
5427
5705
  encodeCustomFields,
5706
+ encodeNativePanes,
5428
5707
  evaluateCustomFieldCondition,
5429
5708
  evaluateCustomFieldVisibility,
5430
5709
  feeProgram,
5710
+ focusedCheckoutUrl,
5431
5711
  fontStack,
5432
5712
  fontWeightValue,
5433
5713
  inputPadValue,
@@ -5436,6 +5716,7 @@ var DelopayInternal = class extends Delopay {
5436
5716
  isHexColor,
5437
5717
  leaf,
5438
5718
  logoDimensions,
5719
+ nativePaneMethodInfo,
5439
5720
  parseCustomFieldsLoose,
5440
5721
  parseImportedBranding,
5441
5722
  programToTree,