@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
package/dist/index.cjs
CHANGED
|
@@ -20,12 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ALL_CUSTOM_FIELD_TYPES: () => ALL_CUSTOM_FIELD_TYPES,
|
|
23
24
|
Analytics: () => Analytics,
|
|
24
25
|
AnalyticsDashboard: () => AnalyticsDashboard,
|
|
25
26
|
AvailabilityOverrides: () => AvailabilityOverrides,
|
|
26
27
|
BRANDING_EXPORT_FORMAT: () => BRANDING_EXPORT_FORMAT,
|
|
27
28
|
BRANDING_EXPORT_VERSION: () => BRANDING_EXPORT_VERSION,
|
|
28
29
|
CUSTOM_CSS_MAX_LENGTH: () => CUSTOM_CSS_MAX_LENGTH,
|
|
30
|
+
CUSTOM_FIELDS_MAX: () => CUSTOM_FIELDS_MAX,
|
|
31
|
+
CUSTOM_FIELD_KEY_PATTERN: () => CUSTOM_FIELD_KEY_PATTERN,
|
|
29
32
|
Cards: () => Cards,
|
|
30
33
|
DEFAULT_BADGES: () => DEFAULT_BADGES,
|
|
31
34
|
DEFAULT_BADGES_DARK: () => DEFAULT_BADGES_DARK,
|
|
@@ -49,11 +52,16 @@ __export(index_exports, {
|
|
|
49
52
|
buildBrandingExport: () => buildBrandingExport,
|
|
50
53
|
buttonPadValue: () => buttonPadValue,
|
|
51
54
|
cloneBranding: () => cloneBranding,
|
|
55
|
+
cloneCustomField: () => cloneCustomField,
|
|
56
|
+
customFieldOptionLabel: () => customFieldOptionLabel,
|
|
57
|
+
customFieldText: () => customFieldText,
|
|
52
58
|
decodeBadges: () => decodeBadges,
|
|
53
59
|
decodeBranding: () => decodeBranding,
|
|
60
|
+
decodeCustomFields: () => decodeCustomFields,
|
|
54
61
|
defaultBranding: () => defaultBranding,
|
|
55
62
|
encodeBadges: () => encodeBadges,
|
|
56
63
|
encodeBranding: () => encodeBranding,
|
|
64
|
+
encodeCustomFields: () => encodeCustomFields,
|
|
57
65
|
feeProgram: () => feeProgram,
|
|
58
66
|
fontStack: () => fontStack,
|
|
59
67
|
fontWeightValue: () => fontWeightValue,
|
|
@@ -62,6 +70,7 @@ __export(index_exports, {
|
|
|
62
70
|
isHexColor: () => isHexColor,
|
|
63
71
|
leaf: () => leaf,
|
|
64
72
|
logoDimensions: () => logoDimensions,
|
|
73
|
+
parseCustomFieldsLoose: () => parseCustomFieldsLoose,
|
|
65
74
|
parseImportedBranding: () => parseImportedBranding,
|
|
66
75
|
programToTree: () => programToTree,
|
|
67
76
|
radiusValue: () => radiusValue,
|
|
@@ -735,10 +744,14 @@ var Disputes = class {
|
|
|
735
744
|
return this.request("PUT", "/disputes/evidence", { body: params });
|
|
736
745
|
}
|
|
737
746
|
/**
|
|
738
|
-
* Retrieve previously
|
|
747
|
+
* Retrieve previously stored evidence for a dispute.
|
|
748
|
+
*
|
|
749
|
+
* Returns an ARRAY of file-evidence blocks (this was previously mistyped
|
|
750
|
+
* as the flat submit-request shape). Only file evidence is reported —
|
|
751
|
+
* text evidence is not retrievable once submitted.
|
|
739
752
|
*
|
|
740
753
|
* @param disputeId - The dispute ID.
|
|
741
|
-
* @returns The
|
|
754
|
+
* @returns The stored file-evidence blocks.
|
|
742
755
|
*/
|
|
743
756
|
async retrieveEvidence(disputeId) {
|
|
744
757
|
return this.request("GET", `/disputes/evidence/${encodeURIComponent(disputeId)}`);
|
|
@@ -776,16 +789,22 @@ var Disputes = class {
|
|
|
776
789
|
return this.request("GET", "/disputes/profile/aggregate", { query: params });
|
|
777
790
|
}
|
|
778
791
|
/**
|
|
779
|
-
* Fetch the latest dispute state from the connector (gateway).
|
|
780
|
-
* `GET /disputes/{
|
|
792
|
+
* Fetch the latest dispute state from the connector (gateway) and persist it.
|
|
793
|
+
* `GET /disputes/{disputeId}?force_sync=true`
|
|
794
|
+
*
|
|
795
|
+
* The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the
|
|
796
|
+
* backend to pull the dispute from the connector (supported where the connector
|
|
797
|
+
* implements the dispute-sync flow, e.g. Stripe) and update the stored record
|
|
798
|
+
* before returning it.
|
|
781
799
|
*
|
|
782
|
-
* Note:
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
* path were silently hitting 404s.
|
|
800
|
+
* Note: this method previously called `GET /disputes/{id}/fetch`, which is a
|
|
801
|
+
* different backend route — a bulk import keyed by **merchant connector account
|
|
802
|
+
* id** with a required date range — so every call with a dispute id failed.
|
|
786
803
|
*/
|
|
787
|
-
async fetchFromConnector(
|
|
788
|
-
return this.request("GET", `/disputes/${encodeURIComponent(
|
|
804
|
+
async fetchFromConnector(disputeId) {
|
|
805
|
+
return this.request("GET", `/disputes/${encodeURIComponent(disputeId)}`, {
|
|
806
|
+
query: { force_sync: "true" }
|
|
807
|
+
});
|
|
789
808
|
}
|
|
790
809
|
};
|
|
791
810
|
|
|
@@ -3937,7 +3956,8 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
3937
3956
|
var DEFAULT_BRANDING = {
|
|
3938
3957
|
...DEFAULT_BRANDING_BASE,
|
|
3939
3958
|
...LIGHT_PALETTE,
|
|
3940
|
-
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b }))
|
|
3959
|
+
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
|
|
3960
|
+
customFields: []
|
|
3941
3961
|
};
|
|
3942
3962
|
var DEFAULT_BRANDING_DARK = {
|
|
3943
3963
|
...DEFAULT_BRANDING_BASE,
|
|
@@ -3952,13 +3972,27 @@ var DEFAULT_BRANDING_DARK = {
|
|
|
3952
3972
|
buttonBackground: "#1E4FEB",
|
|
3953
3973
|
buttonText: "#ffffff",
|
|
3954
3974
|
surfaceStyle: "flat",
|
|
3955
|
-
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b }))
|
|
3975
|
+
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
|
|
3976
|
+
customFields: []
|
|
3956
3977
|
};
|
|
3957
3978
|
function defaultBranding() {
|
|
3958
3979
|
return cloneBranding(DEFAULT_BRANDING);
|
|
3959
3980
|
}
|
|
3960
3981
|
function cloneBranding(b) {
|
|
3961
|
-
return {
|
|
3982
|
+
return {
|
|
3983
|
+
...b,
|
|
3984
|
+
trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
|
|
3985
|
+
customFields: b.customFields.map(cloneCustomField)
|
|
3986
|
+
};
|
|
3987
|
+
}
|
|
3988
|
+
function cloneCustomField(f) {
|
|
3989
|
+
return {
|
|
3990
|
+
...f,
|
|
3991
|
+
labelTranslations: { ...f.labelTranslations },
|
|
3992
|
+
placeholderTranslations: { ...f.placeholderTranslations },
|
|
3993
|
+
helpTextTranslations: { ...f.helpTextTranslations },
|
|
3994
|
+
options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } }))
|
|
3995
|
+
};
|
|
3962
3996
|
}
|
|
3963
3997
|
var CUSTOM_CSS_MAX_LENGTH = 5e4;
|
|
3964
3998
|
function sanitizeCustomCss(raw) {
|
|
@@ -4036,10 +4070,135 @@ function encodeBadges(badges) {
|
|
|
4036
4070
|
}))
|
|
4037
4071
|
);
|
|
4038
4072
|
}
|
|
4073
|
+
var CUSTOM_FIELDS_MAX = 20;
|
|
4074
|
+
var CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;
|
|
4075
|
+
var ALL_CUSTOM_FIELD_TYPES = [
|
|
4076
|
+
"text",
|
|
4077
|
+
"textarea",
|
|
4078
|
+
"password",
|
|
4079
|
+
"email",
|
|
4080
|
+
"select"
|
|
4081
|
+
];
|
|
4082
|
+
function parseTranslations(raw) {
|
|
4083
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
4084
|
+
const out = {};
|
|
4085
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
4086
|
+
if (typeof v === "string" && v.length > 0) out[k] = v;
|
|
4087
|
+
}
|
|
4088
|
+
return out;
|
|
4089
|
+
}
|
|
4090
|
+
function parseBoundedInt(raw) {
|
|
4091
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
|
|
4092
|
+
if (!Number.isInteger(n) || n < 0) return null;
|
|
4093
|
+
return Math.min(n, 5e3);
|
|
4094
|
+
}
|
|
4095
|
+
function normalizeCustomField(raw, index) {
|
|
4096
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
4097
|
+
const f = raw;
|
|
4098
|
+
const key = typeof f["key"] === "string" ? f["key"].trim() : "";
|
|
4099
|
+
if (!CUSTOM_FIELD_KEY_PATTERN.test(key)) return null;
|
|
4100
|
+
const type = pickEnum(f["type"], ALL_CUSTOM_FIELD_TYPES, "text");
|
|
4101
|
+
const options = type === "select" && Array.isArray(f["options"]) ? f["options"].filter((o) => !!o && typeof o === "object").map((o) => {
|
|
4102
|
+
const value = typeof o["value"] === "string" ? o["value"] : "";
|
|
4103
|
+
return {
|
|
4104
|
+
value,
|
|
4105
|
+
label: typeof o["label"] === "string" && o["label"] ? o["label"] : value,
|
|
4106
|
+
labelTranslations: parseTranslations(o["labelTranslations"])
|
|
4107
|
+
};
|
|
4108
|
+
}).filter((o) => o.value.length > 0) : [];
|
|
4109
|
+
const minLength = parseBoundedInt(f["minLength"]);
|
|
4110
|
+
const maxLength = parseBoundedInt(f["maxLength"]);
|
|
4111
|
+
return {
|
|
4112
|
+
id: typeof f["id"] === "string" && f["id"] ? f["id"] : `field-${index}`,
|
|
4113
|
+
key,
|
|
4114
|
+
type,
|
|
4115
|
+
label: typeof f["label"] === "string" && f["label"] ? f["label"] : key,
|
|
4116
|
+
labelTranslations: parseTranslations(f["labelTranslations"]),
|
|
4117
|
+
placeholder: typeof f["placeholder"] === "string" ? f["placeholder"] : "",
|
|
4118
|
+
placeholderTranslations: parseTranslations(f["placeholderTranslations"]),
|
|
4119
|
+
helpText: typeof f["helpText"] === "string" ? f["helpText"] : "",
|
|
4120
|
+
helpTextTranslations: parseTranslations(f["helpTextTranslations"]),
|
|
4121
|
+
required: parseBool(f["required"], false),
|
|
4122
|
+
enabled: parseBool(f["enabled"], true),
|
|
4123
|
+
minLength,
|
|
4124
|
+
// Guard inverted bounds at decode so consumers never see min > max.
|
|
4125
|
+
maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
|
|
4126
|
+
defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
|
|
4127
|
+
options
|
|
4128
|
+
};
|
|
4129
|
+
}
|
|
4130
|
+
function parseCustomFieldsLoose(raw) {
|
|
4131
|
+
if (!Array.isArray(raw)) return null;
|
|
4132
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4133
|
+
const out = [];
|
|
4134
|
+
for (let i = 0; i < raw.length && out.length < CUSTOM_FIELDS_MAX; i++) {
|
|
4135
|
+
const field = normalizeCustomField(raw[i], i);
|
|
4136
|
+
if (!field || seen.has(field.key)) continue;
|
|
4137
|
+
seen.add(field.key);
|
|
4138
|
+
out.push(field);
|
|
4139
|
+
}
|
|
4140
|
+
return out;
|
|
4141
|
+
}
|
|
4142
|
+
function decodeCustomFields(raw) {
|
|
4143
|
+
if (raw === void 0) return null;
|
|
4144
|
+
try {
|
|
4145
|
+
return parseCustomFieldsLoose(JSON.parse(raw));
|
|
4146
|
+
} catch {
|
|
4147
|
+
return null;
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
function encodeCustomFields(fields) {
|
|
4151
|
+
const nonEmpty = (m) => {
|
|
4152
|
+
const entries = Object.entries(m).filter(([, v]) => v.trim().length > 0);
|
|
4153
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
4154
|
+
};
|
|
4155
|
+
return JSON.stringify(
|
|
4156
|
+
fields.map((f) => ({
|
|
4157
|
+
id: f.id,
|
|
4158
|
+
key: f.key,
|
|
4159
|
+
type: f.type,
|
|
4160
|
+
label: f.label,
|
|
4161
|
+
...nonEmpty(f.labelTranslations) ? { labelTranslations: nonEmpty(f.labelTranslations) } : {},
|
|
4162
|
+
...f.placeholder ? { placeholder: f.placeholder } : {},
|
|
4163
|
+
...nonEmpty(f.placeholderTranslations) ? { placeholderTranslations: nonEmpty(f.placeholderTranslations) } : {},
|
|
4164
|
+
...f.helpText ? { helpText: f.helpText } : {},
|
|
4165
|
+
...nonEmpty(f.helpTextTranslations) ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) } : {},
|
|
4166
|
+
...f.required ? { required: true } : {},
|
|
4167
|
+
...f.enabled ? {} : { enabled: false },
|
|
4168
|
+
...f.minLength !== null ? { minLength: f.minLength } : {},
|
|
4169
|
+
...f.maxLength !== null ? { maxLength: f.maxLength } : {},
|
|
4170
|
+
...f.defaultValue ? { defaultValue: f.defaultValue } : {},
|
|
4171
|
+
...f.type === "select" ? { options: f.options } : {}
|
|
4172
|
+
}))
|
|
4173
|
+
);
|
|
4174
|
+
}
|
|
4175
|
+
function translationFor(map, locale) {
|
|
4176
|
+
if (!locale) return null;
|
|
4177
|
+
const own = (k) => {
|
|
4178
|
+
const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : void 0;
|
|
4179
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
4180
|
+
};
|
|
4181
|
+
const exact = own(locale);
|
|
4182
|
+
if (exact) return exact;
|
|
4183
|
+
const base = locale.split("-")[0];
|
|
4184
|
+
return base && base !== locale ? own(base) : null;
|
|
4185
|
+
}
|
|
4186
|
+
function customFieldText(field, part, locale) {
|
|
4187
|
+
const map = part === "label" ? field.labelTranslations : part === "placeholder" ? field.placeholderTranslations : field.helpTextTranslations;
|
|
4188
|
+
const translated = translationFor(map, locale);
|
|
4189
|
+
if (translated) return translated;
|
|
4190
|
+
const fallback = field[part];
|
|
4191
|
+
if (fallback) return fallback;
|
|
4192
|
+
return part === "label" ? field.key : "";
|
|
4193
|
+
}
|
|
4194
|
+
function customFieldOptionLabel(option, locale) {
|
|
4195
|
+
return translationFor(option.labelTranslations, locale) ?? (option.label || option.value);
|
|
4196
|
+
}
|
|
4039
4197
|
function decodeBranding(source) {
|
|
4040
4198
|
if (!source) return cloneBranding(DEFAULT_BRANDING);
|
|
4041
4199
|
const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
|
|
4042
4200
|
const decodedBadges = decodeBadges(extras["trustBadges"]);
|
|
4201
|
+
const decodedCustomFields = decodeCustomFields(extras["customFields"]);
|
|
4043
4202
|
const displayName = s(source.merchant_name) || s(source.seller_name);
|
|
4044
4203
|
const logoUrl = s(source.merchant_logo) || s(source.logo);
|
|
4045
4204
|
const tagline = s(extras["tagline"]) || s(source.merchant_description);
|
|
@@ -4141,6 +4300,7 @@ function decodeBranding(source) {
|
|
|
4141
4300
|
showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
|
|
4142
4301
|
showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
|
|
4143
4302
|
trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
|
|
4303
|
+
customFields: decodedCustomFields ?? [],
|
|
4144
4304
|
headerText: s(source.payment_form_header_text),
|
|
4145
4305
|
payButtonLabel: s(source.payment_button_text),
|
|
4146
4306
|
cardTermsMessage: s(source.custom_message_for_card_terms),
|
|
@@ -4194,6 +4354,9 @@ function encodeBranding(branding, base) {
|
|
|
4194
4354
|
labelStyle: branding.labelStyle,
|
|
4195
4355
|
trustBadges: encodeBadges(branding.trustBadges)
|
|
4196
4356
|
};
|
|
4357
|
+
if (branding.customFields.length > 0) {
|
|
4358
|
+
extras["customFields"] = encodeCustomFields(branding.customFields);
|
|
4359
|
+
}
|
|
4197
4360
|
const tagline = trim(branding.tagline);
|
|
4198
4361
|
if (tagline) extras["tagline"] = tagline;
|
|
4199
4362
|
const footer = trim(branding.footerText);
|
|
@@ -4244,6 +4407,7 @@ function parseImportedBranding(raw) {
|
|
|
4244
4407
|
const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
|
|
4245
4408
|
const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
|
|
4246
4409
|
const trustBadges = parseTrustBadgesLoose(root["trustBadges"]) ?? dflt.trustBadges.map((b) => ({ ...b }));
|
|
4410
|
+
const customFields = parseCustomFieldsLoose(root["customFields"]) ?? [];
|
|
4247
4411
|
const labelStyle = (() => {
|
|
4248
4412
|
const v = root["labelStyle"];
|
|
4249
4413
|
if (v === "above" || v === "hidden") return v;
|
|
@@ -4314,6 +4478,7 @@ function parseImportedBranding(raw) {
|
|
|
4314
4478
|
showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
|
|
4315
4479
|
showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
|
|
4316
4480
|
trustBadges,
|
|
4481
|
+
customFields,
|
|
4317
4482
|
headerText: sStr(root["headerText"], dflt.headerText),
|
|
4318
4483
|
payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
|
|
4319
4484
|
cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
|
|
@@ -4384,12 +4549,15 @@ function shadowFor(style) {
|
|
|
4384
4549
|
}
|
|
4385
4550
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4386
4551
|
0 && (module.exports = {
|
|
4552
|
+
ALL_CUSTOM_FIELD_TYPES,
|
|
4387
4553
|
Analytics,
|
|
4388
4554
|
AnalyticsDashboard,
|
|
4389
4555
|
AvailabilityOverrides,
|
|
4390
4556
|
BRANDING_EXPORT_FORMAT,
|
|
4391
4557
|
BRANDING_EXPORT_VERSION,
|
|
4392
4558
|
CUSTOM_CSS_MAX_LENGTH,
|
|
4559
|
+
CUSTOM_FIELDS_MAX,
|
|
4560
|
+
CUSTOM_FIELD_KEY_PATTERN,
|
|
4393
4561
|
Cards,
|
|
4394
4562
|
DEFAULT_BADGES,
|
|
4395
4563
|
DEFAULT_BADGES_DARK,
|
|
@@ -4413,11 +4581,16 @@ function shadowFor(style) {
|
|
|
4413
4581
|
buildBrandingExport,
|
|
4414
4582
|
buttonPadValue,
|
|
4415
4583
|
cloneBranding,
|
|
4584
|
+
cloneCustomField,
|
|
4585
|
+
customFieldOptionLabel,
|
|
4586
|
+
customFieldText,
|
|
4416
4587
|
decodeBadges,
|
|
4417
4588
|
decodeBranding,
|
|
4589
|
+
decodeCustomFields,
|
|
4418
4590
|
defaultBranding,
|
|
4419
4591
|
encodeBadges,
|
|
4420
4592
|
encodeBranding,
|
|
4593
|
+
encodeCustomFields,
|
|
4421
4594
|
feeProgram,
|
|
4422
4595
|
fontStack,
|
|
4423
4596
|
fontWeightValue,
|
|
@@ -4426,6 +4599,7 @@ function shadowFor(style) {
|
|
|
4426
4599
|
isHexColor,
|
|
4427
4600
|
leaf,
|
|
4428
4601
|
logoDimensions,
|
|
4602
|
+
parseCustomFieldsLoose,
|
|
4429
4603
|
parseImportedBranding,
|
|
4430
4604
|
programToTree,
|
|
4431
4605
|
radiusValue,
|