@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.
@@ -2384,6 +2384,23 @@ var Routing = class {
2384
2384
  async connectorCaps(profileId) {
2385
2385
  return this.request("GET", `/routing/connector-caps/${encodeURIComponent(profileId)}`);
2386
2386
  }
2387
+ /**
2388
+ * The live `routing_volume` counters behind a shop's active advanced
2389
+ * program: one per distinct budget the program reads, each with the window
2390
+ * it covers, the figure in the pinned threshold currency, and the rules that
2391
+ * read it. Lets a merchant see whether a `routing_volume < 50000` rule is at
2392
+ * 120 or at 499 today, and support answer why a payment went to the overflow
2393
+ * connector.
2394
+ *
2395
+ * What routing will use right now, not what the shop turned over: the
2396
+ * counters are held in Redis only and a lost Redis restarts the window at
2397
+ * zero. Read-only; needs the same permission as reading the rules.
2398
+ *
2399
+ * `GET /routing/volume-counters/{profileId}`
2400
+ */
2401
+ async volumeCounters(profileId) {
2402
+ return this.request("GET", `/routing/volume-counters/${encodeURIComponent(profileId)}`);
2403
+ }
2387
2404
  /**
2388
2405
  * Replace a shop's per-connector payment caps.
2389
2406
  *
@@ -5448,6 +5465,151 @@ var DEFAULT_BADGES_DARK = [
5448
5465
  borderColor: "#1e40af"
5449
5466
  }
5450
5467
  ];
5468
+ var METHOD_SECTION_ORDER_KEY = "methodSectionOrder";
5469
+ var METHOD_SECTION_LABELS_KEY = "methodSectionLabels";
5470
+ var MIN_SECTION_ORDER = 1;
5471
+ var MAX_SECTION_ORDER = 100;
5472
+ var MAX_SECTION_LABEL_LENGTH = 120;
5473
+ var METHOD_SECTIONS = [
5474
+ { id: "card", labelKey: "sections.card", order: 10 },
5475
+ { id: "wallet", labelKey: "sections.wallets", order: 20 },
5476
+ { id: "bnpl", labelKey: "sections.bnpl", order: 30 },
5477
+ { id: "bank_redirect", labelKey: "sections.onlineBanking", order: 40 },
5478
+ { id: "bank_transfer", labelKey: "sections.bankTransfer", order: 45 },
5479
+ { id: "crypto", labelKey: "sections.cryptocurrency", order: 50 },
5480
+ { id: "game_items", labelKey: "sections.gameItems", order: 60 },
5481
+ { id: "voucher", labelKey: "sections.vouchers", order: 70 },
5482
+ { id: "gift_card", labelKey: "sections.giftCards", order: 75 },
5483
+ { id: "reward", labelKey: "sections.rewards", order: 80 },
5484
+ { id: "cash", labelKey: "sections.cash", order: 90 }
5485
+ ];
5486
+ var SECTION_ALIASES = {
5487
+ card_redirect: "card"
5488
+ };
5489
+ var UNKNOWN_SECTION_ORDER = MAX_SECTION_ORDER;
5490
+ function canonicalSectionId(category) {
5491
+ return SECTION_ALIASES[category] ?? category;
5492
+ }
5493
+ function defaultMethodSectionOrder() {
5494
+ const order = {};
5495
+ for (const section of METHOD_SECTIONS) order[section.id] = section.order;
5496
+ return order;
5497
+ }
5498
+ function validSectionOrder(raw) {
5499
+ if (typeof raw !== "number" || !Number.isInteger(raw)) return null;
5500
+ if (raw < MIN_SECTION_ORDER || raw > MAX_SECTION_ORDER) return null;
5501
+ return raw;
5502
+ }
5503
+ function decodeMethodSectionOrder(raw) {
5504
+ const order = defaultMethodSectionOrder();
5505
+ if (raw === void 0) return order;
5506
+ let parsed;
5507
+ try {
5508
+ parsed = JSON.parse(raw);
5509
+ } catch {
5510
+ return order;
5511
+ }
5512
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return order;
5513
+ for (const [key, value] of Object.entries(parsed)) {
5514
+ const valid = validSectionOrder(value);
5515
+ if (valid === null) continue;
5516
+ order[canonicalSectionId(key)] = valid;
5517
+ }
5518
+ return order;
5519
+ }
5520
+ function encodeMethodSectionOrder(order) {
5521
+ return JSON.stringify(order);
5522
+ }
5523
+ function decodeMethodSectionLabels(raw) {
5524
+ if (raw === void 0) return {};
5525
+ let parsed;
5526
+ try {
5527
+ parsed = JSON.parse(raw);
5528
+ } catch {
5529
+ return {};
5530
+ }
5531
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return {};
5532
+ const labels = {};
5533
+ for (const [section, byLocale] of Object.entries(parsed)) {
5534
+ if (!section || byLocale === null || typeof byLocale !== "object" || Array.isArray(byLocale)) {
5535
+ continue;
5536
+ }
5537
+ const kept = {};
5538
+ for (const [locale, text] of Object.entries(byLocale)) {
5539
+ if (typeof text !== "string") continue;
5540
+ const trimmed = text.trim();
5541
+ if (!trimmed) continue;
5542
+ kept[locale] = trimmed.slice(0, MAX_SECTION_LABEL_LENGTH);
5543
+ }
5544
+ if (Object.keys(kept).length > 0) labels[canonicalSectionId(section)] = kept;
5545
+ }
5546
+ return labels;
5547
+ }
5548
+ function encodeMethodSectionLabels(labels) {
5549
+ const cleaned = {};
5550
+ for (const [section, byLocale] of Object.entries(labels)) {
5551
+ const kept = {};
5552
+ for (const [locale, text] of Object.entries(byLocale)) {
5553
+ const trimmed = (text ?? "").trim();
5554
+ if (trimmed) kept[locale] = trimmed.slice(0, MAX_SECTION_LABEL_LENGTH);
5555
+ }
5556
+ if (Object.keys(kept).length > 0) cleaned[section] = kept;
5557
+ }
5558
+ return Object.keys(cleaned).length > 0 ? JSON.stringify(cleaned) : null;
5559
+ }
5560
+ function sectionCatalogueIndex(sectionId) {
5561
+ const index = METHOD_SECTIONS.findIndex((section) => section.id === sectionId);
5562
+ return index === -1 ? METHOD_SECTIONS.length : index;
5563
+ }
5564
+ function sectionOrderOf(order, category) {
5565
+ return order[canonicalSectionId(category)] ?? UNKNOWN_SECTION_ORDER;
5566
+ }
5567
+ function compareSections(order) {
5568
+ return (a, b) => {
5569
+ const left = canonicalSectionId(a);
5570
+ const right = canonicalSectionId(b);
5571
+ const byOrder = sectionOrderOf(order, left) - sectionOrderOf(order, right);
5572
+ if (byOrder !== 0) return byOrder;
5573
+ const byCatalogue = sectionCatalogueIndex(left) - sectionCatalogueIndex(right);
5574
+ if (byCatalogue !== 0) return byCatalogue;
5575
+ return left < right ? -1 : left > right ? 1 : 0;
5576
+ };
5577
+ }
5578
+ function sectionLabel(labels, category, locale, knownKey, translate) {
5579
+ const id = canonicalSectionId(category);
5580
+ if (id in labels) {
5581
+ const captions = labels[id];
5582
+ const matched = translationFor(captions, locale)?.trim();
5583
+ if (matched) return matched;
5584
+ for (const value of Object.values(captions)) {
5585
+ const any = value.trim();
5586
+ if (any) return any;
5587
+ }
5588
+ }
5589
+ if (knownKey) {
5590
+ const translated = translate(knownKey);
5591
+ if (translated) return translated;
5592
+ }
5593
+ return category;
5594
+ }
5595
+ function parseSectionOrderLoose(raw) {
5596
+ if (typeof raw === "string") return decodeMethodSectionOrder(raw);
5597
+ if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
5598
+ return decodeMethodSectionOrder(JSON.stringify(raw));
5599
+ }
5600
+ return defaultMethodSectionOrder();
5601
+ }
5602
+ function parseSectionLabelsLoose(raw) {
5603
+ if (typeof raw === "string") return decodeMethodSectionLabels(raw);
5604
+ if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
5605
+ return decodeMethodSectionLabels(JSON.stringify(raw));
5606
+ }
5607
+ return {};
5608
+ }
5609
+ function knownSectionLabelKey(category) {
5610
+ const id = canonicalSectionId(category);
5611
+ return METHOD_SECTIONS.find((section) => section.id === id)?.labelKey;
5612
+ }
5451
5613
  var DEFAULT_BRANDING_BASE = {
5452
5614
  displayName: "",
5453
5615
  logoUrl: "",
@@ -5536,7 +5698,9 @@ var DEFAULT_BRANDING = {
5536
5698
  ...DEFAULT_BRANDING_BASE,
5537
5699
  ...LIGHT_PALETTE,
5538
5700
  trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
5539
- customFields: []
5701
+ customFields: [],
5702
+ methodSectionOrder: defaultMethodSectionOrder(),
5703
+ methodSectionLabels: {}
5540
5704
  };
5541
5705
  var DEFAULT_BRANDING_DARK = {
5542
5706
  ...DEFAULT_BRANDING_BASE,
@@ -5557,7 +5721,9 @@ var DEFAULT_BRANDING_DARK = {
5557
5721
  surchargeColor: "#fbbf24",
5558
5722
  discountColor: "#34d399",
5559
5723
  trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
5560
- customFields: []
5724
+ customFields: [],
5725
+ methodSectionOrder: defaultMethodSectionOrder(),
5726
+ methodSectionLabels: {}
5561
5727
  };
5562
5728
  function defaultBranding() {
5563
5729
  return cloneBranding(DEFAULT_BRANDING);
@@ -5567,6 +5733,10 @@ function cloneBranding(b) {
5567
5733
  ...b,
5568
5734
  trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
5569
5735
  customFields: b.customFields.map(cloneCustomField),
5736
+ methodSectionOrder: { ...b.methodSectionOrder },
5737
+ methodSectionLabels: Object.fromEntries(
5738
+ Object.entries(b.methodSectionLabels).map(([id, byLocale]) => [id, { ...byLocale }])
5739
+ ),
5570
5740
  // Copied, not shared. A spread alone would leave the clone pointing at the
5571
5741
  // original's maps, and the dashboard edits a clone precisely so the form
5572
5742
  // can be abandoned without touching what is saved.
@@ -6182,6 +6352,8 @@ function decodeBranding(source) {
6182
6352
  showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
6183
6353
  trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
6184
6354
  customFields: decodedCustomFields ?? [],
6355
+ methodSectionOrder: decodeMethodSectionOrder(extras[METHOD_SECTION_ORDER_KEY]),
6356
+ methodSectionLabels: decodeMethodSectionLabels(extras[METHOD_SECTION_LABELS_KEY]),
6185
6357
  headerText: s(source.payment_form_header_text),
6186
6358
  payButtonLabel: s(source.payment_button_text),
6187
6359
  cardTermsMessage: s(source.custom_message_for_card_terms),
@@ -6248,8 +6420,11 @@ function encodeBranding(branding, base) {
6248
6420
  logoShape: branding.logoShape,
6249
6421
  logoSize: branding.logoSize,
6250
6422
  labelStyle: branding.labelStyle,
6251
- trustBadges: encodeBadges(branding.trustBadges)
6423
+ trustBadges: encodeBadges(branding.trustBadges),
6424
+ [METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
6252
6425
  };
6426
+ const sectionLabels = encodeMethodSectionLabels(branding.methodSectionLabels);
6427
+ if (sectionLabels) extras[METHOD_SECTION_LABELS_KEY] = sectionLabels;
6253
6428
  if (branding.customFields.length > 0) {
6254
6429
  extras["customFields"] = encodeCustomFields(branding.customFields);
6255
6430
  }
@@ -6451,6 +6626,10 @@ function parseImportedBranding(raw) {
6451
6626
  showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
6452
6627
  trustBadges,
6453
6628
  customFields,
6629
+ // An export writes the decoded maps; a hand-written file may carry the
6630
+ // JSON strings the bag uses. Both are accepted, and neither is required.
6631
+ methodSectionOrder: parseSectionOrderLoose(root[METHOD_SECTION_ORDER_KEY]),
6632
+ methodSectionLabels: parseSectionLabelsLoose(root[METHOD_SECTION_LABELS_KEY]),
6454
6633
  headerText: sStr(root["headerText"], dflt.headerText),
6455
6634
  payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
6456
6635
  cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
@@ -7316,6 +7495,23 @@ export {
7316
7495
  isDarkSurface,
7317
7496
  DEFAULT_BADGES,
7318
7497
  DEFAULT_BADGES_DARK,
7498
+ MIN_SECTION_ORDER,
7499
+ MAX_SECTION_ORDER,
7500
+ MAX_SECTION_LABEL_LENGTH,
7501
+ METHOD_SECTIONS,
7502
+ SECTION_ALIASES,
7503
+ UNKNOWN_SECTION_ORDER,
7504
+ canonicalSectionId,
7505
+ defaultMethodSectionOrder,
7506
+ validSectionOrder,
7507
+ decodeMethodSectionOrder,
7508
+ encodeMethodSectionOrder,
7509
+ decodeMethodSectionLabels,
7510
+ encodeMethodSectionLabels,
7511
+ sectionOrderOf,
7512
+ compareSections,
7513
+ sectionLabel,
7514
+ knownSectionLabelKey,
7319
7515
  DEFAULT_BRANDING,
7320
7516
  DEFAULT_BRANDING_DARK,
7321
7517
  defaultBranding,
@@ -7387,4 +7583,4 @@ export {
7387
7583
  decodeNativePanes,
7388
7584
  encodeNativePanes
7389
7585
  };
7390
- //# sourceMappingURL=chunk-4TVKPQTZ.js.map
7586
+ //# sourceMappingURL=chunk-D44FJRXS.js.map