@suportepos/split-checkout 0.5.6 → 0.5.8

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
@@ -21698,7 +21698,8 @@ function SplitCheckoutForm({
21698
21698
  uuid,
21699
21699
  resumo,
21700
21700
  parcelas,
21701
- urlApi
21701
+ urlApi,
21702
+ voltar
21702
21703
  }) {
21703
21704
  const [step, setStep] = useState("card");
21704
21705
  const maskCard = (v) => v.replace(/\D/g, "").trim();
@@ -21839,6 +21840,12 @@ function SplitCheckoutForm({
21839
21840
  }
21840
21841
  }
21841
21842
  };
21843
+ const fieldLabels = {
21844
+ "bp-sop-cardnumber": "Número do cartão",
21845
+ "bp-sop-cardholdername": "Nome como está no cartão",
21846
+ "bp-sop-cardexpirationdat": "Vencimento",
21847
+ "bp-sop-cardcvv": "CVV"
21848
+ };
21842
21849
  const handleFinalSubmit = async () => {
21843
21850
  if (!validateBuyer()) return;
21844
21851
  setLoading(true);
@@ -21884,19 +21891,21 @@ function SplitCheckoutForm({
21884
21891
  onResponse?.(result);
21885
21892
  } catch (err) {
21886
21893
  console.error("Erro chamando backend:", err);
21887
- onResponse?.({ sucesso: false, mensagem: "Erro ao comunicar backend" });
21894
+ onResponse?.({ sucesso: false, mensagem: "100 - Erro ao comunicar backend" });
21888
21895
  } finally {
21889
21896
  setLoading(false);
21890
21897
  }
21891
21898
  },
21892
21899
  onError: (err) => {
21893
- console.error("Erro SOP:", err);
21894
- onResponse?.({ sucesso: false, mensagem: "Erro SOP" });
21900
+ onResponse?.({ sucesso: false, mensagem: "101 - Dados do cartão inválidos. Verifique e tente novamente." });
21895
21901
  setLoading(false);
21896
21902
  },
21897
21903
  onInvalid: (fields) => {
21898
- console.warn("Campos inválidos:", fields);
21899
- onResponse?.({ sucesso: false, mensagem: "Campos inválidos" });
21904
+ const message = `102 - Campos inválidos: ${fields.map((e) => {
21905
+ const label = fieldLabels[e.Field] ?? e.Field;
21906
+ return `${label} - ${e.Message}`;
21907
+ }).join(", ")}`;
21908
+ onResponse?.({ sucesso: false, mensagem: message });
21900
21909
  setLoading(false);
21901
21910
  }
21902
21911
  };
@@ -21993,7 +22002,7 @@ function SplitCheckoutForm({
21993
22002
  ] }),
21994
22003
  /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", className: "bp-sop-cardtype", value: "CreditCard" }),
21995
22004
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, sx: { mt: 1 }, children: [
21996
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22005
+ voltar && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
21997
22006
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "contained", onClick: nextFromCard, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Continuar" })
21998
22007
  ] })
21999
22008
  ] })
@@ -22204,7 +22213,8 @@ function SplitPixForm({
22204
22213
  onResponse,
22205
22214
  uuid,
22206
22215
  resumo,
22207
- urlApi
22216
+ urlApi,
22217
+ voltar
22208
22218
  }) {
22209
22219
  useMediaQuery("(max-width:900px)");
22210
22220
  const [copied, setCopied] = useState(false);
@@ -22352,7 +22362,7 @@ function SplitPixForm({
22352
22362
  }
22353
22363
  ),
22354
22364
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, children: [
22355
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22365
+ voltar && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22356
22366
  /* @__PURE__ */ jsxRuntimeExports.jsx(
22357
22367
  Button,
22358
22368
  {
@@ -22436,7 +22446,7 @@ function SplitPixForm({
22436
22446
  ),
22437
22447
  /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, { sx: { my: 2 } }),
22438
22448
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, children: [
22439
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22449
+ voltar && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22440
22450
  /* @__PURE__ */ jsxRuntimeExports.jsx(
22441
22451
  Button,
22442
22452
  {
@@ -22475,7 +22485,8 @@ function CheckoutFlowContent({
22475
22485
  onResponse,
22476
22486
  paymentEnabled,
22477
22487
  resumo,
22478
- parcelas
22488
+ parcelas,
22489
+ pagamento
22479
22490
  }) {
22480
22491
  useMediaQuery("(max-width:900px)");
22481
22492
  useTheme();
@@ -22548,7 +22559,8 @@ function CheckoutFlowContent({
22548
22559
  uuid,
22549
22560
  resumo,
22550
22561
  parcelas,
22551
- urlApi: apiUrl
22562
+ urlApi: apiUrl,
22563
+ voltar: pagamento ? false : true
22552
22564
  }
22553
22565
  );
22554
22566
  }
@@ -22568,7 +22580,8 @@ function CheckoutFlowContent({
22568
22580
  onResponse,
22569
22581
  uuid,
22570
22582
  resumo,
22571
- urlApi: apiUrl
22583
+ urlApi: apiUrl,
22584
+ voltar: pagamento ? false : true
22572
22585
  }
22573
22586
  );
22574
22587
  }