@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 CHANGED
@@ -639,6 +639,15 @@ function readString(payload, key) {
639
639
  const value = payload?.[key];
640
640
  return typeof value === "string" && value.trim() ? value : void 0;
641
641
  }
642
+ function readMessage(payload, key) {
643
+ const value = payload?.[key];
644
+ if (typeof value === "string") return value.trim() ? value : void 0;
645
+ if (Array.isArray(value)) {
646
+ const joined = value.filter((entry) => typeof entry === "string" && entry.trim().length > 0).join("; ");
647
+ return joined || void 0;
648
+ }
649
+ return void 0;
650
+ }
642
651
  function readNumber(payload, key) {
643
652
  const value = payload?.[key];
644
653
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
@@ -656,7 +665,7 @@ function createCheckoutProcessingTimeoutError() {
656
665
  async function buildApiErrorFromResponse(response, fallbackMessage) {
657
666
  const payload = await response.json().catch(() => null);
658
667
  const nestedError = isRecord(payload?.error) ? payload.error : null;
659
- const message = readString(payload, "message") ?? readString(nestedError, "message") ?? fallbackMessage;
668
+ const message = readMessage(payload, "message") ?? readMessage(nestedError, "message") ?? fallbackMessage;
660
669
  const code = readString(payload, "code") ?? readString(payload, "gatewayErrorCode") ?? readString(nestedError, "code") ?? `http_${response.status}`;
661
670
  return new import_shared3.FloPayError(message, "api_error", {
662
671
  code,