@suportepos/split-checkout 0.2.0 → 0.2.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.es.js CHANGED
@@ -21771,6 +21771,8 @@ const UF_LIST = [
21771
21771
  ];
21772
21772
  function SplitCheckoutForm({
21773
21773
  merchantId,
21774
+ orderId,
21775
+ production,
21774
21776
  amount,
21775
21777
  splits,
21776
21778
  summaryItems,
@@ -21780,6 +21782,7 @@ function SplitCheckoutForm({
21780
21782
  onBack,
21781
21783
  onResponse
21782
21784
  }) {
21785
+ const apiUrl = production ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
21783
21786
  const isSm = useMediaQuery("(max-width:900px)");
21784
21787
  const [step, setStep] = useState("card");
21785
21788
  const maskCard = (v) => v.replace(/\D/g, "").trim();
@@ -21811,12 +21814,16 @@ function SplitCheckoutForm({
21811
21814
  const [loading, setLoading] = useState(false);
21812
21815
  useEffect(() => {
21813
21816
  const script = document.createElement("script");
21814
- script.src = "https://www.pagador.com.br/post/scripts/silentorderpost-1.0.min.js";
21817
+ if (production) {
21818
+ script.src = "https://transactionscus.pagador.com.br/post/Scripts/silentorderpost-1.0.min.js";
21819
+ } else {
21820
+ script.src = "https://transactionsandbox.pagador.com.br/post/Scripts/silentorderpost-1.0.min.js";
21821
+ }
21815
21822
  script.async = true;
21816
21823
  document.body.appendChild(script);
21817
21824
  script.onload = async () => {
21818
21825
  try {
21819
- const res = await fetch(`http://localhost:8003/api/token-cartao?uuid=${merchantId}`);
21826
+ const res = await fetch(`${apiUrl}/api/token-cartao?uuid=${merchantId}`);
21820
21827
  const data = await res.json();
21821
21828
  setAccessToken(data?.AccessToken);
21822
21829
  } catch (err) {
@@ -21881,7 +21888,7 @@ function SplitCheckoutForm({
21881
21888
  const rawCep = masked.replace(/\D/g, "");
21882
21889
  if (rawCep.length === 8) {
21883
21890
  try {
21884
- const res = await fetch(`http://localhost:8003/api/cep/${rawCep}?uuid=${merchantId}`);
21891
+ const res = await fetch(`${apiUrl}/api/cep/${rawCep}?uuid=${merchantId}`);
21885
21892
  const data = await res.json();
21886
21893
  if (!data.error) {
21887
21894
  setAddress(data.street || "");
@@ -21908,12 +21915,13 @@ function SplitCheckoutForm({
21908
21915
  cvvrequired: true,
21909
21916
  onSuccess: async (response) => {
21910
21917
  try {
21911
- const res = await fetch("http://localhost:8003/api/pagar", {
21918
+ const res = await fetch(`${apiUrl}/api/pagar`, {
21912
21919
  method: "POST",
21913
21920
  headers: { "Content-Type": "application/json" },
21914
21921
  body: JSON.stringify({
21915
21922
  uuid: merchantId,
21916
21923
  // ou pegue dinamicamente
21924
+ numero_pedido: orderId,
21917
21925
  paymentToken: response.CardToken ?? response.PaymentToken,
21918
21926
  amount,
21919
21927
  installments,
@@ -22238,6 +22246,8 @@ const ContentCopyIcon = createSvgIcon(/* @__PURE__ */ jsxRuntimeExports.jsx("pat
22238
22246
  }), "ContentCopy");
22239
22247
  function SplitPixForm({
22240
22248
  merchantId,
22249
+ orderId,
22250
+ production,
22241
22251
  amount,
22242
22252
  merchantName = "SUPORTEPOS",
22243
22253
  summaryItems,
@@ -22246,6 +22256,7 @@ function SplitPixForm({
22246
22256
  onBack,
22247
22257
  onResponse
22248
22258
  }) {
22259
+ const apiUrl = production ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
22249
22260
  const isSm = useMediaQuery("(max-width:900px)");
22250
22261
  const [copied, setCopied] = useState(false);
22251
22262
  const [buyerName, setBuyerName] = useState(customer?.buyerName ?? "");
@@ -22281,11 +22292,12 @@ function SplitPixForm({
22281
22292
  if (!validate()) return;
22282
22293
  setLoading(true);
22283
22294
  try {
22284
- const res = await fetch("http://localhost:8003/api/pix", {
22295
+ const res = await fetch(apiUrl + "/api/pix", {
22285
22296
  method: "POST",
22286
22297
  headers: { "Content-Type": "application/json" },
22287
22298
  body: JSON.stringify({
22288
22299
  uuid: merchantId,
22300
+ numero_pedido: orderId,
22289
22301
  amount,
22290
22302
  buyerName,
22291
22303
  docType,
@@ -22474,6 +22486,8 @@ function SplitPixForm({
22474
22486
  }
22475
22487
  function CheckoutFlow({
22476
22488
  merchantId,
22489
+ orderId,
22490
+ production,
22477
22491
  products,
22478
22492
  customer,
22479
22493
  merchantName = "SUPORTEPOS",
@@ -22618,6 +22632,8 @@ function CheckoutFlow({
22618
22632
  SplitCheckoutForm,
22619
22633
  {
22620
22634
  merchantId,
22635
+ orderId,
22636
+ production,
22621
22637
  amount,
22622
22638
  splits,
22623
22639
  customer,
@@ -22630,6 +22646,8 @@ function CheckoutFlow({
22630
22646
  SplitPixForm,
22631
22647
  {
22632
22648
  merchantId,
22649
+ orderId,
22650
+ production,
22633
22651
  amount,
22634
22652
  splits,
22635
22653
  customer,