@delopay/sdk 0.163.0 → 0.165.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/{chunk-Y6TADN6R.js → chunk-CP5M5WR6.js} +340 -7
- package/dist/chunk-CP5M5WR6.js.map +1 -0
- package/dist/index.cjs +357 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +427 -1
- package/dist/index.d.ts +427 -1
- package/dist/index.js +37 -1
- package/dist/internal.cjs +357 -6
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +37 -1
- package/dist/internal.js.map +1 -1
- package/package.json +17 -18
- package/dist/chunk-Y6TADN6R.js.map +0 -1
|
@@ -1763,6 +1763,16 @@ var Payments = class {
|
|
|
1763
1763
|
* Not the hosted-shop settlement API under `settlement.*`, which is host →
|
|
1764
1764
|
* shop owner and manual; this is acquirer → merchant bank, per payment.
|
|
1765
1765
|
*
|
|
1766
|
+
* Each attempt also carries what the rail itself took for it —
|
|
1767
|
+
* `processor_cost_amount` with its own `processor_cost_currency` and
|
|
1768
|
+
* `processor_cost_exponent`, the `processor_cost_source` that says how the
|
|
1769
|
+
* figure was obtained, the `processor_cost_basis` behind an estimate, and
|
|
1770
|
+
* the `connector_method_code` it was priced under. Recorded for **every**
|
|
1771
|
+
* merchant, not only those that host shops. Never present an `estimated`
|
|
1772
|
+
* cost as an observation, and read an absent `processor_cost_source` as
|
|
1773
|
+
* "nothing was ever written", which is not the `unavailable` the rail
|
|
1774
|
+
* answers with.
|
|
1775
|
+
*
|
|
1766
1776
|
* `GET /payments/{paymentId}/settlement`
|
|
1767
1777
|
*
|
|
1768
1778
|
* @param paymentId - The payment intent ID.
|
|
@@ -1781,6 +1791,9 @@ var Payments = class {
|
|
|
1781
1791
|
* if (attempt.status === 'paid_out') {
|
|
1782
1792
|
* console.log(attempt.paid_out_at, attempt.payout_reference);
|
|
1783
1793
|
* }
|
|
1794
|
+
* if (attempt.processor_cost_source === 'estimated') {
|
|
1795
|
+
* // Label it an estimate — it was derived from a cost schedule.
|
|
1796
|
+
* }
|
|
1784
1797
|
* }
|
|
1785
1798
|
* ```
|
|
1786
1799
|
*/
|
|
@@ -5016,6 +5029,65 @@ var Settlement = class {
|
|
|
5016
5029
|
...options
|
|
5017
5030
|
});
|
|
5018
5031
|
}
|
|
5032
|
+
/**
|
|
5033
|
+
* What a period's payments cost at the rails, grouped by shop, connector
|
|
5034
|
+
* and payment method. Answers for **every** merchant, including one that
|
|
5035
|
+
* hosts nobody — it reads the per-attempt settlement record rather than the
|
|
5036
|
+
* settlement lines, which exist only where hosting fees are configured.
|
|
5037
|
+
*
|
|
5038
|
+
* A sibling of {@link Settlement.cost} rather than a widening of it. That
|
|
5039
|
+
* endpoint is a profit statement whose revenue term is hosting income, and
|
|
5040
|
+
* a merchant who hosts nobody has none. This publishes cost and never
|
|
5041
|
+
* margin.
|
|
5042
|
+
*
|
|
5043
|
+
* Send `year` and `month` together to report one UTC calendar month, or
|
|
5044
|
+
* neither for the running month so far.
|
|
5045
|
+
*
|
|
5046
|
+
* **The response carries no period total, and a caller must not compute
|
|
5047
|
+
* one here.** Every figure keeps the unit the rail reported it in, and the
|
|
5048
|
+
* unit is part of each bucket's key, so adding two buckets is not addition.
|
|
5049
|
+
* Convert caller-side if you need one number, and say which rates you used.
|
|
5050
|
+
* The counts are totalled, because a count has no unit.
|
|
5051
|
+
*
|
|
5052
|
+
* Two distinctions not to flatten when rendering a bucket:
|
|
5053
|
+
* `cost_amount` covers `reported_count + estimated_count` attempts out of
|
|
5054
|
+
* `attempt_count` and is a lower bound whenever those disagree; and
|
|
5055
|
+
* `unavailable_count` (the rail says it has no figure) means something
|
|
5056
|
+
* different from `unwritten_count` (a gap in our own recording).
|
|
5057
|
+
*
|
|
5058
|
+
* **Merchant scope.** A token scoped to a single shop, a role narrowed to
|
|
5059
|
+
* specific connector accounts, or a role without the settlement-read
|
|
5060
|
+
* permission group is refused `403`: what a rail charged is the merchant's
|
|
5061
|
+
* own cost base, and here it is the whole response, so there is nothing
|
|
5062
|
+
* coherent to redact down to. Gate the surface on the caller's scope rather
|
|
5063
|
+
* than calling it and handling the failure.
|
|
5064
|
+
*
|
|
5065
|
+
* `GET /settlement/processor-cost`
|
|
5066
|
+
*
|
|
5067
|
+
* @example
|
|
5068
|
+
* ```typescript
|
|
5069
|
+
* const period = await delopay.settlement.processorCost({
|
|
5070
|
+
* test_mode: false,
|
|
5071
|
+
* year: 2026,
|
|
5072
|
+
* month: 7,
|
|
5073
|
+
* });
|
|
5074
|
+
* for (const bucket of period.buckets) {
|
|
5075
|
+
* // Each bucket is its own unit — render per bucket, never a sum.
|
|
5076
|
+
* console.log(bucket.connector, bucket.cost_amount, bucket.cost_currency);
|
|
5077
|
+
* }
|
|
5078
|
+
* ```
|
|
5079
|
+
*/
|
|
5080
|
+
async processorCost(params, options) {
|
|
5081
|
+
return this.request("GET", "/settlement/processor-cost", {
|
|
5082
|
+
query: {
|
|
5083
|
+
profile_id: params?.profile_id,
|
|
5084
|
+
test_mode: params?.test_mode,
|
|
5085
|
+
year: params?.year,
|
|
5086
|
+
month: params?.month
|
|
5087
|
+
},
|
|
5088
|
+
...options
|
|
5089
|
+
});
|
|
5090
|
+
}
|
|
5019
5091
|
/**
|
|
5020
5092
|
* List generated settlement statements, newest first.
|
|
5021
5093
|
*
|
|
@@ -6424,6 +6496,66 @@ function surchargeWordFor(branding, isDiscount, locale) {
|
|
|
6424
6496
|
locale
|
|
6425
6497
|
);
|
|
6426
6498
|
}
|
|
6499
|
+
var NOTICE_SECTIONS = ["summary", "payment"];
|
|
6500
|
+
var NOTICES_PER_SECTION = 3;
|
|
6501
|
+
var NOTICE_LABEL_MAX_LENGTH = 80;
|
|
6502
|
+
var NOTICE_ICONS = [
|
|
6503
|
+
"lock",
|
|
6504
|
+
"shield",
|
|
6505
|
+
"check",
|
|
6506
|
+
"truck",
|
|
6507
|
+
"package",
|
|
6508
|
+
"refresh",
|
|
6509
|
+
"star",
|
|
6510
|
+
"support",
|
|
6511
|
+
"globe",
|
|
6512
|
+
"tag",
|
|
6513
|
+
"heart",
|
|
6514
|
+
"leaf",
|
|
6515
|
+
"clock",
|
|
6516
|
+
"bank"
|
|
6517
|
+
];
|
|
6518
|
+
var NOTICE_ICON_FALLBACK = "check";
|
|
6519
|
+
var NOTICE_ICON_PATHS = {
|
|
6520
|
+
lock: [
|
|
6521
|
+
"M6 10h12a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2z",
|
|
6522
|
+
"M8 10V7a4 4 0 0 1 8 0v3"
|
|
6523
|
+
],
|
|
6524
|
+
shield: ["M12 3l7 3v6c0 4.2-2.9 7.6-7 9-4.1-1.4-7-4.8-7-9V6z", "M9 12l2.5 2.5 4-4.5"],
|
|
6525
|
+
check: ["M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z", "M8 12.5l3 3 5-6"],
|
|
6526
|
+
truck: [
|
|
6527
|
+
"M3 7.5h10v9H3z",
|
|
6528
|
+
"M13 11h4l3 3v2.5h-7z",
|
|
6529
|
+
"M8.8 18a1.8 1.8 0 1 1-3.6 0a1.8 1.8 0 1 1 3.6 0z",
|
|
6530
|
+
"M18.8 18a1.8 1.8 0 1 1-3.6 0a1.8 1.8 0 1 1 3.6 0z"
|
|
6531
|
+
],
|
|
6532
|
+
package: [
|
|
6533
|
+
"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",
|
|
6534
|
+
"M12 22V12",
|
|
6535
|
+
"M3.29 7L12 12l8.71-5"
|
|
6536
|
+
],
|
|
6537
|
+
refresh: ["M20 12a8 8 0 1 1-2.5-5.8", "M20 4v5h-5"],
|
|
6538
|
+
star: ["m12 3.6 2.6 5.3 5.9.9-4.3 4.1 1 5.8-5.2-2.7-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z"],
|
|
6539
|
+
support: [
|
|
6540
|
+
"M5 13v-1a7 7 0 0 1 14 0v1",
|
|
6541
|
+
"M3.5 14.5a1.8 1.8 0 0 1 1.8-1.8H7v5H5.3a1.8 1.8 0 0 1-1.8-1.8z",
|
|
6542
|
+
"M20.5 14.5a1.8 1.8 0 0 0-1.8-1.8H17v5h1.7a1.8 1.8 0 0 0 1.8-1.8z",
|
|
6543
|
+
"M19 17.7v.8a2.5 2.5 0 0 1-2.5 2.5H13"
|
|
6544
|
+
],
|
|
6545
|
+
globe: [
|
|
6546
|
+
"M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z",
|
|
6547
|
+
"M3 12h18",
|
|
6548
|
+
"M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"
|
|
6549
|
+
],
|
|
6550
|
+
tag: ["M11 3H4v7l10 10 7-7z", "M9.1 7a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z"],
|
|
6551
|
+
heart: ["M12 20s-7-4.4-7-9.3A3.9 3.9 0 0 1 12 8a3.9 3.9 0 0 1 7 2.7c0 4.9-7 9.3-7 9.3z"],
|
|
6552
|
+
leaf: ["M20 4c0 9-5.4 13-9.5 13A4.5 4.5 0 0 1 6 12.5C6 7 12 4 20 4z", "M4 20c2-4.5 5-7.5 9-9.5"],
|
|
6553
|
+
clock: ["M21 12a9 9 0 1 1-18 0a9 9 0 1 1 18 0z", "M12 7v5l3 2"],
|
|
6554
|
+
bank: ["M3 9.5 12 4l9 5.5", "M5 10v8M9.5 10v8M14.5 10v8M19 10v8", "M3 20h18"]
|
|
6555
|
+
};
|
|
6556
|
+
function isNoticeIcon(value) {
|
|
6557
|
+
return typeof value === "string" && NOTICE_ICONS.includes(value);
|
|
6558
|
+
}
|
|
6427
6559
|
var FONT_STACKS = {
|
|
6428
6560
|
inter: "'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif",
|
|
6429
6561
|
system: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif",
|
|
@@ -6593,6 +6725,96 @@ var DEFAULT_BADGES_DARK = [
|
|
|
6593
6725
|
borderColor: "#1e40af"
|
|
6594
6726
|
}
|
|
6595
6727
|
];
|
|
6728
|
+
var DEFAULT_NOTICES = [
|
|
6729
|
+
{
|
|
6730
|
+
id: "secure",
|
|
6731
|
+
section: "summary",
|
|
6732
|
+
icon: "shield",
|
|
6733
|
+
label: "Secure payment",
|
|
6734
|
+
labelTranslations: {
|
|
6735
|
+
de: "Sichere Zahlung",
|
|
6736
|
+
fr: "Paiement s\xE9curis\xE9",
|
|
6737
|
+
es: "Pago seguro",
|
|
6738
|
+
it: "Pagamento sicuro",
|
|
6739
|
+
nl: "Veilig betalen",
|
|
6740
|
+
zh: "\u5B89\u5168\u652F\u4ED8",
|
|
6741
|
+
"zh-Hant": "\u5B89\u5168\u4ED8\u6B3E",
|
|
6742
|
+
hi: "\u0938\u0941\u0930\u0915\u094D\u0937\u093F\u0924 \u092D\u0941\u0917\u0924\u093E\u0928",
|
|
6743
|
+
ar: "\u062F\u0641\u0639 \u0622\u0645\u0646"
|
|
6744
|
+
}
|
|
6745
|
+
},
|
|
6746
|
+
{
|
|
6747
|
+
id: "ssl",
|
|
6748
|
+
section: "summary",
|
|
6749
|
+
icon: "lock",
|
|
6750
|
+
label: "Encrypted \xB7 256-bit SSL",
|
|
6751
|
+
labelTranslations: {
|
|
6752
|
+
de: "Verschl\xFCsselt \xB7 256-Bit-SSL",
|
|
6753
|
+
fr: "Chiffr\xE9 \xB7 SSL 256 bits",
|
|
6754
|
+
es: "Cifrado \xB7 SSL de 256 bits",
|
|
6755
|
+
it: "Crittografato \xB7 SSL a 256 bit",
|
|
6756
|
+
nl: "Versleuteld \xB7 256-bit SSL",
|
|
6757
|
+
zh: "\u52A0\u5BC6 \xB7 256 \u4F4D SSL",
|
|
6758
|
+
"zh-Hant": "\u52A0\u5BC6 \xB7 256 \u4F4D\u5143 SSL",
|
|
6759
|
+
hi: "\u090F\u0928\u094D\u0915\u094D\u0930\u093F\u092A\u094D\u091F\u0947\u0921 \xB7 256-\u092C\u093F\u091F SSL",
|
|
6760
|
+
ar: "\u0645\u0634\u0641\u0651\u0631 \xB7 SSL \u0628\u0637\u0648\u0644 256 \u0628\u062A"
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
];
|
|
6764
|
+
function defaultNotices() {
|
|
6765
|
+
return DEFAULT_NOTICES.map(cloneNotice);
|
|
6766
|
+
}
|
|
6767
|
+
function cloneNotice(notice) {
|
|
6768
|
+
return { ...notice, labelTranslations: { ...notice.labelTranslations } };
|
|
6769
|
+
}
|
|
6770
|
+
function hexChannels(hex) {
|
|
6771
|
+
const raw = /^#([0-9a-f]{6})$/i.exec(hex.trim())?.[1];
|
|
6772
|
+
if (!raw) return null;
|
|
6773
|
+
return [
|
|
6774
|
+
parseInt(raw.slice(0, 2), 16),
|
|
6775
|
+
parseInt(raw.slice(2, 4), 16),
|
|
6776
|
+
parseInt(raw.slice(4, 6), 16)
|
|
6777
|
+
];
|
|
6778
|
+
}
|
|
6779
|
+
function isThemeTintedBadgeColouring(textColor, fill, border) {
|
|
6780
|
+
const primary = hexChannels(textColor);
|
|
6781
|
+
const bg = hexChannels(fill);
|
|
6782
|
+
const line = hexChannels(border);
|
|
6783
|
+
if (!primary || !bg || !line) return false;
|
|
6784
|
+
const mixed = (surface, to, share) => Math.round(surface + (to - surface) * share);
|
|
6785
|
+
return primary.every((p, i) => {
|
|
6786
|
+
for (let surface = 0; surface <= 255; surface += 1) {
|
|
6787
|
+
if (mixed(surface, p, 0.08) === bg[i] && mixed(surface, p, 0.3) === line[i]) return true;
|
|
6788
|
+
}
|
|
6789
|
+
return false;
|
|
6790
|
+
});
|
|
6791
|
+
}
|
|
6792
|
+
function isDefaultBadgeSet(badges) {
|
|
6793
|
+
if (badges.length !== DEFAULT_BADGES.length) return false;
|
|
6794
|
+
const sameContent = badges.every(
|
|
6795
|
+
(badge, i) => badge.id === DEFAULT_BADGES[i]?.id && badge.label === DEFAULT_BADGES[i]?.label
|
|
6796
|
+
);
|
|
6797
|
+
if (!sameContent) return false;
|
|
6798
|
+
const colouring = (set) => set.map((b) => [b.textColor, b.backgroundColor, b.borderColor ?? ""].join("|").toLowerCase()).join("/");
|
|
6799
|
+
const mine = colouring(badges);
|
|
6800
|
+
if (mine === colouring(DEFAULT_BADGES) || mine === colouring(DEFAULT_BADGES_DARK)) return true;
|
|
6801
|
+
const [first] = badges;
|
|
6802
|
+
const border = first?.borderColor;
|
|
6803
|
+
if (!first || !border) return false;
|
|
6804
|
+
const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
|
|
6805
|
+
return badges.every(
|
|
6806
|
+
(b) => same(b.textColor, first.textColor) && same(b.backgroundColor, first.backgroundColor) && same(b.borderColor, border)
|
|
6807
|
+
) && isThemeTintedBadgeColouring(first.textColor, first.backgroundColor, border);
|
|
6808
|
+
}
|
|
6809
|
+
function resolveNoticesAndBadges(savedBadges, savedNotices) {
|
|
6810
|
+
if (savedNotices !== null) {
|
|
6811
|
+
return { trustBadges: savedBadges ?? [], notices: savedNotices };
|
|
6812
|
+
}
|
|
6813
|
+
if (savedBadges === null || isDefaultBadgeSet(savedBadges)) {
|
|
6814
|
+
return { trustBadges: [], notices: defaultNotices() };
|
|
6815
|
+
}
|
|
6816
|
+
return { trustBadges: savedBadges, notices: [] };
|
|
6817
|
+
}
|
|
6596
6818
|
var METHOD_SECTION_ORDER_KEY = "methodSectionOrder";
|
|
6597
6819
|
var METHOD_SECTION_LABELS_KEY = "methodSectionLabels";
|
|
6598
6820
|
var MIN_SECTION_ORDER = 1;
|
|
@@ -6879,7 +7101,11 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
6879
7101
|
var DEFAULT_BRANDING = {
|
|
6880
7102
|
...DEFAULT_BRANDING_BASE,
|
|
6881
7103
|
...LIGHT_PALETTE,
|
|
6882
|
-
|
|
7104
|
+
// No badges by default since todos#218 — notices took their place.
|
|
7105
|
+
// `DEFAULT_BADGES` stays exported because `isDefaultBadgeSet` still has to
|
|
7106
|
+
// recognise the pair on shops saved before.
|
|
7107
|
+
trustBadges: [],
|
|
7108
|
+
notices: defaultNotices(),
|
|
6883
7109
|
customFields: [],
|
|
6884
7110
|
methodSectionOrder: defaultMethodSectionOrder(),
|
|
6885
7111
|
methodSectionLabels: {}
|
|
@@ -6902,7 +7128,8 @@ var DEFAULT_BRANDING_DARK = {
|
|
|
6902
7128
|
// end of the ramp — 10.69 and 9.29 against the dark surface, also pinned.
|
|
6903
7129
|
surchargeColor: "#fbbf24",
|
|
6904
7130
|
discountColor: "#34d399",
|
|
6905
|
-
trustBadges:
|
|
7131
|
+
trustBadges: [],
|
|
7132
|
+
notices: defaultNotices(),
|
|
6906
7133
|
customFields: [],
|
|
6907
7134
|
methodSectionOrder: defaultMethodSectionOrder(),
|
|
6908
7135
|
methodSectionLabels: {}
|
|
@@ -6914,6 +7141,7 @@ function cloneBranding(b) {
|
|
|
6914
7141
|
return {
|
|
6915
7142
|
...b,
|
|
6916
7143
|
trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
|
|
7144
|
+
notices: b.notices.map(cloneNotice),
|
|
6917
7145
|
customFields: b.customFields.map(cloneCustomField),
|
|
6918
7146
|
methodSectionOrder: { ...b.methodSectionOrder },
|
|
6919
7147
|
methodSectionLabels: Object.fromEntries(
|
|
@@ -7023,6 +7251,80 @@ function encodeBadges(badges) {
|
|
|
7023
7251
|
}))
|
|
7024
7252
|
);
|
|
7025
7253
|
}
|
|
7254
|
+
var NOTICE_ID_MAX_LENGTH = 40;
|
|
7255
|
+
function capNoticeText(value) {
|
|
7256
|
+
return Array.from(value).slice(0, NOTICE_LABEL_MAX_LENGTH).join("");
|
|
7257
|
+
}
|
|
7258
|
+
function normalizeNotices(list) {
|
|
7259
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7260
|
+
const perSection = /* @__PURE__ */ new Map();
|
|
7261
|
+
const out = [];
|
|
7262
|
+
list.forEach((raw, index) => {
|
|
7263
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
|
|
7264
|
+
const src = raw;
|
|
7265
|
+
const label = typeof src["label"] === "string" ? capNoticeText(src["label"]) : "";
|
|
7266
|
+
const labelTranslations = {};
|
|
7267
|
+
for (const [locale, text] of Object.entries(parseTranslations(src["labelTranslations"]))) {
|
|
7268
|
+
labelTranslations[locale] = capNoticeText(text);
|
|
7269
|
+
}
|
|
7270
|
+
if (label.trim().length === 0 && Object.keys(labelTranslations).length === 0) return;
|
|
7271
|
+
const section = pickEnum(src["section"], NOTICE_SECTIONS, "summary");
|
|
7272
|
+
const used = perSection.get(section) ?? 0;
|
|
7273
|
+
if (used >= NOTICES_PER_SECTION) return;
|
|
7274
|
+
perSection.set(section, used + 1);
|
|
7275
|
+
let id = typeof src["id"] === "string" ? src["id"].replace(/[^A-Za-z0-9_-]/g, "").slice(0, NOTICE_ID_MAX_LENGTH) : "";
|
|
7276
|
+
if (!id || seen.has(id)) id = `notice-${index + 1}`;
|
|
7277
|
+
while (seen.has(id)) id = `${id}x`;
|
|
7278
|
+
seen.add(id);
|
|
7279
|
+
out.push({
|
|
7280
|
+
id,
|
|
7281
|
+
section,
|
|
7282
|
+
icon: isNoticeIcon(src["icon"]) ? src["icon"] : NOTICE_ICON_FALLBACK,
|
|
7283
|
+
label,
|
|
7284
|
+
labelTranslations
|
|
7285
|
+
});
|
|
7286
|
+
});
|
|
7287
|
+
return out;
|
|
7288
|
+
}
|
|
7289
|
+
function decodeNotices(raw) {
|
|
7290
|
+
if (raw === void 0) return null;
|
|
7291
|
+
let parsed;
|
|
7292
|
+
try {
|
|
7293
|
+
parsed = JSON.parse(raw);
|
|
7294
|
+
} catch {
|
|
7295
|
+
return null;
|
|
7296
|
+
}
|
|
7297
|
+
return Array.isArray(parsed) ? normalizeNotices(parsed) : null;
|
|
7298
|
+
}
|
|
7299
|
+
function parseNoticesLoose(raw) {
|
|
7300
|
+
if (typeof raw === "string") return decodeNotices(raw);
|
|
7301
|
+
return Array.isArray(raw) ? normalizeNotices(raw) : null;
|
|
7302
|
+
}
|
|
7303
|
+
function encodeNotices(notices) {
|
|
7304
|
+
return JSON.stringify(
|
|
7305
|
+
notices.map((n) => {
|
|
7306
|
+
const translations = Object.entries(n.labelTranslations).filter(
|
|
7307
|
+
([, text]) => text.trim().length > 0
|
|
7308
|
+
);
|
|
7309
|
+
return {
|
|
7310
|
+
id: n.id,
|
|
7311
|
+
section: n.section,
|
|
7312
|
+
icon: n.icon,
|
|
7313
|
+
label: n.label,
|
|
7314
|
+
...translations.length > 0 ? { labelTranslations: Object.fromEntries(translations) } : {}
|
|
7315
|
+
};
|
|
7316
|
+
})
|
|
7317
|
+
);
|
|
7318
|
+
}
|
|
7319
|
+
function noticeText(notice, locale) {
|
|
7320
|
+
return translationFor(notice.labelTranslations, locale) ?? notice.label;
|
|
7321
|
+
}
|
|
7322
|
+
function noticesIn(notices, section) {
|
|
7323
|
+
return notices.filter((n) => n.section === section).slice(0, NOTICES_PER_SECTION);
|
|
7324
|
+
}
|
|
7325
|
+
function shownNotices(notices, section, locale) {
|
|
7326
|
+
return noticesIn(notices, section).map((notice) => ({ notice, text: noticeText(notice, locale).trim() })).filter((entry) => entry.text.length > 0);
|
|
7327
|
+
}
|
|
7026
7328
|
var CUSTOM_FIELDS_MAX = 20;
|
|
7027
7329
|
var CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;
|
|
7028
7330
|
var ALL_CUSTOM_FIELD_TYPES = [
|
|
@@ -7366,7 +7668,10 @@ function customFieldOptionLabel(option, locale) {
|
|
|
7366
7668
|
function decodeBranding(source) {
|
|
7367
7669
|
if (!source) return cloneBranding(DEFAULT_BRANDING);
|
|
7368
7670
|
const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
|
|
7369
|
-
const
|
|
7671
|
+
const trustRow = resolveNoticesAndBadges(
|
|
7672
|
+
decodeBadges(extras["trustBadges"]),
|
|
7673
|
+
decodeNotices(extras["notices"])
|
|
7674
|
+
);
|
|
7370
7675
|
const decodedCustomFields = decodeCustomFields(extras["customFields"]);
|
|
7371
7676
|
const displayName = s(source.merchant_name) || s(source.seller_name);
|
|
7372
7677
|
const logoUrl = s(source.merchant_logo) || s(source.logo);
|
|
@@ -7545,7 +7850,8 @@ function decodeBranding(source) {
|
|
|
7545
7850
|
totalLabel: s(extras["totalLabel"]) || DEFAULT_BRANDING.totalLabel,
|
|
7546
7851
|
showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
|
|
7547
7852
|
showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
|
|
7548
|
-
trustBadges:
|
|
7853
|
+
trustBadges: trustRow.trustBadges,
|
|
7854
|
+
notices: trustRow.notices,
|
|
7549
7855
|
customFields: decodedCustomFields ?? [],
|
|
7550
7856
|
methodSectionOrder: decodeMethodSectionOrder(extras[METHOD_SECTION_ORDER_KEY]),
|
|
7551
7857
|
methodSectionLabels: decodeMethodSectionLabels(extras[METHOD_SECTION_LABELS_KEY]),
|
|
@@ -7829,9 +8135,14 @@ function encodeBranding(branding, base) {
|
|
|
7829
8135
|
nomupayApplePayButtonType: branding.nomupayApplePayButtonType,
|
|
7830
8136
|
nomupayGooglePayButtonColor: branding.nomupayGooglePayButtonColor,
|
|
7831
8137
|
nomupayGooglePayButtonType: branding.nomupayGooglePayButtonType,
|
|
7832
|
-
|
|
8138
|
+
// Always written, `[]` included — its presence is what stops a later
|
|
8139
|
+
// decode from migrating the shop again (`resolveNoticesAndBadges`).
|
|
8140
|
+
notices: encodeNotices(branding.notices),
|
|
7833
8141
|
[METHOD_SECTION_ORDER_KEY]: encodeMethodSectionOrder(branding.methodSectionOrder)
|
|
7834
8142
|
};
|
|
8143
|
+
if (branding.trustBadges.length > 0) {
|
|
8144
|
+
extras["trustBadges"] = encodeBadges(branding.trustBadges);
|
|
8145
|
+
}
|
|
7835
8146
|
const sectionLabels = encodeMethodSectionLabels(branding.methodSectionLabels);
|
|
7836
8147
|
if (sectionLabels) extras[METHOD_SECTION_LABELS_KEY] = sectionLabels;
|
|
7837
8148
|
if (branding.customFields.length > 0) {
|
|
@@ -7897,7 +8208,10 @@ function parseImportedBranding(raw) {
|
|
|
7897
8208
|
const dflt = DEFAULT_BRANDING;
|
|
7898
8209
|
const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
|
|
7899
8210
|
const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
|
|
7900
|
-
const
|
|
8211
|
+
const { trustBadges, notices } = resolveNoticesAndBadges(
|
|
8212
|
+
parseTrustBadgesLoose(root["trustBadges"]),
|
|
8213
|
+
parseNoticesLoose(root["notices"])
|
|
8214
|
+
);
|
|
7901
8215
|
const customFields = parseCustomFieldsLoose(root["customFields"]) ?? [];
|
|
7902
8216
|
const labelStyle = (() => {
|
|
7903
8217
|
const v = root["labelStyle"];
|
|
@@ -8040,6 +8354,7 @@ function parseImportedBranding(raw) {
|
|
|
8040
8354
|
showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
|
|
8041
8355
|
showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
|
|
8042
8356
|
trustBadges,
|
|
8357
|
+
notices,
|
|
8043
8358
|
customFields,
|
|
8044
8359
|
// An export writes the decoded maps; a hand-written file may carry the
|
|
8045
8360
|
// JSON strings the bag uses. Both are accepted, and neither is required.
|
|
@@ -9289,6 +9604,13 @@ export {
|
|
|
9289
9604
|
copyTranslationsKey,
|
|
9290
9605
|
checkoutCopy,
|
|
9291
9606
|
surchargeWordFor,
|
|
9607
|
+
NOTICE_SECTIONS,
|
|
9608
|
+
NOTICES_PER_SECTION,
|
|
9609
|
+
NOTICE_LABEL_MAX_LENGTH,
|
|
9610
|
+
NOTICE_ICONS,
|
|
9611
|
+
NOTICE_ICON_FALLBACK,
|
|
9612
|
+
NOTICE_ICON_PATHS,
|
|
9613
|
+
isNoticeIcon,
|
|
9292
9614
|
fontStack,
|
|
9293
9615
|
radiusValue,
|
|
9294
9616
|
fontWeightValue,
|
|
@@ -9304,6 +9626,11 @@ export {
|
|
|
9304
9626
|
isDarkSurface,
|
|
9305
9627
|
DEFAULT_BADGES,
|
|
9306
9628
|
DEFAULT_BADGES_DARK,
|
|
9629
|
+
DEFAULT_NOTICES,
|
|
9630
|
+
defaultNotices,
|
|
9631
|
+
cloneNotice,
|
|
9632
|
+
isDefaultBadgeSet,
|
|
9633
|
+
resolveNoticesAndBadges,
|
|
9307
9634
|
MIN_SECTION_ORDER,
|
|
9308
9635
|
MAX_SECTION_ORDER,
|
|
9309
9636
|
MAX_SECTION_LABEL_LENGTH,
|
|
@@ -9330,6 +9657,12 @@ export {
|
|
|
9330
9657
|
sanitizeCustomCss,
|
|
9331
9658
|
decodeBadges,
|
|
9332
9659
|
encodeBadges,
|
|
9660
|
+
decodeNotices,
|
|
9661
|
+
parseNoticesLoose,
|
|
9662
|
+
encodeNotices,
|
|
9663
|
+
noticeText,
|
|
9664
|
+
noticesIn,
|
|
9665
|
+
shownNotices,
|
|
9333
9666
|
CUSTOM_FIELDS_MAX,
|
|
9334
9667
|
CUSTOM_FIELD_KEY_PATTERN,
|
|
9335
9668
|
ALL_CUSTOM_FIELD_TYPES,
|
|
@@ -9392,4 +9725,4 @@ export {
|
|
|
9392
9725
|
decodeNativePanes,
|
|
9393
9726
|
encodeNativePanes
|
|
9394
9727
|
};
|
|
9395
|
-
//# sourceMappingURL=chunk-
|
|
9728
|
+
//# sourceMappingURL=chunk-CP5M5WR6.js.map
|