@delopay/sdk 0.69.0 → 0.71.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-XIRQPEI6.js → chunk-RGA6KEKL.js} +179 -14
- package/dist/chunk-RGA6KEKL.js.map +1 -0
- package/dist/index.cjs +187 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -15
- package/dist/index.d.ts +106 -15
- package/dist/index.js +19 -1
- package/dist/internal.cjs +187 -13
- 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 +19 -1
- package/dist/internal.js.map +1 -1
- package/package.json +16 -17
- package/dist/chunk-XIRQPEI6.js.map +0 -1
|
@@ -660,10 +660,14 @@ var Disputes = class {
|
|
|
660
660
|
return this.request("PUT", "/disputes/evidence", { body: params });
|
|
661
661
|
}
|
|
662
662
|
/**
|
|
663
|
-
* Retrieve previously
|
|
663
|
+
* Retrieve previously stored evidence for a dispute.
|
|
664
|
+
*
|
|
665
|
+
* Returns an ARRAY of file-evidence blocks (this was previously mistyped
|
|
666
|
+
* as the flat submit-request shape). Only file evidence is reported —
|
|
667
|
+
* text evidence is not retrievable once submitted.
|
|
664
668
|
*
|
|
665
669
|
* @param disputeId - The dispute ID.
|
|
666
|
-
* @returns The
|
|
670
|
+
* @returns The stored file-evidence blocks.
|
|
667
671
|
*/
|
|
668
672
|
async retrieveEvidence(disputeId) {
|
|
669
673
|
return this.request("GET", `/disputes/evidence/${encodeURIComponent(disputeId)}`);
|
|
@@ -701,16 +705,22 @@ var Disputes = class {
|
|
|
701
705
|
return this.request("GET", "/disputes/profile/aggregate", { query: params });
|
|
702
706
|
}
|
|
703
707
|
/**
|
|
704
|
-
* Fetch the latest dispute state from the connector (gateway).
|
|
705
|
-
* `GET /disputes/{
|
|
708
|
+
* Fetch the latest dispute state from the connector (gateway) and persist it.
|
|
709
|
+
* `GET /disputes/{disputeId}?force_sync=true`
|
|
710
|
+
*
|
|
711
|
+
* The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the
|
|
712
|
+
* backend to pull the dispute from the connector (supported where the connector
|
|
713
|
+
* implements the dispute-sync flow, e.g. Stripe) and update the stored record
|
|
714
|
+
* before returning it.
|
|
706
715
|
*
|
|
707
|
-
* Note:
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
* path were silently hitting 404s.
|
|
716
|
+
* Note: this method previously called `GET /disputes/{id}/fetch`, which is a
|
|
717
|
+
* different backend route — a bulk import keyed by **merchant connector account
|
|
718
|
+
* id** with a required date range — so every call with a dispute id failed.
|
|
711
719
|
*/
|
|
712
|
-
async fetchFromConnector(
|
|
713
|
-
return this.request("GET", `/disputes/${encodeURIComponent(
|
|
720
|
+
async fetchFromConnector(disputeId) {
|
|
721
|
+
return this.request("GET", `/disputes/${encodeURIComponent(disputeId)}`, {
|
|
722
|
+
query: { force_sync: "true" }
|
|
723
|
+
});
|
|
714
724
|
}
|
|
715
725
|
};
|
|
716
726
|
|
|
@@ -3862,7 +3872,8 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
3862
3872
|
var DEFAULT_BRANDING = {
|
|
3863
3873
|
...DEFAULT_BRANDING_BASE,
|
|
3864
3874
|
...LIGHT_PALETTE,
|
|
3865
|
-
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b }))
|
|
3875
|
+
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
|
|
3876
|
+
customFields: []
|
|
3866
3877
|
};
|
|
3867
3878
|
var DEFAULT_BRANDING_DARK = {
|
|
3868
3879
|
...DEFAULT_BRANDING_BASE,
|
|
@@ -3877,13 +3888,27 @@ var DEFAULT_BRANDING_DARK = {
|
|
|
3877
3888
|
buttonBackground: "#1E4FEB",
|
|
3878
3889
|
buttonText: "#ffffff",
|
|
3879
3890
|
surfaceStyle: "flat",
|
|
3880
|
-
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b }))
|
|
3891
|
+
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
|
|
3892
|
+
customFields: []
|
|
3881
3893
|
};
|
|
3882
3894
|
function defaultBranding() {
|
|
3883
3895
|
return cloneBranding(DEFAULT_BRANDING);
|
|
3884
3896
|
}
|
|
3885
3897
|
function cloneBranding(b) {
|
|
3886
|
-
return {
|
|
3898
|
+
return {
|
|
3899
|
+
...b,
|
|
3900
|
+
trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
|
|
3901
|
+
customFields: b.customFields.map(cloneCustomField)
|
|
3902
|
+
};
|
|
3903
|
+
}
|
|
3904
|
+
function cloneCustomField(f) {
|
|
3905
|
+
return {
|
|
3906
|
+
...f,
|
|
3907
|
+
labelTranslations: { ...f.labelTranslations },
|
|
3908
|
+
placeholderTranslations: { ...f.placeholderTranslations },
|
|
3909
|
+
helpTextTranslations: { ...f.helpTextTranslations },
|
|
3910
|
+
options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } }))
|
|
3911
|
+
};
|
|
3887
3912
|
}
|
|
3888
3913
|
var CUSTOM_CSS_MAX_LENGTH = 5e4;
|
|
3889
3914
|
function sanitizeCustomCss(raw) {
|
|
@@ -3961,10 +3986,135 @@ function encodeBadges(badges) {
|
|
|
3961
3986
|
}))
|
|
3962
3987
|
);
|
|
3963
3988
|
}
|
|
3989
|
+
var CUSTOM_FIELDS_MAX = 20;
|
|
3990
|
+
var CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;
|
|
3991
|
+
var ALL_CUSTOM_FIELD_TYPES = [
|
|
3992
|
+
"text",
|
|
3993
|
+
"textarea",
|
|
3994
|
+
"password",
|
|
3995
|
+
"email",
|
|
3996
|
+
"select"
|
|
3997
|
+
];
|
|
3998
|
+
function parseTranslations(raw) {
|
|
3999
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
4000
|
+
const out = {};
|
|
4001
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
4002
|
+
if (typeof v === "string" && v.length > 0) out[k] = v;
|
|
4003
|
+
}
|
|
4004
|
+
return out;
|
|
4005
|
+
}
|
|
4006
|
+
function parseBoundedInt(raw) {
|
|
4007
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
|
|
4008
|
+
if (!Number.isInteger(n) || n < 0) return null;
|
|
4009
|
+
return Math.min(n, 5e3);
|
|
4010
|
+
}
|
|
4011
|
+
function normalizeCustomField(raw, index) {
|
|
4012
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
4013
|
+
const f = raw;
|
|
4014
|
+
const key = typeof f["key"] === "string" ? f["key"].trim() : "";
|
|
4015
|
+
if (!CUSTOM_FIELD_KEY_PATTERN.test(key)) return null;
|
|
4016
|
+
const type = pickEnum(f["type"], ALL_CUSTOM_FIELD_TYPES, "text");
|
|
4017
|
+
const options = type === "select" && Array.isArray(f["options"]) ? f["options"].filter((o) => !!o && typeof o === "object").map((o) => {
|
|
4018
|
+
const value = typeof o["value"] === "string" ? o["value"] : "";
|
|
4019
|
+
return {
|
|
4020
|
+
value,
|
|
4021
|
+
label: typeof o["label"] === "string" && o["label"] ? o["label"] : value,
|
|
4022
|
+
labelTranslations: parseTranslations(o["labelTranslations"])
|
|
4023
|
+
};
|
|
4024
|
+
}).filter((o) => o.value.length > 0) : [];
|
|
4025
|
+
const minLength = parseBoundedInt(f["minLength"]);
|
|
4026
|
+
const maxLength = parseBoundedInt(f["maxLength"]);
|
|
4027
|
+
return {
|
|
4028
|
+
id: typeof f["id"] === "string" && f["id"] ? f["id"] : `field-${index}`,
|
|
4029
|
+
key,
|
|
4030
|
+
type,
|
|
4031
|
+
label: typeof f["label"] === "string" && f["label"] ? f["label"] : key,
|
|
4032
|
+
labelTranslations: parseTranslations(f["labelTranslations"]),
|
|
4033
|
+
placeholder: typeof f["placeholder"] === "string" ? f["placeholder"] : "",
|
|
4034
|
+
placeholderTranslations: parseTranslations(f["placeholderTranslations"]),
|
|
4035
|
+
helpText: typeof f["helpText"] === "string" ? f["helpText"] : "",
|
|
4036
|
+
helpTextTranslations: parseTranslations(f["helpTextTranslations"]),
|
|
4037
|
+
required: parseBool(f["required"], false),
|
|
4038
|
+
enabled: parseBool(f["enabled"], true),
|
|
4039
|
+
minLength,
|
|
4040
|
+
// Guard inverted bounds at decode so consumers never see min > max.
|
|
4041
|
+
maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
|
|
4042
|
+
defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
|
|
4043
|
+
options
|
|
4044
|
+
};
|
|
4045
|
+
}
|
|
4046
|
+
function parseCustomFieldsLoose(raw) {
|
|
4047
|
+
if (!Array.isArray(raw)) return null;
|
|
4048
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4049
|
+
const out = [];
|
|
4050
|
+
for (let i = 0; i < raw.length && out.length < CUSTOM_FIELDS_MAX; i++) {
|
|
4051
|
+
const field = normalizeCustomField(raw[i], i);
|
|
4052
|
+
if (!field || seen.has(field.key)) continue;
|
|
4053
|
+
seen.add(field.key);
|
|
4054
|
+
out.push(field);
|
|
4055
|
+
}
|
|
4056
|
+
return out;
|
|
4057
|
+
}
|
|
4058
|
+
function decodeCustomFields(raw) {
|
|
4059
|
+
if (raw === void 0) return null;
|
|
4060
|
+
try {
|
|
4061
|
+
return parseCustomFieldsLoose(JSON.parse(raw));
|
|
4062
|
+
} catch {
|
|
4063
|
+
return null;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
function encodeCustomFields(fields) {
|
|
4067
|
+
const nonEmpty = (m) => {
|
|
4068
|
+
const entries = Object.entries(m).filter(([, v]) => v.trim().length > 0);
|
|
4069
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
4070
|
+
};
|
|
4071
|
+
return JSON.stringify(
|
|
4072
|
+
fields.map((f) => ({
|
|
4073
|
+
id: f.id,
|
|
4074
|
+
key: f.key,
|
|
4075
|
+
type: f.type,
|
|
4076
|
+
label: f.label,
|
|
4077
|
+
...nonEmpty(f.labelTranslations) ? { labelTranslations: nonEmpty(f.labelTranslations) } : {},
|
|
4078
|
+
...f.placeholder ? { placeholder: f.placeholder } : {},
|
|
4079
|
+
...nonEmpty(f.placeholderTranslations) ? { placeholderTranslations: nonEmpty(f.placeholderTranslations) } : {},
|
|
4080
|
+
...f.helpText ? { helpText: f.helpText } : {},
|
|
4081
|
+
...nonEmpty(f.helpTextTranslations) ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) } : {},
|
|
4082
|
+
...f.required ? { required: true } : {},
|
|
4083
|
+
...f.enabled ? {} : { enabled: false },
|
|
4084
|
+
...f.minLength !== null ? { minLength: f.minLength } : {},
|
|
4085
|
+
...f.maxLength !== null ? { maxLength: f.maxLength } : {},
|
|
4086
|
+
...f.defaultValue ? { defaultValue: f.defaultValue } : {},
|
|
4087
|
+
...f.type === "select" ? { options: f.options } : {}
|
|
4088
|
+
}))
|
|
4089
|
+
);
|
|
4090
|
+
}
|
|
4091
|
+
function translationFor(map, locale) {
|
|
4092
|
+
if (!locale) return null;
|
|
4093
|
+
const own = (k) => {
|
|
4094
|
+
const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : void 0;
|
|
4095
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
4096
|
+
};
|
|
4097
|
+
const exact = own(locale);
|
|
4098
|
+
if (exact) return exact;
|
|
4099
|
+
const base = locale.split("-")[0];
|
|
4100
|
+
return base && base !== locale ? own(base) : null;
|
|
4101
|
+
}
|
|
4102
|
+
function customFieldText(field, part, locale) {
|
|
4103
|
+
const map = part === "label" ? field.labelTranslations : part === "placeholder" ? field.placeholderTranslations : field.helpTextTranslations;
|
|
4104
|
+
const translated = translationFor(map, locale);
|
|
4105
|
+
if (translated) return translated;
|
|
4106
|
+
const fallback = field[part];
|
|
4107
|
+
if (fallback) return fallback;
|
|
4108
|
+
return part === "label" ? field.key : "";
|
|
4109
|
+
}
|
|
4110
|
+
function customFieldOptionLabel(option, locale) {
|
|
4111
|
+
return translationFor(option.labelTranslations, locale) ?? (option.label || option.value);
|
|
4112
|
+
}
|
|
3964
4113
|
function decodeBranding(source) {
|
|
3965
4114
|
if (!source) return cloneBranding(DEFAULT_BRANDING);
|
|
3966
4115
|
const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
|
|
3967
4116
|
const decodedBadges = decodeBadges(extras["trustBadges"]);
|
|
4117
|
+
const decodedCustomFields = decodeCustomFields(extras["customFields"]);
|
|
3968
4118
|
const displayName = s(source.merchant_name) || s(source.seller_name);
|
|
3969
4119
|
const logoUrl = s(source.merchant_logo) || s(source.logo);
|
|
3970
4120
|
const tagline = s(extras["tagline"]) || s(source.merchant_description);
|
|
@@ -4066,6 +4216,7 @@ function decodeBranding(source) {
|
|
|
4066
4216
|
showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
|
|
4067
4217
|
showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
|
|
4068
4218
|
trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
|
|
4219
|
+
customFields: decodedCustomFields ?? [],
|
|
4069
4220
|
headerText: s(source.payment_form_header_text),
|
|
4070
4221
|
payButtonLabel: s(source.payment_button_text),
|
|
4071
4222
|
cardTermsMessage: s(source.custom_message_for_card_terms),
|
|
@@ -4119,6 +4270,9 @@ function encodeBranding(branding, base) {
|
|
|
4119
4270
|
labelStyle: branding.labelStyle,
|
|
4120
4271
|
trustBadges: encodeBadges(branding.trustBadges)
|
|
4121
4272
|
};
|
|
4273
|
+
if (branding.customFields.length > 0) {
|
|
4274
|
+
extras["customFields"] = encodeCustomFields(branding.customFields);
|
|
4275
|
+
}
|
|
4122
4276
|
const tagline = trim(branding.tagline);
|
|
4123
4277
|
if (tagline) extras["tagline"] = tagline;
|
|
4124
4278
|
const footer = trim(branding.footerText);
|
|
@@ -4169,6 +4323,7 @@ function parseImportedBranding(raw) {
|
|
|
4169
4323
|
const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
|
|
4170
4324
|
const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
|
|
4171
4325
|
const trustBadges = parseTrustBadgesLoose(root["trustBadges"]) ?? dflt.trustBadges.map((b) => ({ ...b }));
|
|
4326
|
+
const customFields = parseCustomFieldsLoose(root["customFields"]) ?? [];
|
|
4172
4327
|
const labelStyle = (() => {
|
|
4173
4328
|
const v = root["labelStyle"];
|
|
4174
4329
|
if (v === "above" || v === "hidden") return v;
|
|
@@ -4239,6 +4394,7 @@ function parseImportedBranding(raw) {
|
|
|
4239
4394
|
showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
|
|
4240
4395
|
showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
|
|
4241
4396
|
trustBadges,
|
|
4397
|
+
customFields,
|
|
4242
4398
|
headerText: sStr(root["headerText"], dflt.headerText),
|
|
4243
4399
|
payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
|
|
4244
4400
|
cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
|
|
@@ -4347,10 +4503,19 @@ export {
|
|
|
4347
4503
|
DEFAULT_BRANDING_DARK,
|
|
4348
4504
|
defaultBranding,
|
|
4349
4505
|
cloneBranding,
|
|
4506
|
+
cloneCustomField,
|
|
4350
4507
|
CUSTOM_CSS_MAX_LENGTH,
|
|
4351
4508
|
sanitizeCustomCss,
|
|
4352
4509
|
decodeBadges,
|
|
4353
4510
|
encodeBadges,
|
|
4511
|
+
CUSTOM_FIELDS_MAX,
|
|
4512
|
+
CUSTOM_FIELD_KEY_PATTERN,
|
|
4513
|
+
ALL_CUSTOM_FIELD_TYPES,
|
|
4514
|
+
parseCustomFieldsLoose,
|
|
4515
|
+
decodeCustomFields,
|
|
4516
|
+
encodeCustomFields,
|
|
4517
|
+
customFieldText,
|
|
4518
|
+
customFieldOptionLabel,
|
|
4354
4519
|
decodeBranding,
|
|
4355
4520
|
encodeBranding,
|
|
4356
4521
|
BRANDING_EXPORT_FORMAT,
|
|
@@ -4360,4 +4525,4 @@ export {
|
|
|
4360
4525
|
applyBrandingVariables,
|
|
4361
4526
|
shadowFor
|
|
4362
4527
|
};
|
|
4363
|
-
//# sourceMappingURL=chunk-
|
|
4528
|
+
//# sourceMappingURL=chunk-RGA6KEKL.js.map
|