@suportepos/split-checkout 0.5.7 → 0.5.9

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();
@@ -22001,7 +22002,7 @@ function SplitCheckoutForm({
22001
22002
  ] }),
22002
22003
  /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", className: "bp-sop-cardtype", value: "CreditCard" }),
22003
22004
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, sx: { mt: 1 }, children: [
22004
- /* @__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" }),
22005
22006
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "contained", onClick: nextFromCard, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Continuar" })
22006
22007
  ] })
22007
22008
  ] })
@@ -22212,7 +22213,8 @@ function SplitPixForm({
22212
22213
  onResponse,
22213
22214
  uuid,
22214
22215
  resumo,
22215
- urlApi
22216
+ urlApi,
22217
+ voltar
22216
22218
  }) {
22217
22219
  useMediaQuery("(max-width:900px)");
22218
22220
  const [copied, setCopied] = useState(false);
@@ -22301,6 +22303,39 @@ function SplitPixForm({
22301
22303
  setLoading(false);
22302
22304
  }
22303
22305
  };
22306
+ useEffect(() => {
22307
+ if (!pixData?.payment_id) return;
22308
+ let interval;
22309
+ let timeout2;
22310
+ const checkPix = async () => {
22311
+ try {
22312
+ const res = await fetch(urlApi + "/api/pix/consultar", {
22313
+ method: "POST",
22314
+ headers: { "Content-Type": "application/json" },
22315
+ body: JSON.stringify({
22316
+ merchantId,
22317
+ paymentId: pixData.payment_id,
22318
+ producao
22319
+ })
22320
+ });
22321
+ const result = await res.json();
22322
+ if (result?.sucesso) {
22323
+ if (result?.pago) {
22324
+ clearInterval(interval);
22325
+ clearTimeout(timeout2);
22326
+ onResponse?.(result);
22327
+ }
22328
+ }
22329
+ } catch (err) {
22330
+ console.error("Erro ao consultar PIX:", err);
22331
+ }
22332
+ };
22333
+ interval = setInterval(checkPix, 5e3);
22334
+ return () => {
22335
+ clearInterval(interval);
22336
+ clearTimeout(timeout2);
22337
+ };
22338
+ }, [pixData?.payment_id]);
22304
22339
  const copyToClipboard = async () => {
22305
22340
  if (!pixData?.codigo_copia_cola) return;
22306
22341
  try {
@@ -22360,7 +22395,7 @@ function SplitPixForm({
22360
22395
  }
22361
22396
  ),
22362
22397
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, children: [
22363
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22398
+ voltar && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, disabled: loading, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22364
22399
  /* @__PURE__ */ jsxRuntimeExports.jsx(
22365
22400
  Button,
22366
22401
  {
@@ -22444,7 +22479,7 @@ function SplitPixForm({
22444
22479
  ),
22445
22480
  /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, { sx: { my: 2 } }),
22446
22481
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, children: [
22447
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22482
+ voltar && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outlined", onClick: onBack, fullWidth: true, sx: { py: 1.4 }, children: "Voltar" }),
22448
22483
  /* @__PURE__ */ jsxRuntimeExports.jsx(
22449
22484
  Button,
22450
22485
  {
@@ -22483,7 +22518,8 @@ function CheckoutFlowContent({
22483
22518
  onResponse,
22484
22519
  paymentEnabled,
22485
22520
  resumo,
22486
- parcelas
22521
+ parcelas,
22522
+ pagamento
22487
22523
  }) {
22488
22524
  useMediaQuery("(max-width:900px)");
22489
22525
  useTheme();
@@ -22556,7 +22592,8 @@ function CheckoutFlowContent({
22556
22592
  uuid,
22557
22593
  resumo,
22558
22594
  parcelas,
22559
- urlApi: apiUrl
22595
+ urlApi: apiUrl,
22596
+ voltar: pagamento ? false : true
22560
22597
  }
22561
22598
  );
22562
22599
  }
@@ -22576,7 +22613,8 @@ function CheckoutFlowContent({
22576
22613
  onResponse,
22577
22614
  uuid,
22578
22615
  resumo,
22579
- urlApi: apiUrl
22616
+ urlApi: apiUrl,
22617
+ voltar: pagamento ? false : true
22580
22618
  }
22581
22619
  );
22582
22620
  }