@suportepos/split-checkout 0.5.6 → 0.5.7

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.es.js CHANGED
@@ -21839,6 +21839,12 @@ function SplitCheckoutForm({
21839
21839
  }
21840
21840
  }
21841
21841
  };
21842
+ const fieldLabels = {
21843
+ "bp-sop-cardnumber": "Número do cartão",
21844
+ "bp-sop-cardholdername": "Nome como está no cartão",
21845
+ "bp-sop-cardexpirationdat": "Vencimento",
21846
+ "bp-sop-cardcvv": "CVV"
21847
+ };
21842
21848
  const handleFinalSubmit = async () => {
21843
21849
  if (!validateBuyer()) return;
21844
21850
  setLoading(true);
@@ -21884,19 +21890,21 @@ function SplitCheckoutForm({
21884
21890
  onResponse?.(result);
21885
21891
  } catch (err) {
21886
21892
  console.error("Erro chamando backend:", err);
21887
- onResponse?.({ sucesso: false, mensagem: "Erro ao comunicar backend" });
21893
+ onResponse?.({ sucesso: false, mensagem: "100 - Erro ao comunicar backend" });
21888
21894
  } finally {
21889
21895
  setLoading(false);
21890
21896
  }
21891
21897
  },
21892
21898
  onError: (err) => {
21893
- console.error("Erro SOP:", err);
21894
- onResponse?.({ sucesso: false, mensagem: "Erro SOP" });
21899
+ onResponse?.({ sucesso: false, mensagem: "101 - Dados do cartão inválidos. Verifique e tente novamente." });
21895
21900
  setLoading(false);
21896
21901
  },
21897
21902
  onInvalid: (fields) => {
21898
- console.warn("Campos inválidos:", fields);
21899
- onResponse?.({ sucesso: false, mensagem: "Campos inválidos" });
21903
+ const message = `102 - Campos inválidos: ${fields.map((e) => {
21904
+ const label = fieldLabels[e.Field] ?? e.Field;
21905
+ return `${label} - ${e.Message}`;
21906
+ }).join(", ")}`;
21907
+ onResponse?.({ sucesso: false, mensagem: message });
21900
21908
  setLoading(false);
21901
21909
  }
21902
21910
  };