@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/internal.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/internal.ts
|
|
21
21
|
var internal_exports = {};
|
|
22
22
|
__export(internal_exports, {
|
|
23
|
+
ALL_CUSTOM_FIELD_TYPES: () => ALL_CUSTOM_FIELD_TYPES,
|
|
23
24
|
Admin: () => Admin,
|
|
24
25
|
AdminPortal: () => AdminPortal,
|
|
25
26
|
Analytics: () => Analytics,
|
|
@@ -29,6 +30,8 @@ __export(internal_exports, {
|
|
|
29
30
|
BRANDING_EXPORT_FORMAT: () => BRANDING_EXPORT_FORMAT,
|
|
30
31
|
BRANDING_EXPORT_VERSION: () => BRANDING_EXPORT_VERSION,
|
|
31
32
|
CUSTOM_CSS_MAX_LENGTH: () => CUSTOM_CSS_MAX_LENGTH,
|
|
33
|
+
CUSTOM_FIELDS_MAX: () => CUSTOM_FIELDS_MAX,
|
|
34
|
+
CUSTOM_FIELD_KEY_PATTERN: () => CUSTOM_FIELD_KEY_PATTERN,
|
|
32
35
|
Cache: () => Cache,
|
|
33
36
|
CardIssuers: () => CardIssuers,
|
|
34
37
|
Cards: () => Cards,
|
|
@@ -61,11 +64,16 @@ __export(internal_exports, {
|
|
|
61
64
|
buildBrandingExport: () => buildBrandingExport,
|
|
62
65
|
buttonPadValue: () => buttonPadValue,
|
|
63
66
|
cloneBranding: () => cloneBranding,
|
|
67
|
+
cloneCustomField: () => cloneCustomField,
|
|
68
|
+
customFieldOptionLabel: () => customFieldOptionLabel,
|
|
69
|
+
customFieldText: () => customFieldText,
|
|
64
70
|
decodeBadges: () => decodeBadges,
|
|
65
71
|
decodeBranding: () => decodeBranding,
|
|
72
|
+
decodeCustomFields: () => decodeCustomFields,
|
|
66
73
|
defaultBranding: () => defaultBranding,
|
|
67
74
|
encodeBadges: () => encodeBadges,
|
|
68
75
|
encodeBranding: () => encodeBranding,
|
|
76
|
+
encodeCustomFields: () => encodeCustomFields,
|
|
69
77
|
feeProgram: () => feeProgram,
|
|
70
78
|
fontStack: () => fontStack,
|
|
71
79
|
fontWeightValue: () => fontWeightValue,
|
|
@@ -74,6 +82,7 @@ __export(internal_exports, {
|
|
|
74
82
|
isHexColor: () => isHexColor,
|
|
75
83
|
leaf: () => leaf,
|
|
76
84
|
logoDimensions: () => logoDimensions,
|
|
85
|
+
parseCustomFieldsLoose: () => parseCustomFieldsLoose,
|
|
77
86
|
parseImportedBranding: () => parseImportedBranding,
|
|
78
87
|
programToTree: () => programToTree,
|
|
79
88
|
radiusValue: () => radiusValue,
|
|
@@ -747,10 +756,14 @@ var Disputes = class {
|
|
|
747
756
|
return this.request("PUT", "/disputes/evidence", { body: params });
|
|
748
757
|
}
|
|
749
758
|
/**
|
|
750
|
-
* Retrieve previously
|
|
759
|
+
* Retrieve previously stored evidence for a dispute.
|
|
760
|
+
*
|
|
761
|
+
* Returns an ARRAY of file-evidence blocks (this was previously mistyped
|
|
762
|
+
* as the flat submit-request shape). Only file evidence is reported —
|
|
763
|
+
* text evidence is not retrievable once submitted.
|
|
751
764
|
*
|
|
752
765
|
* @param disputeId - The dispute ID.
|
|
753
|
-
* @returns The
|
|
766
|
+
* @returns The stored file-evidence blocks.
|
|
754
767
|
*/
|
|
755
768
|
async retrieveEvidence(disputeId) {
|
|
756
769
|
return this.request("GET", `/disputes/evidence/${encodeURIComponent(disputeId)}`);
|
|
@@ -788,16 +801,22 @@ var Disputes = class {
|
|
|
788
801
|
return this.request("GET", "/disputes/profile/aggregate", { query: params });
|
|
789
802
|
}
|
|
790
803
|
/**
|
|
791
|
-
* Fetch the latest dispute state from the connector (gateway).
|
|
792
|
-
* `GET /disputes/{
|
|
804
|
+
* Fetch the latest dispute state from the connector (gateway) and persist it.
|
|
805
|
+
* `GET /disputes/{disputeId}?force_sync=true`
|
|
806
|
+
*
|
|
807
|
+
* The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the
|
|
808
|
+
* backend to pull the dispute from the connector (supported where the connector
|
|
809
|
+
* implements the dispute-sync flow, e.g. Stripe) and update the stored record
|
|
810
|
+
* before returning it.
|
|
793
811
|
*
|
|
794
|
-
* Note:
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
* path were silently hitting 404s.
|
|
812
|
+
* Note: this method previously called `GET /disputes/{id}/fetch`, which is a
|
|
813
|
+
* different backend route — a bulk import keyed by **merchant connector account
|
|
814
|
+
* id** with a required date range — so every call with a dispute id failed.
|
|
798
815
|
*/
|
|
799
|
-
async fetchFromConnector(
|
|
800
|
-
return this.request("GET", `/disputes/${encodeURIComponent(
|
|
816
|
+
async fetchFromConnector(disputeId) {
|
|
817
|
+
return this.request("GET", `/disputes/${encodeURIComponent(disputeId)}`, {
|
|
818
|
+
query: { force_sync: "true" }
|
|
819
|
+
});
|
|
801
820
|
}
|
|
802
821
|
};
|
|
803
822
|
|
|
@@ -3949,7 +3968,8 @@ var DEFAULT_BRANDING_BASE = {
|
|
|
3949
3968
|
var DEFAULT_BRANDING = {
|
|
3950
3969
|
...DEFAULT_BRANDING_BASE,
|
|
3951
3970
|
...LIGHT_PALETTE,
|
|
3952
|
-
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b }))
|
|
3971
|
+
trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),
|
|
3972
|
+
customFields: []
|
|
3953
3973
|
};
|
|
3954
3974
|
var DEFAULT_BRANDING_DARK = {
|
|
3955
3975
|
...DEFAULT_BRANDING_BASE,
|
|
@@ -3964,13 +3984,27 @@ var DEFAULT_BRANDING_DARK = {
|
|
|
3964
3984
|
buttonBackground: "#1E4FEB",
|
|
3965
3985
|
buttonText: "#ffffff",
|
|
3966
3986
|
surfaceStyle: "flat",
|
|
3967
|
-
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b }))
|
|
3987
|
+
trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),
|
|
3988
|
+
customFields: []
|
|
3968
3989
|
};
|
|
3969
3990
|
function defaultBranding() {
|
|
3970
3991
|
return cloneBranding(DEFAULT_BRANDING);
|
|
3971
3992
|
}
|
|
3972
3993
|
function cloneBranding(b) {
|
|
3973
|
-
return {
|
|
3994
|
+
return {
|
|
3995
|
+
...b,
|
|
3996
|
+
trustBadges: b.trustBadges.map((badge) => ({ ...badge })),
|
|
3997
|
+
customFields: b.customFields.map(cloneCustomField)
|
|
3998
|
+
};
|
|
3999
|
+
}
|
|
4000
|
+
function cloneCustomField(f) {
|
|
4001
|
+
return {
|
|
4002
|
+
...f,
|
|
4003
|
+
labelTranslations: { ...f.labelTranslations },
|
|
4004
|
+
placeholderTranslations: { ...f.placeholderTranslations },
|
|
4005
|
+
helpTextTranslations: { ...f.helpTextTranslations },
|
|
4006
|
+
options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } }))
|
|
4007
|
+
};
|
|
3974
4008
|
}
|
|
3975
4009
|
var CUSTOM_CSS_MAX_LENGTH = 5e4;
|
|
3976
4010
|
function sanitizeCustomCss(raw) {
|
|
@@ -4048,10 +4082,135 @@ function encodeBadges(badges) {
|
|
|
4048
4082
|
}))
|
|
4049
4083
|
);
|
|
4050
4084
|
}
|
|
4085
|
+
var CUSTOM_FIELDS_MAX = 20;
|
|
4086
|
+
var CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;
|
|
4087
|
+
var ALL_CUSTOM_FIELD_TYPES = [
|
|
4088
|
+
"text",
|
|
4089
|
+
"textarea",
|
|
4090
|
+
"password",
|
|
4091
|
+
"email",
|
|
4092
|
+
"select"
|
|
4093
|
+
];
|
|
4094
|
+
function parseTranslations(raw) {
|
|
4095
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
4096
|
+
const out = {};
|
|
4097
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
4098
|
+
if (typeof v === "string" && v.length > 0) out[k] = v;
|
|
4099
|
+
}
|
|
4100
|
+
return out;
|
|
4101
|
+
}
|
|
4102
|
+
function parseBoundedInt(raw) {
|
|
4103
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
|
|
4104
|
+
if (!Number.isInteger(n) || n < 0) return null;
|
|
4105
|
+
return Math.min(n, 5e3);
|
|
4106
|
+
}
|
|
4107
|
+
function normalizeCustomField(raw, index) {
|
|
4108
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
4109
|
+
const f = raw;
|
|
4110
|
+
const key = typeof f["key"] === "string" ? f["key"].trim() : "";
|
|
4111
|
+
if (!CUSTOM_FIELD_KEY_PATTERN.test(key)) return null;
|
|
4112
|
+
const type = pickEnum(f["type"], ALL_CUSTOM_FIELD_TYPES, "text");
|
|
4113
|
+
const options = type === "select" && Array.isArray(f["options"]) ? f["options"].filter((o) => !!o && typeof o === "object").map((o) => {
|
|
4114
|
+
const value = typeof o["value"] === "string" ? o["value"] : "";
|
|
4115
|
+
return {
|
|
4116
|
+
value,
|
|
4117
|
+
label: typeof o["label"] === "string" && o["label"] ? o["label"] : value,
|
|
4118
|
+
labelTranslations: parseTranslations(o["labelTranslations"])
|
|
4119
|
+
};
|
|
4120
|
+
}).filter((o) => o.value.length > 0) : [];
|
|
4121
|
+
const minLength = parseBoundedInt(f["minLength"]);
|
|
4122
|
+
const maxLength = parseBoundedInt(f["maxLength"]);
|
|
4123
|
+
return {
|
|
4124
|
+
id: typeof f["id"] === "string" && f["id"] ? f["id"] : `field-${index}`,
|
|
4125
|
+
key,
|
|
4126
|
+
type,
|
|
4127
|
+
label: typeof f["label"] === "string" && f["label"] ? f["label"] : key,
|
|
4128
|
+
labelTranslations: parseTranslations(f["labelTranslations"]),
|
|
4129
|
+
placeholder: typeof f["placeholder"] === "string" ? f["placeholder"] : "",
|
|
4130
|
+
placeholderTranslations: parseTranslations(f["placeholderTranslations"]),
|
|
4131
|
+
helpText: typeof f["helpText"] === "string" ? f["helpText"] : "",
|
|
4132
|
+
helpTextTranslations: parseTranslations(f["helpTextTranslations"]),
|
|
4133
|
+
required: parseBool(f["required"], false),
|
|
4134
|
+
enabled: parseBool(f["enabled"], true),
|
|
4135
|
+
minLength,
|
|
4136
|
+
// Guard inverted bounds at decode so consumers never see min > max.
|
|
4137
|
+
maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,
|
|
4138
|
+
defaultValue: typeof f["defaultValue"] === "string" ? f["defaultValue"] : "",
|
|
4139
|
+
options
|
|
4140
|
+
};
|
|
4141
|
+
}
|
|
4142
|
+
function parseCustomFieldsLoose(raw) {
|
|
4143
|
+
if (!Array.isArray(raw)) return null;
|
|
4144
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4145
|
+
const out = [];
|
|
4146
|
+
for (let i = 0; i < raw.length && out.length < CUSTOM_FIELDS_MAX; i++) {
|
|
4147
|
+
const field = normalizeCustomField(raw[i], i);
|
|
4148
|
+
if (!field || seen.has(field.key)) continue;
|
|
4149
|
+
seen.add(field.key);
|
|
4150
|
+
out.push(field);
|
|
4151
|
+
}
|
|
4152
|
+
return out;
|
|
4153
|
+
}
|
|
4154
|
+
function decodeCustomFields(raw) {
|
|
4155
|
+
if (raw === void 0) return null;
|
|
4156
|
+
try {
|
|
4157
|
+
return parseCustomFieldsLoose(JSON.parse(raw));
|
|
4158
|
+
} catch {
|
|
4159
|
+
return null;
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
function encodeCustomFields(fields) {
|
|
4163
|
+
const nonEmpty = (m) => {
|
|
4164
|
+
const entries = Object.entries(m).filter(([, v]) => v.trim().length > 0);
|
|
4165
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
4166
|
+
};
|
|
4167
|
+
return JSON.stringify(
|
|
4168
|
+
fields.map((f) => ({
|
|
4169
|
+
id: f.id,
|
|
4170
|
+
key: f.key,
|
|
4171
|
+
type: f.type,
|
|
4172
|
+
label: f.label,
|
|
4173
|
+
...nonEmpty(f.labelTranslations) ? { labelTranslations: nonEmpty(f.labelTranslations) } : {},
|
|
4174
|
+
...f.placeholder ? { placeholder: f.placeholder } : {},
|
|
4175
|
+
...nonEmpty(f.placeholderTranslations) ? { placeholderTranslations: nonEmpty(f.placeholderTranslations) } : {},
|
|
4176
|
+
...f.helpText ? { helpText: f.helpText } : {},
|
|
4177
|
+
...nonEmpty(f.helpTextTranslations) ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) } : {},
|
|
4178
|
+
...f.required ? { required: true } : {},
|
|
4179
|
+
...f.enabled ? {} : { enabled: false },
|
|
4180
|
+
...f.minLength !== null ? { minLength: f.minLength } : {},
|
|
4181
|
+
...f.maxLength !== null ? { maxLength: f.maxLength } : {},
|
|
4182
|
+
...f.defaultValue ? { defaultValue: f.defaultValue } : {},
|
|
4183
|
+
...f.type === "select" ? { options: f.options } : {}
|
|
4184
|
+
}))
|
|
4185
|
+
);
|
|
4186
|
+
}
|
|
4187
|
+
function translationFor(map, locale) {
|
|
4188
|
+
if (!locale) return null;
|
|
4189
|
+
const own = (k) => {
|
|
4190
|
+
const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : void 0;
|
|
4191
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
4192
|
+
};
|
|
4193
|
+
const exact = own(locale);
|
|
4194
|
+
if (exact) return exact;
|
|
4195
|
+
const base = locale.split("-")[0];
|
|
4196
|
+
return base && base !== locale ? own(base) : null;
|
|
4197
|
+
}
|
|
4198
|
+
function customFieldText(field, part, locale) {
|
|
4199
|
+
const map = part === "label" ? field.labelTranslations : part === "placeholder" ? field.placeholderTranslations : field.helpTextTranslations;
|
|
4200
|
+
const translated = translationFor(map, locale);
|
|
4201
|
+
if (translated) return translated;
|
|
4202
|
+
const fallback = field[part];
|
|
4203
|
+
if (fallback) return fallback;
|
|
4204
|
+
return part === "label" ? field.key : "";
|
|
4205
|
+
}
|
|
4206
|
+
function customFieldOptionLabel(option, locale) {
|
|
4207
|
+
return translationFor(option.labelTranslations, locale) ?? (option.label || option.value);
|
|
4208
|
+
}
|
|
4051
4209
|
function decodeBranding(source) {
|
|
4052
4210
|
if (!source) return cloneBranding(DEFAULT_BRANDING);
|
|
4053
4211
|
const extras = source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ?? {};
|
|
4054
4212
|
const decodedBadges = decodeBadges(extras["trustBadges"]);
|
|
4213
|
+
const decodedCustomFields = decodeCustomFields(extras["customFields"]);
|
|
4055
4214
|
const displayName = s(source.merchant_name) || s(source.seller_name);
|
|
4056
4215
|
const logoUrl = s(source.merchant_logo) || s(source.logo);
|
|
4057
4216
|
const tagline = s(extras["tagline"]) || s(source.merchant_description);
|
|
@@ -4153,6 +4312,7 @@ function decodeBranding(source) {
|
|
|
4153
4312
|
showCurrencyCode: parseBool(extras["showCurrencyCode"], DEFAULT_BRANDING.showCurrencyCode),
|
|
4154
4313
|
showOrderItems: parseBool(extras["showOrderItems"], DEFAULT_BRANDING.showOrderItems),
|
|
4155
4314
|
trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),
|
|
4315
|
+
customFields: decodedCustomFields ?? [],
|
|
4156
4316
|
headerText: s(source.payment_form_header_text),
|
|
4157
4317
|
payButtonLabel: s(source.payment_button_text),
|
|
4158
4318
|
cardTermsMessage: s(source.custom_message_for_card_terms),
|
|
@@ -4206,6 +4366,9 @@ function encodeBranding(branding, base) {
|
|
|
4206
4366
|
labelStyle: branding.labelStyle,
|
|
4207
4367
|
trustBadges: encodeBadges(branding.trustBadges)
|
|
4208
4368
|
};
|
|
4369
|
+
if (branding.customFields.length > 0) {
|
|
4370
|
+
extras["customFields"] = encodeCustomFields(branding.customFields);
|
|
4371
|
+
}
|
|
4209
4372
|
const tagline = trim(branding.tagline);
|
|
4210
4373
|
if (tagline) extras["tagline"] = tagline;
|
|
4211
4374
|
const footer = trim(branding.footerText);
|
|
@@ -4256,6 +4419,7 @@ function parseImportedBranding(raw) {
|
|
|
4256
4419
|
const sStr = (v, fallback) => typeof v === "string" ? v : fallback;
|
|
4257
4420
|
const sHex = (v, fallback) => typeof v === "string" && isHexColor(v) ? v : fallback;
|
|
4258
4421
|
const trustBadges = parseTrustBadgesLoose(root["trustBadges"]) ?? dflt.trustBadges.map((b) => ({ ...b }));
|
|
4422
|
+
const customFields = parseCustomFieldsLoose(root["customFields"]) ?? [];
|
|
4259
4423
|
const labelStyle = (() => {
|
|
4260
4424
|
const v = root["labelStyle"];
|
|
4261
4425
|
if (v === "above" || v === "hidden") return v;
|
|
@@ -4326,6 +4490,7 @@ function parseImportedBranding(raw) {
|
|
|
4326
4490
|
showCurrencyCode: parseBool(root["showCurrencyCode"], dflt.showCurrencyCode),
|
|
4327
4491
|
showOrderItems: parseBool(root["showOrderItems"], dflt.showOrderItems),
|
|
4328
4492
|
trustBadges,
|
|
4493
|
+
customFields,
|
|
4329
4494
|
headerText: sStr(root["headerText"], dflt.headerText),
|
|
4330
4495
|
payButtonLabel: sStr(root["payButtonLabel"], dflt.payButtonLabel),
|
|
4331
4496
|
cardTermsMessage: sStr(root["cardTermsMessage"], dflt.cardTermsMessage),
|
|
@@ -4959,6 +5124,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
4959
5124
|
};
|
|
4960
5125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4961
5126
|
0 && (module.exports = {
|
|
5127
|
+
ALL_CUSTOM_FIELD_TYPES,
|
|
4962
5128
|
Admin,
|
|
4963
5129
|
AdminPortal,
|
|
4964
5130
|
Analytics,
|
|
@@ -4968,6 +5134,8 @@ var DelopayInternal = class extends Delopay {
|
|
|
4968
5134
|
BRANDING_EXPORT_FORMAT,
|
|
4969
5135
|
BRANDING_EXPORT_VERSION,
|
|
4970
5136
|
CUSTOM_CSS_MAX_LENGTH,
|
|
5137
|
+
CUSTOM_FIELDS_MAX,
|
|
5138
|
+
CUSTOM_FIELD_KEY_PATTERN,
|
|
4971
5139
|
Cache,
|
|
4972
5140
|
CardIssuers,
|
|
4973
5141
|
Cards,
|
|
@@ -5000,11 +5168,16 @@ var DelopayInternal = class extends Delopay {
|
|
|
5000
5168
|
buildBrandingExport,
|
|
5001
5169
|
buttonPadValue,
|
|
5002
5170
|
cloneBranding,
|
|
5171
|
+
cloneCustomField,
|
|
5172
|
+
customFieldOptionLabel,
|
|
5173
|
+
customFieldText,
|
|
5003
5174
|
decodeBadges,
|
|
5004
5175
|
decodeBranding,
|
|
5176
|
+
decodeCustomFields,
|
|
5005
5177
|
defaultBranding,
|
|
5006
5178
|
encodeBadges,
|
|
5007
5179
|
encodeBranding,
|
|
5180
|
+
encodeCustomFields,
|
|
5008
5181
|
feeProgram,
|
|
5009
5182
|
fontStack,
|
|
5010
5183
|
fontWeightValue,
|
|
@@ -5013,6 +5186,7 @@ var DelopayInternal = class extends Delopay {
|
|
|
5013
5186
|
isHexColor,
|
|
5014
5187
|
leaf,
|
|
5015
5188
|
logoDimensions,
|
|
5189
|
+
parseCustomFieldsLoose,
|
|
5016
5190
|
parseImportedBranding,
|
|
5017
5191
|
programToTree,
|
|
5018
5192
|
radiusValue,
|