@suportepos/split-checkout 0.5.0 → 0.5.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/README.md CHANGED
@@ -69,6 +69,9 @@ export default function App() {
69
69
  estado: "SP"
70
70
  }}
71
71
  merchantName="SUPORTEPOS"
72
+ cor="#32a852"
73
+ pagamento="card"
74
+ resumo={true}
72
75
  onResponse={(result) => {
73
76
  if (result.sucesso) {
74
77
  alert(`Sucesso: ${result.mensagem}`);
@@ -125,7 +128,10 @@ export default function App() {
125
128
  estado: "SP"
126
129
  },
127
130
  merchantName: "SUPORTEPOS",
131
+ pagamento: "card",
132
+ cor: "#32a852",
128
133
  valorTotal: 105.25,
134
+ resumo: true,
129
135
  merchantId: "********************************67b7",
130
136
  onResponse: (result) => {
131
137
  console.log("Resposta do backend:", result);
@@ -141,10 +147,10 @@ export default function App() {
141
147
 
142
148
  ## 🛠️ Parâmetros de `renderCheckout` / `CheckoutFlow`
143
149
 
144
- | Campo | Tipo | Obrigatório | Descrição |
150
+ | Campo | Tipo | Obrigatório | Descrição |
145
151
  |------------------|-----------|-------------|---------------------------------------------------------------------------|
146
- | `elementId` | `string` | ✅ (Standalone) | ID do elemento HTML onde o checkout será montado |
147
- | `produtos` | `Array` | ✅ | Lista de produtos `{ id, nome, preco, quantidade }` |
152
+ | `elementId` | `string` | ✅ (Standalone) | ID do elemento HTML onde o checkout será montado |
153
+ | `produtos` | `Array` | ✅ | Lista de produtos `{ id, nome, preco, quantidade }` |
148
154
  | `splits` | `Array` | ❌ | Lista de splits `{ subordinateMerchantId, valor }` |
149
155
  | `codigoPedido` | `string` | ✅ | Identificador único do pedido |
150
156
  | `producao` | `boolean` | ✅ | Define o ambiente (`true = produção`, `false = homologação/test`) |
@@ -153,7 +159,9 @@ export default function App() {
153
159
  | `valorTotal` | `number` | ❌ | Sobrescreve o valor total calculado (útil para descontos, taxas, etc.) |
154
160
  | `merchantId` | `string` | ✅ | Identificador único da loja (fornecido pela SuportePOS) |
155
161
  | `onResponse` | `function`| ✅ | Callback chamado ao finalizar pagamento |
156
-
162
+ | `cor` | `string` | ❌ | Customização da cor dos botões |
163
+ | `pagamento` | `string` | ❌ | Meio de pagamento para pular opção de seleção (card, pix) |
164
+ | `resumo` | `boolean` | ❌ | Resumo com as informações de valor total e produtos |
157
165
  ---
158
166
 
159
167
  ## 🎯 Estrutura do Callback `onResponse`
package/dist/README.md CHANGED
@@ -69,6 +69,9 @@ export default function App() {
69
69
  estado: "SP"
70
70
  }}
71
71
  merchantName="SUPORTEPOS"
72
+ cor="#32a852"
73
+ pagamento="card"
74
+ resumo={true}
72
75
  onResponse={(result) => {
73
76
  if (result.sucesso) {
74
77
  alert(`Sucesso: ${result.mensagem}`);
@@ -125,7 +128,10 @@ export default function App() {
125
128
  estado: "SP"
126
129
  },
127
130
  merchantName: "SUPORTEPOS",
131
+ pagamento: "card",
132
+ cor: "#32a852",
128
133
  valorTotal: 105.25,
134
+ resumo: true,
129
135
  merchantId: "********************************67b7",
130
136
  onResponse: (result) => {
131
137
  console.log("Resposta do backend:", result);
@@ -141,10 +147,10 @@ export default function App() {
141
147
 
142
148
  ## 🛠️ Parâmetros de `renderCheckout` / `CheckoutFlow`
143
149
 
144
- | Campo | Tipo | Obrigatório | Descrição |
150
+ | Campo | Tipo | Obrigatório | Descrição |
145
151
  |------------------|-----------|-------------|---------------------------------------------------------------------------|
146
- | `elementId` | `string` | ✅ (Standalone) | ID do elemento HTML onde o checkout será montado |
147
- | `produtos` | `Array` | ✅ | Lista de produtos `{ id, nome, preco, quantidade }` |
152
+ | `elementId` | `string` | ✅ (Standalone) | ID do elemento HTML onde o checkout será montado |
153
+ | `produtos` | `Array` | ✅ | Lista de produtos `{ id, nome, preco, quantidade }` |
148
154
  | `splits` | `Array` | ❌ | Lista de splits `{ subordinateMerchantId, valor }` |
149
155
  | `codigoPedido` | `string` | ✅ | Identificador único do pedido |
150
156
  | `producao` | `boolean` | ✅ | Define o ambiente (`true = produção`, `false = homologação/test`) |
@@ -153,7 +159,9 @@ export default function App() {
153
159
  | `valorTotal` | `number` | ❌ | Sobrescreve o valor total calculado (útil para descontos, taxas, etc.) |
154
160
  | `merchantId` | `string` | ✅ | Identificador único da loja (fornecido pela SuportePOS) |
155
161
  | `onResponse` | `function`| ✅ | Callback chamado ao finalizar pagamento |
156
-
162
+ | `cor` | `string` | ❌ | Customização da cor dos botões |
163
+ | `pagamento` | `string` | ❌ | Meio de pagamento para pular opção de seleção (card, pix) |
164
+ | `resumo` | `boolean` | ❌ | Resumo com as informações de valor total e produtos |
157
165
  ---
158
166
 
159
167
  ## 🎯 Estrutura do Callback `onResponse`
package/dist/index.es.js CHANGED
@@ -21695,7 +21695,8 @@ function SplitCheckoutForm({
21695
21695
  installmentsOptions = [1, 2, 3, 6, 10, 12],
21696
21696
  onBack,
21697
21697
  onResponse,
21698
- uuid
21698
+ uuid,
21699
+ resumo
21699
21700
  }) {
21700
21701
  const apiUrl = producao ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
21701
21702
  useMediaQuery("(max-width:900px)");
@@ -21727,6 +21728,8 @@ function SplitCheckoutForm({
21727
21728
  const [docNumber, setDocNumber] = useState(cliente?.numeroDoc ?? "");
21728
21729
  const [errors, setErrors] = useState({});
21729
21730
  const [loading, setLoading] = useState(false);
21731
+ const boxSizeStep = resumo ? 7 : 12;
21732
+ const boxSizeSummary = resumo ? 5 : 12;
21730
21733
  useEffect(() => {
21731
21734
  const script = document.createElement("script");
21732
21735
  if (producao) {
@@ -21880,7 +21883,7 @@ function SplitCheckoutForm({
21880
21883
  window.bpSop_silentOrderPost(options);
21881
21884
  };
21882
21885
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, spacing: 3, children: [
21883
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 7 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
21886
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeStep }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
21884
21887
  /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { sx: { display: step === "card" ? "block" : "none" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
21885
21888
  /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h6", sx: { mb: 2 }, children: "Pagamento com cartão de crédito" }),
21886
21889
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { spacing: 2, children: [
@@ -22147,7 +22150,7 @@ function SplitCheckoutForm({
22147
22150
  ] })
22148
22151
  ] }) })
22149
22152
  ] }) }) }),
22150
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 5 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22153
+ resumo && /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeSummary }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22151
22154
  OrderSummary,
22152
22155
  {
22153
22156
  amount: valor,
@@ -22171,7 +22174,8 @@ function SplitPixForm({
22171
22174
  cliente,
22172
22175
  onBack,
22173
22176
  onResponse,
22174
- uuid
22177
+ uuid,
22178
+ resumo
22175
22179
  }) {
22176
22180
  const apiUrl = producao ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
22177
22181
  useMediaQuery("(max-width:900px)");
@@ -22181,6 +22185,8 @@ function SplitPixForm({
22181
22185
  const [docNumber, setDocNumber] = useState(cliente?.numeroDoc ?? "");
22182
22186
  const [errors, setErrors] = useState({});
22183
22187
  const [loading, setLoading] = useState(false);
22188
+ const boxSizeStep = resumo ? 7 : 12;
22189
+ const boxSizeSummary = resumo ? 5 : 12;
22184
22190
  const [pixData, setPixData] = useState(null);
22185
22191
  const maskCPF = (v) => v.replace(/\D/g, "").slice(0, 11).replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2");
22186
22192
  const maskCNPJ = (v) => v.replace(/\D/g, "").slice(0, 14).replace(/^(\d{2})(\d)/, "$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1/$2").replace(/(\d{4})(\d)/, "$1-$2");
@@ -22269,7 +22275,7 @@ function SplitPixForm({
22269
22275
  }
22270
22276
  };
22271
22277
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, spacing: 3, children: [
22272
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 7 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
22278
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeStep }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
22273
22279
  !pixData && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
22274
22280
  /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h6", sx: { mb: 2 }, children: "Preencha seus dados para gerar o PIX" }),
22275
22281
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { spacing: 2, children: [
@@ -22416,7 +22422,7 @@ function SplitPixForm({
22416
22422
  ] })
22417
22423
  ] })
22418
22424
  ] }) }) }),
22419
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 5 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22425
+ resumo && /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeSummary }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22420
22426
  OrderSummary,
22421
22427
  {
22422
22428
  amount: valor,
@@ -22440,7 +22446,7 @@ function CheckoutFlowContent({
22440
22446
  producao,
22441
22447
  onResponse,
22442
22448
  paymentEnabled,
22443
- cor
22449
+ resumo
22444
22450
  }) {
22445
22451
  useMediaQuery("(max-width:900px)");
22446
22452
  useTheme();
@@ -22493,6 +22499,8 @@ function CheckoutFlowContent({
22493
22499
  );
22494
22500
  }
22495
22501
  const noneActive = primaryButtons.length === 0 && listItems.length === 0;
22502
+ const boxSizeStep = resumo ? 7 : 12;
22503
+ const boxSizeSummary = resumo ? 5 : 12;
22496
22504
  if (step === "card") {
22497
22505
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
22498
22506
  SplitCheckoutForm,
@@ -22507,7 +22515,8 @@ function CheckoutFlowContent({
22507
22515
  produtos,
22508
22516
  onBack: () => setStep("select"),
22509
22517
  onResponse,
22510
- uuid
22518
+ uuid,
22519
+ resumo
22511
22520
  }
22512
22521
  );
22513
22522
  }
@@ -22525,19 +22534,20 @@ function CheckoutFlowContent({
22525
22534
  produtos,
22526
22535
  onBack: () => setStep("select"),
22527
22536
  onResponse,
22528
- uuid
22537
+ uuid,
22538
+ resumo
22529
22539
  }
22530
22540
  );
22531
22541
  }
22532
22542
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, spacing: 3, justifyContent: "center", children: [
22533
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 7 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
22543
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeStep }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { elevation: 0, sx: { border: "1px solid #e2e8f0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { children: [
22534
22544
  /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h6", sx: { mb: 2 }, children: "Como você quer pagar?" }),
22535
22545
  noneActive && /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { severity: "warning", sx: { mb: 2 }, children: "Nenhum meio de pagamento está disponível no momento." }),
22536
22546
  primaryButtons.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, sx: { mb: 2 }, children: primaryButtons }),
22537
22547
  primaryButtons.length > 0 && listItems.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, { sx: { my: 1 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "body2", color: "text.secondary", children: "ou" }) }),
22538
22548
  listItems.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(List, { sx: { mt: primaryButtons.length ? 1 : 0 }, children: listItems })
22539
22549
  ] }) }) }),
22540
- /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: 5 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22550
+ resumo && /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { size: { xs: 12, sm: boxSizeSummary }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22541
22551
  OrderSummary,
22542
22552
  {
22543
22553
  amount: valor,
@@ -22631,7 +22641,7 @@ const createBrandTheme = (color2) => {
22631
22641
  });
22632
22642
  };
22633
22643
  function CheckoutFlow(props) {
22634
- const [step, setStep] = useState("select");
22644
+ const [step, setStep] = useState(props?.pagamento ?? "select");
22635
22645
  const amountFromItems = useMemo(
22636
22646
  () => props.produtos.reduce((sum, p) => sum + p.preco * (p.quantidade ?? 1), 0),
22637
22647
  [props.produtos]