@flopay/js 1.3.0 → 1.3.1
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/index.cjs +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -600,6 +600,15 @@ function readString(payload, key) {
|
|
|
600
600
|
const value = payload?.[key];
|
|
601
601
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
602
602
|
}
|
|
603
|
+
function readMessage(payload, key) {
|
|
604
|
+
const value = payload?.[key];
|
|
605
|
+
if (typeof value === "string") return value.trim() ? value : void 0;
|
|
606
|
+
if (Array.isArray(value)) {
|
|
607
|
+
const joined = value.filter((entry) => typeof entry === "string" && entry.trim().length > 0).join("; ");
|
|
608
|
+
return joined || void 0;
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
603
612
|
function readNumber(payload, key) {
|
|
604
613
|
const value = payload?.[key];
|
|
605
614
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
@@ -617,7 +626,7 @@ function createCheckoutProcessingTimeoutError() {
|
|
|
617
626
|
async function buildApiErrorFromResponse(response, fallbackMessage) {
|
|
618
627
|
const payload = await response.json().catch(() => null);
|
|
619
628
|
const nestedError = isRecord(payload?.error) ? payload.error : null;
|
|
620
|
-
const message =
|
|
629
|
+
const message = readMessage(payload, "message") ?? readMessage(nestedError, "message") ?? fallbackMessage;
|
|
621
630
|
const code = readString(payload, "code") ?? readString(payload, "gatewayErrorCode") ?? readString(nestedError, "code") ?? `http_${response.status}`;
|
|
622
631
|
return new FloPayError3(message, "api_error", {
|
|
623
632
|
code,
|