@delopay/sdk 0.18.2 → 0.19.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-CFM23H56.js → chunk-ICBLNJN7.js} +665 -2
- package/dist/chunk-ICBLNJN7.js.map +1 -0
- package/dist/index.cjs +693 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -1
- package/dist/index.d.ts +139 -1
- package/dist/index.js +59 -3
- package/dist/internal.cjs +693 -2
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +18 -1
- package/dist/internal.d.ts +18 -1
- package/dist/internal.js +59 -3
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-CFM23H56.js.map +0 -1
|
@@ -2885,6 +2885,641 @@ var Delopay = class {
|
|
|
2885
2885
|
/** Utility for verifying incoming webhook signatures (static, no instance needed). */
|
|
2886
2886
|
Delopay.webhooks = Webhooks;
|
|
2887
2887
|
|
|
2888
|
+
// src/branding.ts
|
|
2889
|
+
var FONT_STACKS = {
|
|
2890
|
+
inter: "'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif",
|
|
2891
|
+
system: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif",
|
|
2892
|
+
serif: "Georgia, 'Times New Roman', serif",
|
|
2893
|
+
mono: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
2894
|
+
roboto: "'Roboto', system-ui, sans-serif",
|
|
2895
|
+
poppins: "'Poppins', system-ui, sans-serif",
|
|
2896
|
+
manrope: "'Manrope Variable', 'Manrope', system-ui, sans-serif",
|
|
2897
|
+
"dm-sans": "'DM Sans Variable', 'DM Sans', system-ui, sans-serif",
|
|
2898
|
+
"space-grotesk": "'Space Grotesk Variable', 'Space Grotesk', system-ui, sans-serif",
|
|
2899
|
+
"plex-sans": "'IBM Plex Sans', system-ui, sans-serif",
|
|
2900
|
+
"work-sans": "'Work Sans Variable', 'Work Sans', system-ui, sans-serif",
|
|
2901
|
+
"open-sans": "'Open Sans Variable', 'Open Sans', system-ui, sans-serif",
|
|
2902
|
+
lora: "'Lora Variable', 'Lora', Georgia, serif",
|
|
2903
|
+
playfair: "'Playfair Display Variable', 'Playfair Display', Georgia, serif",
|
|
2904
|
+
"plex-mono": "'IBM Plex Mono', ui-monospace, monospace",
|
|
2905
|
+
"jetbrains-mono": "'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace"
|
|
2906
|
+
};
|
|
2907
|
+
var RADIUS_PX = {
|
|
2908
|
+
square: "0px",
|
|
2909
|
+
small: "6px",
|
|
2910
|
+
medium: "12px",
|
|
2911
|
+
large: "20px",
|
|
2912
|
+
pill: "999px"
|
|
2913
|
+
};
|
|
2914
|
+
var FONT_WEIGHT_NUMERIC = {
|
|
2915
|
+
regular: "400",
|
|
2916
|
+
medium: "500",
|
|
2917
|
+
semibold: "600",
|
|
2918
|
+
bold: "700"
|
|
2919
|
+
};
|
|
2920
|
+
var SURFACE_PAD = {
|
|
2921
|
+
compact: "1rem",
|
|
2922
|
+
comfortable: "1.5rem",
|
|
2923
|
+
spacious: "2rem"
|
|
2924
|
+
};
|
|
2925
|
+
var VERTICAL_GAP = {
|
|
2926
|
+
compact: "0.75rem",
|
|
2927
|
+
comfortable: "1rem",
|
|
2928
|
+
spacious: "1.5rem"
|
|
2929
|
+
};
|
|
2930
|
+
var INPUT_PAD = {
|
|
2931
|
+
sm: "0.5rem 0.75rem",
|
|
2932
|
+
md: "0.625rem 0.75rem",
|
|
2933
|
+
lg: "0.875rem 0.875rem"
|
|
2934
|
+
};
|
|
2935
|
+
var BUTTON_PAD = {
|
|
2936
|
+
sm: "0.625rem 1rem",
|
|
2937
|
+
md: "0.875rem 1.25rem",
|
|
2938
|
+
lg: "1.125rem 1.5rem"
|
|
2939
|
+
};
|
|
2940
|
+
function fontStack(family) {
|
|
2941
|
+
return FONT_STACKS[family] ?? FONT_STACKS.inter;
|
|
2942
|
+
}
|
|
2943
|
+
function radiusValue(radius) {
|
|
2944
|
+
return RADIUS_PX[radius] ?? RADIUS_PX.medium;
|
|
2945
|
+
}
|
|
2946
|
+
function fontWeightValue(weight) {
|
|
2947
|
+
return FONT_WEIGHT_NUMERIC[weight] ?? "600";
|
|
2948
|
+
}
|
|
2949
|
+
function surfacePadValue(scale) {
|
|
2950
|
+
return SURFACE_PAD[scale] ?? SURFACE_PAD.comfortable;
|
|
2951
|
+
}
|
|
2952
|
+
function verticalGapValue(scale) {
|
|
2953
|
+
return VERTICAL_GAP[scale] ?? VERTICAL_GAP.comfortable;
|
|
2954
|
+
}
|
|
2955
|
+
function inputPadValue(size) {
|
|
2956
|
+
return INPUT_PAD[size] ?? INPUT_PAD.md;
|
|
2957
|
+
}
|
|
2958
|
+
function buttonPadValue(size) {
|
|
2959
|
+
return BUTTON_PAD[size] ?? BUTTON_PAD.md;
|
|
2960
|
+
}
|
|
2961
|
+
function logoDimensions(size) {
|
|
2962
|
+
switch (size) {
|
|
2963
|
+
case "sm":
|
|
2964
|
+
return { px: 36, radius: 8 };
|
|
2965
|
+
case "lg":
|
|
2966
|
+
return { px: 64, radius: 16 };
|
|
2967
|
+
case "md":
|
|
2968
|
+
default:
|
|
2969
|
+
return { px: 48, radius: 12 };
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
var HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
|
|
2973
|
+
function isHexColor(value) {
|
|
2974
|
+
return HEX_RE.test(value.trim());
|
|
2975
|
+
}
|
|
2976
|
+
function isDarkSurface(color) {
|
|
2977
|
+
const m = color.replace("#", "").trim();
|
|
2978
|
+
if (m.length !== 3 && m.length !== 6) return false;
|
|
2979
|
+
const full = m.length === 3 ? m.split("").map((c) => c + c).join("") : m;
|
|
2980
|
+
const r = parseInt(full.slice(0, 2), 16);
|
|
2981
|
+
const g = parseInt(full.slice(2, 4), 16);
|
|
2982
|
+
const b = parseInt(full.slice(4, 6), 16);
|
|
2983
|
+
if ([r, g, b].some(Number.isNaN)) return false;
|
|
2984
|
+
const luma = (r * 299 + g * 587 + b * 114) / 1e3;
|
|
2985
|
+
return luma < 128;
|
|
2986
|
+
}
|
|
2987
|
+
var LIGHT_PALETTE = {
|
|
2988
|
+
primary: "#1E4FEB",
|
|
2989
|
+
background: "#f8fafc",
|
|
2990
|
+
surface: "#ffffff",
|
|
2991
|
+
text: "#1e293b",
|
|
2992
|
+
heading: "#0A1130",
|
|
2993
|
+
muted: "#64748b",
|
|
2994
|
+
border: "#e2e8f0",
|
|
2995
|
+
accentText: "#1E4FEB",
|
|
2996
|
+
buttonBackground: "#0A1130",
|
|
2997
|
+
buttonText: "#ffffff"
|
|
2998
|
+
};
|
|
2999
|
+
var DEFAULT_BADGES = [
|
|
3000
|
+
{
|
|
3001
|
+
id: "secure",
|
|
3002
|
+
label: "Secure",
|
|
3003
|
+
textColor: "#047857",
|
|
3004
|
+
backgroundColor: "#ecfdf5",
|
|
3005
|
+
borderColor: "#a7f3d0"
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
id: "ssl",
|
|
3009
|
+
label: "256-bit SSL",
|
|
3010
|
+
textColor: "#1E4FEB",
|
|
3011
|
+
backgroundColor: "#eff6ff",
|
|
3012
|
+
borderColor: "#bfdbfe"
|
|
3013
|
+
}
|
|
3014
|
+
];
|
|
3015
|
+
var DEFAULT_BADGES_DARK = [
|
|
3016
|
+
{
|
|
3017
|
+
id: "secure",
|
|
3018
|
+
label: "Secure",
|
|
3019
|
+
textColor: "#34d399",
|
|
3020
|
+
backgroundColor: "#064e3b",
|
|
3021
|
+
borderColor: "#065f46"
|
|
3022
|
+
},
|
|
3023
|
+
{
|
|
3024
|
+
id: "ssl",
|
|
3025
|
+
label: "256-bit SSL",
|
|
3026
|
+
textColor: "#60a5fa",
|
|
3027
|
+
backgroundColor: "#172554",
|
|
3028
|
+
borderColor: "#1e40af"
|
|
3029
|
+
}
|
|
3030
|
+
];
|
|
3031
|
+
var DEFAULT_BRANDING_BASE = {
|
|
3032
|
+
displayName: "",
|
|
3033
|
+
logoUrl: "",
|
|
3034
|
+
tagline: "",
|
|
3035
|
+
// Logo + summary gradient OFF by default — an unconfigured DeloPay
|
|
3036
|
+
// checkout reads cleaner without a placeholder logo block, and the
|
|
3037
|
+
// gradient implies a primary tint the merchant hasn't yet picked.
|
|
3038
|
+
showLogo: false,
|
|
3039
|
+
logoShape: "rounded",
|
|
3040
|
+
logoSize: "md",
|
|
3041
|
+
fontFamily: "inter",
|
|
3042
|
+
headingWeight: "semibold",
|
|
3043
|
+
radiusSurface: "medium",
|
|
3044
|
+
radiusInput: "medium",
|
|
3045
|
+
radiusButton: "medium",
|
|
3046
|
+
radiusBadge: "pill",
|
|
3047
|
+
surfaceStyle: "elevated",
|
|
3048
|
+
surfacePadding: "comfortable",
|
|
3049
|
+
verticalGap: "comfortable",
|
|
3050
|
+
inputSize: "md",
|
|
3051
|
+
buttonSize: "md",
|
|
3052
|
+
layout: "split",
|
|
3053
|
+
summaryPosition: "left",
|
|
3054
|
+
showOrderSummary: true,
|
|
3055
|
+
summaryGradient: false,
|
|
3056
|
+
showTotal: true,
|
|
3057
|
+
totalLabel: "Total",
|
|
3058
|
+
showCurrencyCode: false,
|
|
3059
|
+
showOrderItems: true,
|
|
3060
|
+
headerText: "",
|
|
3061
|
+
payButtonLabel: "",
|
|
3062
|
+
cardTermsMessage: "",
|
|
3063
|
+
footerText: "",
|
|
3064
|
+
supportEmail: "",
|
|
3065
|
+
paymentLayout: "tabs",
|
|
3066
|
+
labelStyle: "above",
|
|
3067
|
+
showPoweredBy: true,
|
|
3068
|
+
customCss: ""
|
|
3069
|
+
};
|
|
3070
|
+
var DEFAULT_BRANDING = {
|
|
3071
|
+
...DEFAULT_BRANDING_BASE,
|
|
3072
|
+
...LIGHT_PALETTE,
|
|
3073
|
+
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b }))
|
|
3074
|
+
};
|
|
3075
|
+
var DEFAULT_BRANDING_DARK = {
|
|
3076
|
+
...DEFAULT_BRANDING_BASE,
|
|
3077
|
+
primary: "#1E4FEB",
|
|
3078
|
+
background: "#020617",
|
|
3079
|
+
surface: "#0f172a",
|
|
3080
|
+
text: "#e2e8f0",
|
|
3081
|
+
heading: "#f8fafc",
|
|
3082
|
+
muted: "#94a3b8",
|
|
3083
|
+
border: "#1e293b",
|
|
3084
|
+
accentText: "#60a5fa",
|
|
3085
|
+
buttonBackground: "#1E4FEB",
|
|
3086
|
+
buttonText: "#ffffff",
|
|
3087
|
+
surfaceStyle: "flat",
|
|
3088
|
+
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b }))
|
|
3089
|
+
};
|
|
3090
|
+
function defaultBranding() {
|
|
3091
|
+
return cloneBranding(DEFAULT_BRANDING);
|
|
3092
|
+
}
|
|
3093
|
+
function cloneBranding(b) {
|
|
3094
|
+
return { ...b, trustBadges: b.trustBadges.map((badge) => ({ ...badge })) };
|
|
3095
|
+
}
|
|
3096
|
+
var CUSTOM_CSS_MAX_LENGTH = 5e4;
|
|
3097
|
+
function sanitizeCustomCss(raw) {
|
|
3098
|
+
if (typeof raw !== "string") return null;
|
|
3099
|
+
const trimmed = raw.trim();
|
|
3100
|
+
if (trimmed.length === 0) return null;
|
|
3101
|
+
if (trimmed.length > CUSTOM_CSS_MAX_LENGTH) return null;
|
|
3102
|
+
let out = trimmed;
|
|
3103
|
+
out = out.replace(/<\/style/gi, "<\\/style");
|
|
3104
|
+
out = out.replace(/@import\b[^;]*;?/gi, "");
|
|
3105
|
+
out = out.replace(/expression\s*\(/gi, "/* expression( */");
|
|
3106
|
+
out = out.replace(/(^|[^a-z-])behavior\s*:/gi, "$1/* behavior: */");
|
|
3107
|
+
out = out.replace(/-moz-binding\s*:/gi, "/* -moz-binding: */");
|
|
3108
|
+
out = out.replace(/url\s*\(\s*["']?\s*javascript:/gi, "url(invalid:");
|
|
3109
|
+
return out;
|
|
3110
|
+
}
|
|
3111
|
+
var BRANDING_GROUP_KEY = "branding";
|
|
3112
|
+
var ALL_FONT_FAMILIES = [
|
|
3113
|
+
"inter",
|
|
3114
|
+
"system",
|
|
3115
|
+
"serif",
|
|
3116
|
+
"mono",
|
|
3117
|
+
"roboto",
|
|
3118
|
+
"poppins",
|
|
3119
|
+
"manrope",
|
|
3120
|
+
"dm-sans",
|
|
3121
|
+
"space-grotesk",
|
|
3122
|
+
"plex-sans",
|
|
3123
|
+
"work-sans",
|
|
3124
|
+
"open-sans",
|
|
3125
|
+
"lora",
|
|
3126
|
+
"playfair",
|
|
3127
|
+
"plex-mono",
|
|
3128
|
+
"jetbrains-mono"
|
|
3129
|
+
];
|
|
3130
|
+
var ALL_RADII = ["square", "small", "medium", "large", "pill"];
|
|
3131
|
+
var NON_PILL_RADII = ["square", "small", "medium", "large"];
|
|
3132
|
+
function pickEnum(value, allowed, fallback) {
|
|
3133
|
+
if (typeof value !== "string") return fallback;
|
|
3134
|
+
return allowed.includes(value) ? value : fallback;
|
|
3135
|
+
}
|
|
3136
|
+
function parseBool(value, fallback) {
|
|
3137
|
+
if (typeof value === "boolean") return value;
|
|
3138
|
+
if (value === "true") return true;
|
|
3139
|
+
if (value === "false") return false;
|
|
3140
|
+
return fallback;
|
|
3141
|
+
}
|
|
3142
|
+
function s(value) {
|
|
3143
|
+
return typeof value === "string" ? value : "";
|
|
3144
|
+
}
|
|
3145
|
+
function decodeBadges(raw) {
|
|
3146
|
+
if (raw === void 0) return null;
|
|
3147
|
+
try {
|
|
3148
|
+
const parsed = JSON.parse(raw);
|
|
3149
|
+
if (!Array.isArray(parsed)) return null;
|
|
3150
|
+
return parsed.filter((b) => !!b && typeof b === "object").map((b, i) => ({
|
|
3151
|
+
id: typeof b["id"] === "string" && b["id"] ? b["id"] : `badge-${i}`,
|
|
3152
|
+
label: typeof b["label"] === "string" ? b["label"] : "",
|
|
3153
|
+
textColor: typeof b["textColor"] === "string" ? b["textColor"] : "#0f172a",
|
|
3154
|
+
backgroundColor: typeof b["backgroundColor"] === "string" ? b["backgroundColor"] : "#f1f5f9",
|
|
3155
|
+
borderColor: typeof b["borderColor"] === "string" && b["borderColor"] ? b["borderColor"] : null
|
|
3156
|
+
})).filter((b) => b.label.length > 0);
|
|
3157
|
+
} catch {
|
|
3158
|
+
return null;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
function encodeBadges(badges) {
|
|
3162
|
+
return JSON.stringify(
|
|
3163
|
+
badges.map((b) => ({
|
|
3164
|
+
id: b.id,
|
|
3165
|
+
label: b.label,
|
|
3166
|
+
textColor: b.textColor,
|
|
3167
|
+
backgroundColor: b.backgroundColor,
|
|
3168
|
+
...b.borderColor ? { borderColor: b.borderColor } : {}
|
|
3169
|
+
}))
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3172
|
+
function decodeBranding(source) {
|
|
3173
|
+
if (!source) return cloneBranding(DEFAULT_BRANDING);
|
|
3174
|
+
const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
|
|
3175
|
+
const decodedBadges = decodeBadges(extras["trustBadges"]);
|
|
3176
|
+
const displayName = s(source.merchant_name) || s(source.seller_name);
|
|
3177
|
+
const logoUrl = s(source.merchant_logo) || s(source.logo);
|
|
3178
|
+
const tagline = s(extras["tagline"]) || s(source.merchant_description);
|
|
3179
|
+
const labelStyle = (() => {
|
|
3180
|
+
const fromBag = extras["labelStyle"];
|
|
3181
|
+
if (fromBag === "above" || fromBag === "hidden") return fromBag;
|
|
3182
|
+
if (fromBag === "floating") return "above";
|
|
3183
|
+
const legacy = source.payment_form_label_type;
|
|
3184
|
+
if (legacy === "above" || legacy === "floating") return "above";
|
|
3185
|
+
if (legacy === "hidden" || legacy === "never") return "hidden";
|
|
3186
|
+
return DEFAULT_BRANDING.labelStyle;
|
|
3187
|
+
})();
|
|
3188
|
+
return {
|
|
3189
|
+
displayName,
|
|
3190
|
+
logoUrl,
|
|
3191
|
+
tagline,
|
|
3192
|
+
showLogo: parseBool(extras["showLogo"], DEFAULT_BRANDING.showLogo),
|
|
3193
|
+
logoShape: pickEnum(
|
|
3194
|
+
extras["logoShape"],
|
|
3195
|
+
["square", "rounded", "circle"],
|
|
3196
|
+
DEFAULT_BRANDING.logoShape
|
|
3197
|
+
),
|
|
3198
|
+
logoSize: pickEnum(extras["logoSize"], ["sm", "md", "lg"], DEFAULT_BRANDING.logoSize),
|
|
3199
|
+
primary: s(source.theme) || DEFAULT_BRANDING.primary,
|
|
3200
|
+
background: s(source.background_colour) || DEFAULT_BRANDING.background,
|
|
3201
|
+
surface: s(extras["surface"]) || DEFAULT_BRANDING.surface,
|
|
3202
|
+
text: s(extras["text"]) || DEFAULT_BRANDING.text,
|
|
3203
|
+
heading: s(extras["heading"]) || s(extras["text"]) || DEFAULT_BRANDING.heading,
|
|
3204
|
+
muted: s(extras["muted"]) || DEFAULT_BRANDING.muted,
|
|
3205
|
+
border: s(extras["border"]) || DEFAULT_BRANDING.border,
|
|
3206
|
+
accentText: s(extras["accentText"]) || s(source.theme) || DEFAULT_BRANDING.accentText,
|
|
3207
|
+
buttonBackground: s(source.payment_button_colour) || s(source.theme) || DEFAULT_BRANDING.buttonBackground,
|
|
3208
|
+
buttonText: s(source.payment_button_text_colour) || DEFAULT_BRANDING.buttonText,
|
|
3209
|
+
fontFamily: pickEnum(
|
|
3210
|
+
extras["fontFamily"],
|
|
3211
|
+
ALL_FONT_FAMILIES,
|
|
3212
|
+
DEFAULT_BRANDING.fontFamily
|
|
3213
|
+
),
|
|
3214
|
+
headingWeight: pickEnum(
|
|
3215
|
+
extras["headingWeight"],
|
|
3216
|
+
["regular", "medium", "semibold", "bold"],
|
|
3217
|
+
DEFAULT_BRANDING.headingWeight
|
|
3218
|
+
),
|
|
3219
|
+
radiusSurface: pickEnum(
|
|
3220
|
+
extras["radiusSurface"],
|
|
3221
|
+
NON_PILL_RADII,
|
|
3222
|
+
DEFAULT_BRANDING.radiusSurface
|
|
3223
|
+
),
|
|
3224
|
+
radiusInput: pickEnum(
|
|
3225
|
+
extras["radiusInput"],
|
|
3226
|
+
NON_PILL_RADII,
|
|
3227
|
+
DEFAULT_BRANDING.radiusInput
|
|
3228
|
+
),
|
|
3229
|
+
radiusButton: pickEnum(
|
|
3230
|
+
extras["radiusButton"],
|
|
3231
|
+
ALL_RADII,
|
|
3232
|
+
DEFAULT_BRANDING.radiusButton
|
|
3233
|
+
),
|
|
3234
|
+
radiusBadge: pickEnum(
|
|
3235
|
+
extras["radiusBadge"],
|
|
3236
|
+
ALL_RADII,
|
|
3237
|
+
DEFAULT_BRANDING.radiusBadge
|
|
3238
|
+
),
|
|
3239
|
+
surfaceStyle: pickEnum(
|
|
3240
|
+
extras["surfaceStyle"],
|
|
3241
|
+
["flat", "outlined", "elevated"],
|
|
3242
|
+
DEFAULT_BRANDING.surfaceStyle
|
|
3243
|
+
),
|
|
3244
|
+
surfacePadding: pickEnum(
|
|
3245
|
+
extras["surfacePadding"],
|
|
3246
|
+
["compact", "comfortable", "spacious"],
|
|
3247
|
+
DEFAULT_BRANDING.surfacePadding
|
|
3248
|
+
),
|
|
3249
|
+
verticalGap: pickEnum(
|
|
3250
|
+
extras["verticalGap"],
|
|
3251
|
+
["compact", "comfortable", "spacious"],
|
|
3252
|
+
DEFAULT_BRANDING.verticalGap
|
|
3253
|
+
),
|
|
3254
|
+
inputSize: pickEnum(
|
|
3255
|
+
extras["inputSize"],
|
|
3256
|
+
["sm", "md", "lg"],
|
|
3257
|
+
DEFAULT_BRANDING.inputSize
|
|
3258
|
+
),
|
|
3259
|
+
buttonSize: pickEnum(
|
|
3260
|
+
extras["buttonSize"],
|
|
3261
|
+
["sm", "md", "lg"],
|
|
3262
|
+
DEFAULT_BRANDING.buttonSize
|
|
3263
|
+
),
|
|
3264
|
+
layout: pickEnum(
|
|
3265
|
+
extras["layout"],
|
|
3266
|
+
["compact", "split"],
|
|
3267
|
+
DEFAULT_BRANDING.layout
|
|
3268
|
+
),
|
|
3269
|
+
summaryPosition: pickEnum(
|
|
3270
|
+
extras["summaryPosition"],
|
|
3271
|
+
["left", "right"],
|
|
3272
|
+
DEFAULT_BRANDING.summaryPosition
|
|
3273
|
+
),
|
|
3274
|
+
showOrderSummary: parseBool(extras["showOrderSummary"], DEFAULT_BRANDING.showOrderSummary),
|
|
3275
|
+
summaryGradient: parseBool(extras["summaryGradient"], DEFAULT_BRANDING.summaryGradient),
|
|
3276
|
+
showTotal: parseBool(extras["showTotal"], DEFAULT_BRANDING.showTotal),
|
|
3277
|
+
totalLabel: s(extras["totalLabel"]) || DEFAULT_BRANDING.totalLabel,
|
|
3278
|
+
showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
|
|
3279
|
+
showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
|
|
3280
|
+
trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
|
|
3281
|
+
headerText: s(source.payment_form_header_text),
|
|
3282
|
+
payButtonLabel: s(source.payment_button_text),
|
|
3283
|
+
cardTermsMessage: s(source.custom_message_for_card_terms),
|
|
3284
|
+
footerText: s(extras["footerText"]),
|
|
3285
|
+
supportEmail: s(extras["supportEmail"]),
|
|
3286
|
+
paymentLayout: pickEnum(
|
|
3287
|
+
source.sdk_layout,
|
|
3288
|
+
["tabs", "accordion", "spaced_accordion"],
|
|
3289
|
+
DEFAULT_BRANDING.paymentLayout
|
|
3290
|
+
),
|
|
3291
|
+
labelStyle,
|
|
3292
|
+
showPoweredBy: source.branding_visibility !== false,
|
|
3293
|
+
customCss: s(extras["customCss"])
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3296
|
+
function encodeBranding(branding, base) {
|
|
3297
|
+
const trim = (v) => {
|
|
3298
|
+
const t = v.trim();
|
|
3299
|
+
return t.length > 0 ? t : null;
|
|
3300
|
+
};
|
|
3301
|
+
const existingRules = base?.["sdk_ui_rules"] ?? {};
|
|
3302
|
+
const extras = {
|
|
3303
|
+
surface: branding.surface,
|
|
3304
|
+
text: branding.text,
|
|
3305
|
+
heading: branding.heading,
|
|
3306
|
+
muted: branding.muted,
|
|
3307
|
+
border: branding.border,
|
|
3308
|
+
accentText: branding.accentText,
|
|
3309
|
+
fontFamily: branding.fontFamily,
|
|
3310
|
+
headingWeight: branding.headingWeight,
|
|
3311
|
+
radiusSurface: branding.radiusSurface,
|
|
3312
|
+
radiusInput: branding.radiusInput,
|
|
3313
|
+
radiusButton: branding.radiusButton,
|
|
3314
|
+
radiusBadge: branding.radiusBadge,
|
|
3315
|
+
surfaceStyle: branding.surfaceStyle,
|
|
3316
|
+
surfacePadding: branding.surfacePadding,
|
|
3317
|
+
verticalGap: branding.verticalGap,
|
|
3318
|
+
inputSize: branding.inputSize,
|
|
3319
|
+
buttonSize: branding.buttonSize,
|
|
3320
|
+
layout: branding.layout,
|
|
3321
|
+
summaryPosition: branding.summaryPosition,
|
|
3322
|
+
showOrderSummary: String(branding.showOrderSummary),
|
|
3323
|
+
summaryGradient: String(branding.summaryGradient),
|
|
3324
|
+
showTotal: String(branding.showTotal),
|
|
3325
|
+
totalLabel: branding.totalLabel,
|
|
3326
|
+
showCurrencyCode: String(branding.showCurrencyCode),
|
|
3327
|
+
showOrderItems: String(branding.showOrderItems),
|
|
3328
|
+
showLogo: String(branding.showLogo),
|
|
3329
|
+
logoShape: branding.logoShape,
|
|
3330
|
+
logoSize: branding.logoSize,
|
|
3331
|
+
labelStyle: branding.labelStyle,
|
|
3332
|
+
trustBadges: encodeBadges(branding.trustBadges)
|
|
3333
|
+
};
|
|
3334
|
+
const tagline = trim(branding.tagline);
|
|
3335
|
+
if (tagline) extras["tagline"] = tagline;
|
|
3336
|
+
const footer = trim(branding.footerText);
|
|
3337
|
+
if (footer) extras["footerText"] = footer;
|
|
3338
|
+
const support = trim(branding.supportEmail);
|
|
3339
|
+
if (support) extras["supportEmail"] = support;
|
|
3340
|
+
const css = trim(branding.customCss);
|
|
3341
|
+
if (css) extras["customCss"] = css;
|
|
3342
|
+
const nextRules = {
|
|
3343
|
+
...existingRules,
|
|
3344
|
+
[BRANDING_GROUP_KEY]: extras
|
|
3345
|
+
};
|
|
3346
|
+
const legacyLabel = branding.labelStyle === "hidden" ? "never" : "above";
|
|
3347
|
+
const flatFields = {
|
|
3348
|
+
theme: branding.primary,
|
|
3349
|
+
logo: trim(branding.logoUrl),
|
|
3350
|
+
seller_name: trim(branding.displayName),
|
|
3351
|
+
sdk_layout: branding.paymentLayout,
|
|
3352
|
+
payment_button_text: trim(branding.payButtonLabel),
|
|
3353
|
+
payment_button_colour: branding.buttonBackground,
|
|
3354
|
+
payment_button_text_colour: branding.buttonText,
|
|
3355
|
+
background_colour: branding.background,
|
|
3356
|
+
payment_form_header_text: trim(branding.headerText),
|
|
3357
|
+
payment_form_label_type: legacyLabel,
|
|
3358
|
+
custom_message_for_card_terms: trim(branding.cardTermsMessage),
|
|
3359
|
+
sdk_ui_rules: nextRules,
|
|
3360
|
+
branding_visibility: branding.showPoweredBy
|
|
3361
|
+
};
|
|
3362
|
+
return {
|
|
3363
|
+
...base,
|
|
3364
|
+
...flatFields
|
|
3365
|
+
};
|
|
3366
|
+
}
|
|
3367
|
+
var BRANDING_EXPORT_FORMAT = "delopay-checkout-branding";
|
|
3368
|
+
var BRANDING_EXPORT_VERSION = 1;
|
|
3369
|
+
function buildBrandingExport(branding) {
|
|
3370
|
+
return {
|
|
3371
|
+
format: BRANDING_EXPORT_FORMAT,
|
|
3372
|
+
version: BRANDING_EXPORT_VERSION,
|
|
3373
|
+
exported_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3374
|
+
branding: cloneBranding(branding)
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
function parseImportedBranding(raw) {
|
|
3378
|
+
const root = isObject(raw) && isObject(raw["branding"]) ? raw["branding"] : isObject(raw) ? raw : null;
|
|
3379
|
+
if (!root) return cloneBranding(DEFAULT_BRANDING);
|
|
3380
|
+
const dflt = DEFAULT_BRANDING;
|
|
3381
|
+
const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
|
|
3382
|
+
const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
|
|
3383
|
+
const trustBadges = parseTrustBadgesLoose(root["trustBadges"]) ?? dflt.trustBadges.map((b) => ({ ...b }));
|
|
3384
|
+
const labelStyle = (() => {
|
|
3385
|
+
const v = root["labelStyle"];
|
|
3386
|
+
if (v === "above" || v === "hidden") return v;
|
|
3387
|
+
return dflt.labelStyle;
|
|
3388
|
+
})();
|
|
3389
|
+
return {
|
|
3390
|
+
displayName: sStr(root["displayName"], dflt.displayName),
|
|
3391
|
+
logoUrl: sStr(root["logoUrl"], dflt.logoUrl),
|
|
3392
|
+
tagline: sStr(root["tagline"], dflt.tagline),
|
|
3393
|
+
showLogo: parseBool(root["showLogo"], dflt.showLogo),
|
|
3394
|
+
logoShape: pickEnum(
|
|
3395
|
+
root["logoShape"],
|
|
3396
|
+
["square", "rounded", "circle"],
|
|
3397
|
+
dflt.logoShape
|
|
3398
|
+
),
|
|
3399
|
+
logoSize: pickEnum(root["logoSize"], ["sm", "md", "lg"], dflt.logoSize),
|
|
3400
|
+
primary: sHex(root["primary"], dflt.primary),
|
|
3401
|
+
background: sHex(root["background"], dflt.background),
|
|
3402
|
+
surface: sHex(root["surface"], dflt.surface),
|
|
3403
|
+
text: sHex(root["text"], dflt.text),
|
|
3404
|
+
heading: sHex(root["heading"], dflt.heading),
|
|
3405
|
+
muted: sHex(root["muted"], dflt.muted),
|
|
3406
|
+
border: sHex(root["border"], dflt.border),
|
|
3407
|
+
accentText: sHex(root["accentText"], dflt.accentText),
|
|
3408
|
+
buttonBackground: sHex(root["buttonBackground"], dflt.buttonBackground),
|
|
3409
|
+
buttonText: sHex(root["buttonText"], dflt.buttonText),
|
|
3410
|
+
fontFamily: pickEnum(root["fontFamily"], ALL_FONT_FAMILIES, dflt.fontFamily),
|
|
3411
|
+
headingWeight: pickEnum(
|
|
3412
|
+
root["headingWeight"],
|
|
3413
|
+
["regular", "medium", "semibold", "bold"],
|
|
3414
|
+
dflt.headingWeight
|
|
3415
|
+
),
|
|
3416
|
+
radiusSurface: pickEnum(
|
|
3417
|
+
root["radiusSurface"],
|
|
3418
|
+
NON_PILL_RADII,
|
|
3419
|
+
dflt.radiusSurface
|
|
3420
|
+
),
|
|
3421
|
+
radiusInput: pickEnum(root["radiusInput"], NON_PILL_RADII, dflt.radiusInput),
|
|
3422
|
+
radiusButton: pickEnum(root["radiusButton"], ALL_RADII, dflt.radiusButton),
|
|
3423
|
+
radiusBadge: pickEnum(root["radiusBadge"], ALL_RADII, dflt.radiusBadge),
|
|
3424
|
+
surfaceStyle: pickEnum(
|
|
3425
|
+
root["surfaceStyle"],
|
|
3426
|
+
["flat", "outlined", "elevated"],
|
|
3427
|
+
dflt.surfaceStyle
|
|
3428
|
+
),
|
|
3429
|
+
surfacePadding: pickEnum(
|
|
3430
|
+
root["surfacePadding"],
|
|
3431
|
+
["compact", "comfortable", "spacious"],
|
|
3432
|
+
dflt.surfacePadding
|
|
3433
|
+
),
|
|
3434
|
+
verticalGap: pickEnum(
|
|
3435
|
+
root["verticalGap"],
|
|
3436
|
+
["compact", "comfortable", "spacious"],
|
|
3437
|
+
dflt.verticalGap
|
|
3438
|
+
),
|
|
3439
|
+
inputSize: pickEnum(root["inputSize"], ["sm", "md", "lg"], dflt.inputSize),
|
|
3440
|
+
buttonSize: pickEnum(root["buttonSize"], ["sm", "md", "lg"], dflt.buttonSize),
|
|
3441
|
+
layout: pickEnum(root["layout"], ["compact", "split"], dflt.layout),
|
|
3442
|
+
summaryPosition: pickEnum(
|
|
3443
|
+
root["summaryPosition"],
|
|
3444
|
+
["left", "right"],
|
|
3445
|
+
dflt.summaryPosition
|
|
3446
|
+
),
|
|
3447
|
+
showOrderSummary: parseBool(root["showOrderSummary"], dflt.showOrderSummary),
|
|
3448
|
+
summaryGradient: parseBool(root["summaryGradient"], dflt.summaryGradient),
|
|
3449
|
+
showTotal: parseBool(root["showTotal"], dflt.showTotal),
|
|
3450
|
+
totalLabel: sStr(root["totalLabel"], dflt.totalLabel),
|
|
3451
|
+
showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
|
|
3452
|
+
showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
|
|
3453
|
+
trustBadges,
|
|
3454
|
+
headerText: sStr(root["headerText"], dflt.headerText),
|
|
3455
|
+
payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
|
|
3456
|
+
cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
|
|
3457
|
+
footerText: sStr(root["footerText"], dflt.footerText),
|
|
3458
|
+
supportEmail: sStr(root["supportEmail"], dflt.supportEmail),
|
|
3459
|
+
paymentLayout: pickEnum(
|
|
3460
|
+
root["paymentLayout"],
|
|
3461
|
+
["tabs", "accordion", "spaced_accordion"],
|
|
3462
|
+
dflt.paymentLayout
|
|
3463
|
+
),
|
|
3464
|
+
labelStyle,
|
|
3465
|
+
showPoweredBy: parseBool(root["showPoweredBy"], dflt.showPoweredBy),
|
|
3466
|
+
customCss: sStr(root["customCss"], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH)
|
|
3467
|
+
};
|
|
3468
|
+
}
|
|
3469
|
+
function isObject(v) {
|
|
3470
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3471
|
+
}
|
|
3472
|
+
function parseTrustBadgesLoose(raw) {
|
|
3473
|
+
if (!Array.isArray(raw)) return null;
|
|
3474
|
+
return raw.filter(isObject).map((b, i) => ({
|
|
3475
|
+
id: typeof b["id"] === "string" && b["id"] ? b["id"] : `badge-${i}`,
|
|
3476
|
+
label: typeof b["label"] === "string" ? b["label"] : "",
|
|
3477
|
+
textColor: typeof b["textColor"] === "string" && isHexColor(b["textColor"]) ? b["textColor"] : "#0f172a",
|
|
3478
|
+
backgroundColor: typeof b["backgroundColor"] === "string" && isHexColor(b["backgroundColor"]) ? b["backgroundColor"] : "#f1f5f9",
|
|
3479
|
+
borderColor: typeof b["borderColor"] === "string" && isHexColor(b["borderColor"]) ? b["borderColor"] : null
|
|
3480
|
+
})).filter((b) => b.label.length > 0);
|
|
3481
|
+
}
|
|
3482
|
+
function applyBrandingVariables(el, b) {
|
|
3483
|
+
const set = (k, v) => {
|
|
3484
|
+
el.style.setProperty(k, v);
|
|
3485
|
+
};
|
|
3486
|
+
set("--dp-primary", b.primary);
|
|
3487
|
+
set("--dp-bg", b.background);
|
|
3488
|
+
set("--dp-surface", b.surface);
|
|
3489
|
+
set("--dp-text", b.text);
|
|
3490
|
+
set("--dp-heading", b.heading);
|
|
3491
|
+
set("--dp-muted", b.muted);
|
|
3492
|
+
set("--dp-border", b.border);
|
|
3493
|
+
set("--dp-accent-text", b.accentText);
|
|
3494
|
+
set("--dp-btn-bg", b.buttonBackground);
|
|
3495
|
+
set("--dp-btn-fg", b.buttonText);
|
|
3496
|
+
set("--dp-radius-surface", radiusValue(b.radiusSurface));
|
|
3497
|
+
set("--dp-radius-input", radiusValue(b.radiusInput));
|
|
3498
|
+
set("--dp-radius-button", radiusValue(b.radiusButton));
|
|
3499
|
+
set("--dp-radius-badge", radiusValue(b.radiusBadge));
|
|
3500
|
+
set("--dp-font", fontStack(b.fontFamily));
|
|
3501
|
+
set("--dp-heading-weight", fontWeightValue(b.headingWeight));
|
|
3502
|
+
set("--dp-pad-surface", SURFACE_PAD[b.surfacePadding]);
|
|
3503
|
+
set("--dp-gap-vertical", VERTICAL_GAP[b.verticalGap]);
|
|
3504
|
+
set("--dp-input-pad", INPUT_PAD[b.inputSize]);
|
|
3505
|
+
set("--dp-button-pad", BUTTON_PAD[b.buttonSize]);
|
|
3506
|
+
set("--dp-shadow", shadowFor(b.surfaceStyle));
|
|
3507
|
+
set(
|
|
3508
|
+
"--dp-surface-border",
|
|
3509
|
+
b.surfaceStyle === "outlined" ? `1px solid ${b.border}` : "1px solid transparent"
|
|
3510
|
+
);
|
|
3511
|
+
}
|
|
3512
|
+
function shadowFor(style) {
|
|
3513
|
+
switch (style) {
|
|
3514
|
+
case "elevated":
|
|
3515
|
+
return "0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 32px -12px rgba(15, 23, 42, 0.08)";
|
|
3516
|
+
case "outlined":
|
|
3517
|
+
case "flat":
|
|
3518
|
+
default:
|
|
3519
|
+
return "none";
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
|
|
2888
3523
|
export {
|
|
2889
3524
|
DelopayError,
|
|
2890
3525
|
DelopayAuthenticationError,
|
|
@@ -2898,6 +3533,34 @@ export {
|
|
|
2898
3533
|
Forex,
|
|
2899
3534
|
Regions,
|
|
2900
3535
|
Subscriptions,
|
|
2901
|
-
Delopay
|
|
3536
|
+
Delopay,
|
|
3537
|
+
fontStack,
|
|
3538
|
+
radiusValue,
|
|
3539
|
+
fontWeightValue,
|
|
3540
|
+
surfacePadValue,
|
|
3541
|
+
verticalGapValue,
|
|
3542
|
+
inputPadValue,
|
|
3543
|
+
buttonPadValue,
|
|
3544
|
+
logoDimensions,
|
|
3545
|
+
isHexColor,
|
|
3546
|
+
isDarkSurface,
|
|
3547
|
+
DEFAULT_BADGES,
|
|
3548
|
+
DEFAULT_BADGES_DARK,
|
|
3549
|
+
DEFAULT_BRANDING,
|
|
3550
|
+
DEFAULT_BRANDING_DARK,
|
|
3551
|
+
defaultBranding,
|
|
3552
|
+
cloneBranding,
|
|
3553
|
+
CUSTOM_CSS_MAX_LENGTH,
|
|
3554
|
+
sanitizeCustomCss,
|
|
3555
|
+
decodeBadges,
|
|
3556
|
+
encodeBadges,
|
|
3557
|
+
decodeBranding,
|
|
3558
|
+
encodeBranding,
|
|
3559
|
+
BRANDING_EXPORT_FORMAT,
|
|
3560
|
+
BRANDING_EXPORT_VERSION,
|
|
3561
|
+
buildBrandingExport,
|
|
3562
|
+
parseImportedBranding,
|
|
3563
|
+
applyBrandingVariables,
|
|
3564
|
+
shadowFor
|
|
2902
3565
|
};
|
|
2903
|
-
//# sourceMappingURL=chunk-
|
|
3566
|
+
//# sourceMappingURL=chunk-ICBLNJN7.js.map
|