@delopay/sdk 0.124.0 → 0.126.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
@@ -54,6 +54,10 @@ __export(index_exports, {
54
54
  Files: () => Files,
55
55
  Forex: () => Forex,
56
56
  LOCALIZABLE_COPY_FIELDS: () => LOCALIZABLE_COPY_FIELDS,
57
+ MAX_SECTION_LABEL_LENGTH: () => MAX_SECTION_LABEL_LENGTH,
58
+ MAX_SECTION_ORDER: () => MAX_SECTION_ORDER,
59
+ METHOD_SECTIONS: () => METHOD_SECTIONS,
60
+ MIN_SECTION_ORDER: () => MIN_SECTION_ORDER,
57
61
  NATIVE_PANES_MAX: () => NATIVE_PANES_MAX,
58
62
  NATIVE_PANE_CATEGORY_KEYS: () => NATIVE_PANE_CATEGORY_KEYS,
59
63
  NATIVE_PANE_ICON_KEYS: () => NATIVE_PANE_ICON_KEYS,
@@ -64,6 +68,7 @@ __export(index_exports, {
64
68
  RTL_CHECKOUT_LOCALES: () => RTL_CHECKOUT_LOCALES,
65
69
  Regions: () => Regions,
66
70
  Risk: () => Risk,
71
+ SECTION_ALIASES: () => SECTION_ALIASES,
67
72
  STRIPE_FALLBACK_PANE_CATALOG: () => STRIPE_FALLBACK_PANE_CATALOG,
68
73
  STRIPE_FALLBACK_PANE_METHODS: () => STRIPE_FALLBACK_PANE_METHODS,
69
74
  STRIPE_NATIVE_PANE_METHODS: () => STRIPE_NATIVE_PANE_METHODS,
@@ -80,6 +85,7 @@ __export(index_exports, {
80
85
  Search: () => Search,
81
86
  Settlement: () => Settlement,
82
87
  Subscriptions: () => Subscriptions,
88
+ UNKNOWN_SECTION_ORDER: () => UNKNOWN_SECTION_ORDER,
83
89
  WCAG_AA_TEXT: () => WCAG_AA_TEXT,
84
90
  WCAG_AA_UI: () => WCAG_AA_UI,
85
91
  Webhooks: () => Webhooks,
@@ -88,12 +94,14 @@ __export(index_exports, {
88
94
  applyBrandingVariables: () => applyBrandingVariables,
89
95
  buildBrandingExport: () => buildBrandingExport,
90
96
  buttonPadValue: () => buttonPadValue,
97
+ canonicalSectionId: () => canonicalSectionId,
91
98
  checkoutCopy: () => checkoutCopy,
92
99
  checkoutLocaleDir: () => checkoutLocaleDir,
93
100
  cloneBranding: () => cloneBranding,
94
101
  cloneCustomField: () => cloneCustomField,
95
102
  cloneNativePane: () => cloneNativePane,
96
103
  clonePane: () => clonePane,
104
+ compareSections: () => compareSections,
97
105
  contrastRatio: () => contrastRatio,
98
106
  copyTranslationsKey: () => copyTranslationsKey,
99
107
  customFieldContextFromMetadata: () => customFieldContextFromMetadata,
@@ -104,10 +112,13 @@ __export(index_exports, {
104
112
  decodeBadges: () => decodeBadges,
105
113
  decodeBranding: () => decodeBranding,
106
114
  decodeCustomFields: () => decodeCustomFields,
115
+ decodeMethodSectionLabels: () => decodeMethodSectionLabels,
116
+ decodeMethodSectionOrder: () => decodeMethodSectionOrder,
107
117
  decodeNativePanes: () => decodeNativePanes,
108
118
  decodePanes: () => decodePanes,
109
119
  defaultBranding: () => defaultBranding,
110
120
  defaultCustomFieldVisibility: () => defaultCustomFieldVisibility,
121
+ defaultMethodSectionOrder: () => defaultMethodSectionOrder,
111
122
  defaultNativePane: () => defaultNativePane,
112
123
  defaultOperatorForSource: () => defaultOperatorForSource,
113
124
  defaultPane: () => defaultPane,
@@ -115,6 +126,8 @@ __export(index_exports, {
115
126
  encodeBadges: () => encodeBadges,
116
127
  encodeBranding: () => encodeBranding,
117
128
  encodeCustomFields: () => encodeCustomFields,
129
+ encodeMethodSectionLabels: () => encodeMethodSectionLabels,
130
+ encodeMethodSectionOrder: () => encodeMethodSectionOrder,
118
131
  encodeNativePanes: () => encodeNativePanes,
119
132
  encodePanes: () => encodePanes,
120
133
  evaluateCustomFieldCondition: () => evaluateCustomFieldCondition,
@@ -127,6 +140,7 @@ __export(index_exports, {
127
140
  isCheckboxChecked: () => isCheckboxChecked,
128
141
  isDarkSurface: () => isDarkSurface,
129
142
  isHexColor: () => isHexColor,
143
+ knownSectionLabelKey: () => knownSectionLabelKey,
130
144
  leaf: () => leaf,
131
145
  logoDimensions: () => logoDimensions,
132
146
  nativePaneMethodInfo: () => nativePaneMethodInfo,
@@ -143,12 +157,15 @@ __export(index_exports, {
143
157
  readableInkOn: () => readableInkOn,
144
158
  ruleMatchToTree: () => ruleMatchToTree,
145
159
  sanitizeCustomCss: () => sanitizeCustomCss,
160
+ sectionLabel: () => sectionLabel,
161
+ sectionOrderOf: () => sectionOrderOf,
146
162
  shadowFor: () => shadowFor,
147
163
  surchargeFigurePlan: () => surchargeFigurePlan,
148
164
  surchargeShowsLabel: () => surchargeShowsLabel,
149
165
  surchargeStyleDrawsAShape: () => surchargeStyleDrawsAShape,
150
166
  surchargeWordFor: () => surchargeWordFor,
151
167
  surfacePadValue: () => surfacePadValue,
168
+ validSectionOrder: () => validSectionOrder,
152
169
  validatePanes: () => validatePanes,
153
170
  verticalGapValue: () => verticalGapValue,
154
171
  visibleCustomFields: () => visibleCustomFields
@@ -2541,6 +2558,23 @@ var Routing = class {
2541
2558
  async connectorCaps(profileId) {
2542
2559
  return this.request("GET", `/routing/connector-caps/${encodeURIComponent(profileId)}`);
2543
2560
  }
2561
+ /**
2562
+ * The live `routing_volume` counters behind a shop's active advanced
2563
+ * program: one per distinct budget the program reads, each with the window
2564
+ * it covers, the figure in the pinned threshold currency, and the rules that
2565
+ * read it. Lets a merchant see whether a `routing_volume < 50000` rule is at
2566
+ * 120 or at 499 today, and support answer why a payment went to the overflow
2567
+ * connector.
2568
+ *
2569
+ * What routing will use right now, not what the shop turned over: the
2570
+ * counters are held in Redis only and a lost Redis restarts the window at
2571
+ * zero. Read-only; needs the same permission as reading the rules.
2572
+ *
2573
+ * `GET /routing/volume-counters/{profileId}`
2574
+ */
2575
+ async volumeCounters(profileId) {
2576
+ return this.request("GET", `/routing/volume-counters/${encodeURIComponent(profileId)}`);
2577
+ }
2544
2578
  /**
2545
2579
  * Replace a shop's per-connector payment caps.
2546
2580
  *
@@ -5605,6 +5639,151 @@ var DEFAULT_BADGES_DARK = [
5605
5639
  borderColor: "#1e40af"
5606
5640
  }
5607
5641
  ];
5642
+ var METHOD_SECTION_ORDER_KEY = "methodSectionOrder";
5643
+ var METHOD_SECTION_LABELS_KEY = "methodSectionLabels";
5644
+ var MIN_SECTION_ORDER = 1;
5645
+ var MAX_SECTION_ORDER = 100;
5646
+ var MAX_SECTION_LABEL_LENGTH = 120;
5647
+ var METHOD_SECTIONS = [
5648
+ { id: "card", labelKey: "sections.card", order: 10 },
5649
+ { id: "wallet", labelKey: "sections.wallets", order: 20 },
5650
+ { id: "bnpl", labelKey: "sections.bnpl", order: 30 },
5651
+ { id: "bank_redirect", labelKey: "sections.onlineBanking", order: 40 },
5652
+ { id: "bank_transfer", labelKey: "sections.bankTransfer", order: 45 },
5653
+ { id: "crypto", labelKey: "sections.cryptocurrency", order: 50 },
5654
+ { id: "game_items", labelKey: "sections.gameItems", order: 60 },
5655
+ { id: "voucher", labelKey: "sections.vouchers", order: 70 },
5656
+ { id: "gift_card", labelKey: "sections.giftCards", order: 75 },
5657
+ { id: "reward", labelKey: "sections.rewards", order: 80 },
5658
+ { id: "cash", labelKey: "sections.cash", order: 90 }
5659
+ ];
5660
+ var SECTION_ALIASES = {
5661
+ card_redirect: "card"
5662
+ };
5663
+ var UNKNOWN_SECTION_ORDER = MAX_SECTION_ORDER;
5664
+ function canonicalSectionId(category) {
5665
+ return SECTION_ALIASES[category] ?? category;
5666
+ }
5667
+ function defaultMethodSectionOrder() {
5668
+ const order = {};
5669
+ for (const section of METHOD_SECTIONS) order[section.id] = section.order;
5670
+ return order;
5671
+ }
5672
+ function validSectionOrder(raw) {
5673
+ if (typeof raw !== "number" || !Number.isInteger(raw)) return null;
5674
+ if (raw < MIN_SECTION_ORDER || raw > MAX_SECTION_ORDER) return null;
5675
+ return raw;
5676
+ }
5677
+ function decodeMethodSectionOrder(raw) {
5678
+ const order = defaultMethodSectionOrder();
5679
+ if (raw === void 0) return order;
5680
+ let parsed;
5681
+ try {
5682
+ parsed = JSON.parse(raw);
5683
+ } catch {
5684
+ return order;
5685
+ }
5686
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return order;
5687
+ for (const [key, value] of Object.entries(parsed)) {
5688
+ const valid = validSectionOrder(value);
5689
+ if (valid === null) continue;
5690
+ order[canonicalSectionId(key)] = valid;
5691
+ }
5692
+ return order;
5693
+ }
5694
+ function encodeMethodSectionOrder(order) {
5695
+ return JSON.stringify(order);
5696
+ }
5697
+ function decodeMethodSectionLabels(raw) {
5698
+ if (raw === void 0) return {};
5699
+ let parsed;
5700
+ try {
5701
+ parsed = JSON.parse(raw);
5702
+ } catch {
5703
+ return {};
5704
+ }
5705
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {};
5706
+ const labels = {};
5707
+ for (const [section, byLocale] of Object.entries(parsed)) {
5708
+ if (!section || byLocale === null || typeof byLocale !== "object" || Array.isArray(byLocale)) {
5709
+ continue;
5710
+ }
5711
+ const kept = {};
5712
+ for (const [locale, text] of Object.entries(byLocale)) {
5713
+ if (typeof text !== "string") continue;
5714
+ const trimmed = text.trim();
5715
+ if (!trimmed) continue;
5716
+ kept[locale] = trimmed.slice(0, MAX_SECTION_LABEL_LENGTH);
5717
+ }
5718
+ if (Object.keys(kept).length > 0) labels[canonicalSectionId(section)] = kept;
5719
+ }
5720
+ return labels;
5721
+ }
5722
+ function encodeMethodSectionLabels(labels) {
5723
+ const cleaned = {};
5724
+ for (const [section, byLocale] of Object.entries(labels)) {
5725
+ const kept = {};
5726
+ for (const [locale, text] of Object.entries(byLocale)) {
5727
+ const trimmed = (text ?? "").trim();
5728
+ if (trimmed) kept[locale] = trimmed.slice(0, MAX_SECTION_LABEL_LENGTH);
5729
+ }
5730
+ if (Object.keys(kept).length > 0) cleaned[section] = kept;
5731
+ }
5732
+ return Object.keys(cleaned).length > 0 ? JSON.stringify(cleaned) : null;
5733
+ }
5734
+ function sectionCatalogueIndex(sectionId) {
5735
+ const index = METHOD_SECTIONS.findIndex((section) => section.id === sectionId);
5736
+ return index === -1 ? METHOD_SECTIONS.length : index;
5737
+ }
5738
+ function sectionOrderOf(order, category) {
5739
+ return order[canonicalSectionId(category)] ?? UNKNOWN_SECTION_ORDER;
5740
+ }
5741
+ function compareSections(order) {
5742
+ return (a, b) => {
5743
+ const left = canonicalSectionId(a);
5744
+ const right = canonicalSectionId(b);
5745
+ const byOrder = sectionOrderOf(order, left) - sectionOrderOf(order, right);
5746
+ if (byOrder !== 0) return byOrder;
5747
+ const byCatalogue = sectionCatalogueIndex(left) - sectionCatalogueIndex(right);
5748
+ if (byCatalogue !== 0) return byCatalogue;
5749
+ return left < right ? -1 : left > right ? 1 : 0;
5750
+ };
5751
+ }
5752
+ function sectionLabel(labels, category, locale, knownKey, translate) {
5753
+ const id = canonicalSectionId(category);
5754
+ if (id in labels) {
5755
+ const captions = labels[id];
5756
+ const matched = translationFor(captions, locale)?.trim();
5757
+ if (matched) return matched;
5758
+ for (const value of Object.values(captions)) {
5759
+ const any = value.trim();
5760
+ if (any) return any;
5761
+ }
5762
+ }
5763
+ if (knownKey) {
5764
+ const translated = translate(knownKey);
5765
+ if (translated) return translated;
5766
+ }
5767
+ return category;
5768
+ }
5769
+ function parseSectionOrderLoose(raw) {
5770
+ if (typeof raw === "string") return decodeMethodSectionOrder(raw);
5771
+ if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
5772
+ return decodeMethodSectionOrder(JSON.stringify(raw));
5773
+ }
5774
+ return defaultMethodSectionOrder();
5775
+ }
5776
+ function parseSectionLabelsLoose(raw) {
5777
+ if (typeof raw === "string") return decodeMethodSectionLabels(raw);
5778
+ if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
5779
+ return decodeMethodSectionLabels(JSON.stringify(raw));
5780
+ }
5781
+ return {};
5782
+ }
5783
+ function knownSectionLabelKey(category) {
5784
+ const id = canonicalSectionId(category);
5785
+ return METHOD_SECTIONS.find((section) => section.id === id)?.labelKey;
5786
+ }
5608
5787
  var DEFAULT_BRANDING_BASE = {
5609
5788
  displayName: "",
5610
5789
  logoUrl: "",
@@ -5693,7 +5872,9 @@ var DEFAULT_BRANDING = {
5693
5872
  ...DEFAULT_BRANDING_BASE,
5694
5873
  ...LIGHT_PALETTE,
5695
5874
  trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
5696
- customFields: []
5875
+ customFields: [],
5876
+ methodSectionOrder: defaultMethodSectionOrder(),
5877
+ methodSectionLabels: {}
5697
5878
  };
5698
5879
  var DEFAULT_BRANDING_DARK = {
5699
5880
  ...DEFAULT_BRANDING_BASE,
@@ -5714,7 +5895,9 @@ var DEFAULT_BRANDING_DARK = {
5714
5895
  surchargeColor: "#fbbf24",
5715
5896
  discountColor: "#34d399",
5716
5897
  trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
5717
- customFields: []
5898
+ customFields: [],
5899
+ methodSectionOrder: defaultMethodSectionOrder(),
5900
+ methodSectionLabels: {}
5718
5901
  };
5719
5902
  function defaultBranding() {
5720
5903
  return cloneBranding(DEFAULT_BRANDING);
@@ -5724,6 +5907,10 @@ function cloneBranding(b) {
5724
5907
  ...b,
5725
5908
  trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
5726
5909
  customFields: b.customFields.map(cloneCustomField),
5910
+ methodSectionOrder: { ...b.methodSectionOrder },
5911
+ methodSectionLabels: Object.fromEntries(
5912
+ Object.entries(b.methodSectionLabels).map(([id, byLocale]) => [id, { ...byLocale }])
5913
+ ),
5727
5914
  // Copied, not shared. A spread alone would leave the clone pointing at the
5728
5915
  // original's maps, and the dashboard edits a clone precisely so the form
5729
5916
  // can be abandoned without touching what is saved.
@@ -6339,6 +6526,8 @@ function decodeBranding(source) {
6339
6526
  showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
6340
6527
  trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
6341
6528
  customFields: decodedCustomFields ?? [],
6529
+ methodSectionOrder: decodeMethodSectionOrder(extras[METHOD_SECTION_ORDER_KEY]),
6530
+ methodSectionLabels: decodeMethodSectionLabels(extras[METHOD_SECTION_LABELS_KEY]),
6342
6531
  headerText: s(source.payment_form_header_text),
6343
6532
  payButtonLabel: s(source.payment_button_text),
6344
6533
  cardTermsMessage: s(source.custom_message_for_card_terms),
@@ -6405,8 +6594,11 @@ function encodeBranding(branding, base) {
6405
6594
  logoShape: branding.logoShape,
6406
6595
  logoSize: branding.logoSize,
6407
6596
  labelStyle: branding.labelStyle,
6408
- trustBadges: encodeBadges(branding.trustBadges)
6597
+ trustBadges: encodeBadges(branding.trustBadges),
6598
+ [METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
6409
6599
  };
6600
+ const sectionLabels = encodeMethodSectionLabels(branding.methodSectionLabels);
6601
+ if (sectionLabels) extras[METHOD_SECTION_LABELS_KEY] = sectionLabels;
6410
6602
  if (branding.customFields.length > 0) {
6411
6603
  extras["customFields"] = encodeCustomFields(branding.customFields);
6412
6604
  }
@@ -6608,6 +6800,10 @@ function parseImportedBranding(raw) {
6608
6800
  showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
6609
6801
  trustBadges,
6610
6802
  customFields,
6803
+ // An export writes the decoded maps; a hand-written file may carry the
6804
+ // JSON strings the bag uses. Both are accepted, and neither is required.
6805
+ methodSectionOrder: parseSectionOrderLoose(root[METHOD_SECTION_ORDER_KEY]),
6806
+ methodSectionLabels: parseSectionLabelsLoose(root[METHOD_SECTION_LABELS_KEY]),
6611
6807
  headerText: sStr(root["headerText"], dflt.headerText),
6612
6808
  payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
6613
6809
  cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
@@ -7445,6 +7641,10 @@ var encodeNativePanes = encodePanes;
7445
7641
  Files,
7446
7642
  Forex,
7447
7643
  LOCALIZABLE_COPY_FIELDS,
7644
+ MAX_SECTION_LABEL_LENGTH,
7645
+ MAX_SECTION_ORDER,
7646
+ METHOD_SECTIONS,
7647
+ MIN_SECTION_ORDER,
7448
7648
  NATIVE_PANES_MAX,
7449
7649
  NATIVE_PANE_CATEGORY_KEYS,
7450
7650
  NATIVE_PANE_ICON_KEYS,
@@ -7455,6 +7655,7 @@ var encodeNativePanes = encodePanes;
7455
7655
  RTL_CHECKOUT_LOCALES,
7456
7656
  Regions,
7457
7657
  Risk,
7658
+ SECTION_ALIASES,
7458
7659
  STRIPE_FALLBACK_PANE_CATALOG,
7459
7660
  STRIPE_FALLBACK_PANE_METHODS,
7460
7661
  STRIPE_NATIVE_PANE_METHODS,
@@ -7471,6 +7672,7 @@ var encodeNativePanes = encodePanes;
7471
7672
  Search,
7472
7673
  Settlement,
7473
7674
  Subscriptions,
7675
+ UNKNOWN_SECTION_ORDER,
7474
7676
  WCAG_AA_TEXT,
7475
7677
  WCAG_AA_UI,
7476
7678
  Webhooks,
@@ -7479,12 +7681,14 @@ var encodeNativePanes = encodePanes;
7479
7681
  applyBrandingVariables,
7480
7682
  buildBrandingExport,
7481
7683
  buttonPadValue,
7684
+ canonicalSectionId,
7482
7685
  checkoutCopy,
7483
7686
  checkoutLocaleDir,
7484
7687
  cloneBranding,
7485
7688
  cloneCustomField,
7486
7689
  cloneNativePane,
7487
7690
  clonePane,
7691
+ compareSections,
7488
7692
  contrastRatio,
7489
7693
  copyTranslationsKey,
7490
7694
  customFieldContextFromMetadata,
@@ -7495,10 +7699,13 @@ var encodeNativePanes = encodePanes;
7495
7699
  decodeBadges,
7496
7700
  decodeBranding,
7497
7701
  decodeCustomFields,
7702
+ decodeMethodSectionLabels,
7703
+ decodeMethodSectionOrder,
7498
7704
  decodeNativePanes,
7499
7705
  decodePanes,
7500
7706
  defaultBranding,
7501
7707
  defaultCustomFieldVisibility,
7708
+ defaultMethodSectionOrder,
7502
7709
  defaultNativePane,
7503
7710
  defaultOperatorForSource,
7504
7711
  defaultPane,
@@ -7506,6 +7713,8 @@ var encodeNativePanes = encodePanes;
7506
7713
  encodeBadges,
7507
7714
  encodeBranding,
7508
7715
  encodeCustomFields,
7716
+ encodeMethodSectionLabels,
7717
+ encodeMethodSectionOrder,
7509
7718
  encodeNativePanes,
7510
7719
  encodePanes,
7511
7720
  evaluateCustomFieldCondition,
@@ -7518,6 +7727,7 @@ var encodeNativePanes = encodePanes;
7518
7727
  isCheckboxChecked,
7519
7728
  isDarkSurface,
7520
7729
  isHexColor,
7730
+ knownSectionLabelKey,
7521
7731
  leaf,
7522
7732
  logoDimensions,
7523
7733
  nativePaneMethodInfo,
@@ -7534,12 +7744,15 @@ var encodeNativePanes = encodePanes;
7534
7744
  readableInkOn,
7535
7745
  ruleMatchToTree,
7536
7746
  sanitizeCustomCss,
7747
+ sectionLabel,
7748
+ sectionOrderOf,
7537
7749
  shadowFor,
7538
7750
  surchargeFigurePlan,
7539
7751
  surchargeShowsLabel,
7540
7752
  surchargeStyleDrawsAShape,
7541
7753
  surchargeWordFor,
7542
7754
  surfacePadValue,
7755
+ validSectionOrder,
7543
7756
  validatePanes,
7544
7757
  verticalGapValue,
7545
7758
  visibleCustomFields