@suportepos/split-checkout 0.5.5 → 0.5.6
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 +35 -13
- package/dist/index.umd.js +7 -7
- package/dist/standalone/suportepos-checkout.js +1 -1
- package/dist/types/CheckoutFlow.d.ts +5 -0
- package/dist/types/SplitCardForm.d.ts +2 -1
- package/dist/types/SplitPixForm.d.ts +2 -1
- package/dist/types/lib/CheckoutFlow.d.ts +5 -0
- package/dist/types/lib/SplitCardForm.d.ts +2 -1
- package/dist/types/lib/SplitPixForm.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -21697,10 +21697,9 @@ function SplitCheckoutForm({
|
|
|
21697
21697
|
onResponse,
|
|
21698
21698
|
uuid,
|
|
21699
21699
|
resumo,
|
|
21700
|
-
parcelas
|
|
21700
|
+
parcelas,
|
|
21701
|
+
urlApi
|
|
21701
21702
|
}) {
|
|
21702
|
-
const apiUrl = producao ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
|
|
21703
|
-
useMediaQuery("(max-width:900px)");
|
|
21704
21703
|
const [step, setStep] = useState("card");
|
|
21705
21704
|
const maskCard = (v) => v.replace(/\D/g, "").trim();
|
|
21706
21705
|
const maskExpiry = (v) => v.replace(/\D/g, "").slice(0, 6).replace(/(\d{2})(\d{0,4})/, (m, mm, yyyy) => yyyy ? `${mm}/${yyyy}` : mm);
|
|
@@ -21715,6 +21714,8 @@ function SplitCheckoutForm({
|
|
|
21715
21714
|
const [cvv, setCvv] = useState("");
|
|
21716
21715
|
const [installments, setInstallments] = useState(1);
|
|
21717
21716
|
const [accessToken, setAccessToken] = useState("");
|
|
21717
|
+
const [bandeiras, setBandeiras] = useState([]);
|
|
21718
|
+
const [bandeiraDetectada, setBandeiraDetectada] = useState("MASTERCARD");
|
|
21718
21719
|
const [cep, setCep] = useState(cliente?.cep ? maskCEP(cliente.cep) : "");
|
|
21719
21720
|
const [address, setAddress] = useState(cliente?.endereco ?? "");
|
|
21720
21721
|
const [number, setNumber] = useState(cliente?.numero ?? "");
|
|
@@ -21742,7 +21743,10 @@ function SplitCheckoutForm({
|
|
|
21742
21743
|
document.body.appendChild(script);
|
|
21743
21744
|
script.onload = async () => {
|
|
21744
21745
|
try {
|
|
21745
|
-
const
|
|
21746
|
+
const resBandeiras = await fetch(`${urlApi}/api/bandeiras?merchantId=${merchantId}&producao=${producao}`);
|
|
21747
|
+
const dataBandeiras = await resBandeiras.json();
|
|
21748
|
+
setBandeiras(dataBandeiras);
|
|
21749
|
+
const res = await fetch(`${urlApi}/api/token-cartao?merchantId=${merchantId}&producao=${producao}`);
|
|
21746
21750
|
const data = await res.json();
|
|
21747
21751
|
setAccessToken(data?.access_token);
|
|
21748
21752
|
} catch (err) {
|
|
@@ -21753,6 +21757,20 @@ function SplitCheckoutForm({
|
|
|
21753
21757
|
document.body.removeChild(script);
|
|
21754
21758
|
};
|
|
21755
21759
|
}, []);
|
|
21760
|
+
useEffect(() => {
|
|
21761
|
+
const bin = cardNumber.replace(/\D/g, "").slice(0, 6);
|
|
21762
|
+
if (bin.length === 6) {
|
|
21763
|
+
const binInt = parseInt(bin);
|
|
21764
|
+
const encontrada = bandeiras.find(
|
|
21765
|
+
(b) => binInt >= parseInt(b.bin_inicial) && binInt <= parseInt(b.bin_final)
|
|
21766
|
+
);
|
|
21767
|
+
if (encontrada) {
|
|
21768
|
+
setBandeiraDetectada(encontrada.bandeira);
|
|
21769
|
+
} else {
|
|
21770
|
+
setBandeiraDetectada("MASTERCARD");
|
|
21771
|
+
}
|
|
21772
|
+
}
|
|
21773
|
+
}, [cardNumber, bandeiras]);
|
|
21756
21774
|
function validateCard() {
|
|
21757
21775
|
const e = {};
|
|
21758
21776
|
if (cardNumber.replace(/\D/g, "").length < 15) e.cardNumber = "Número inválido";
|
|
@@ -21807,7 +21825,7 @@ function SplitCheckoutForm({
|
|
|
21807
21825
|
const rawCep = masked.replace(/\D/g, "");
|
|
21808
21826
|
if (rawCep.length === 8) {
|
|
21809
21827
|
try {
|
|
21810
|
-
const res = await fetch(`${
|
|
21828
|
+
const res = await fetch(`${urlApi}/api/cep/${rawCep}?merchantId=${merchantId}`);
|
|
21811
21829
|
const data = await res.json();
|
|
21812
21830
|
if (!data.error) {
|
|
21813
21831
|
setAddress(data.street || "");
|
|
@@ -21834,7 +21852,7 @@ function SplitCheckoutForm({
|
|
|
21834
21852
|
cvvrequired: true,
|
|
21835
21853
|
onSuccess: async (response) => {
|
|
21836
21854
|
try {
|
|
21837
|
-
const res = await fetch(`${
|
|
21855
|
+
const res = await fetch(`${urlApi}/api/pagar`, {
|
|
21838
21856
|
method: "POST",
|
|
21839
21857
|
headers: { "Content-Type": "application/json" },
|
|
21840
21858
|
body: JSON.stringify({
|
|
@@ -21858,7 +21876,8 @@ function SplitCheckoutForm({
|
|
|
21858
21876
|
cidade: city,
|
|
21859
21877
|
estado: uf,
|
|
21860
21878
|
producao,
|
|
21861
|
-
uuid
|
|
21879
|
+
uuid,
|
|
21880
|
+
bandeira: bandeiraDetectada
|
|
21862
21881
|
})
|
|
21863
21882
|
});
|
|
21864
21883
|
const result = await res.json();
|
|
@@ -22184,9 +22203,9 @@ function SplitPixForm({
|
|
|
22184
22203
|
onBack,
|
|
22185
22204
|
onResponse,
|
|
22186
22205
|
uuid,
|
|
22187
|
-
resumo
|
|
22206
|
+
resumo,
|
|
22207
|
+
urlApi
|
|
22188
22208
|
}) {
|
|
22189
|
-
const apiUrl = producao ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
|
|
22190
22209
|
useMediaQuery("(max-width:900px)");
|
|
22191
22210
|
const [copied, setCopied] = useState(false);
|
|
22192
22211
|
const [buyerName, setBuyerName] = useState(cliente?.nomeComprador ?? "");
|
|
@@ -22224,7 +22243,7 @@ function SplitPixForm({
|
|
|
22224
22243
|
if (!validate()) return;
|
|
22225
22244
|
setLoading(true);
|
|
22226
22245
|
try {
|
|
22227
|
-
const res = await fetch(
|
|
22246
|
+
const res = await fetch(urlApi + "/api/pix", {
|
|
22228
22247
|
method: "POST",
|
|
22229
22248
|
headers: { "Content-Type": "application/json" },
|
|
22230
22249
|
body: JSON.stringify({
|
|
@@ -22255,7 +22274,7 @@ function SplitPixForm({
|
|
|
22255
22274
|
if (!validate()) return;
|
|
22256
22275
|
setLoading(true);
|
|
22257
22276
|
try {
|
|
22258
|
-
const res = await fetch(
|
|
22277
|
+
const res = await fetch(urlApi + "/api/pix/consultar", {
|
|
22259
22278
|
method: "POST",
|
|
22260
22279
|
headers: { "Content-Type": "application/json" },
|
|
22261
22280
|
body: JSON.stringify({
|
|
@@ -22462,6 +22481,7 @@ function CheckoutFlowContent({
|
|
|
22462
22481
|
useTheme();
|
|
22463
22482
|
const primaryButtons = [];
|
|
22464
22483
|
const listItems = [];
|
|
22484
|
+
const apiUrl = producao ? "https://api-conciliapos.suportepos.com.br" : "https://api-conciliapos-stag.suportepos.com.br";
|
|
22465
22485
|
if (paymentEnabled?.creditCard) {
|
|
22466
22486
|
listItems.push(
|
|
22467
22487
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(ListItemButton, { onClick: () => setStep("card"), sx: {
|
|
@@ -22527,7 +22547,8 @@ function CheckoutFlowContent({
|
|
|
22527
22547
|
onResponse,
|
|
22528
22548
|
uuid,
|
|
22529
22549
|
resumo,
|
|
22530
|
-
parcelas
|
|
22550
|
+
parcelas,
|
|
22551
|
+
urlApi: apiUrl
|
|
22531
22552
|
}
|
|
22532
22553
|
);
|
|
22533
22554
|
}
|
|
@@ -22546,7 +22567,8 @@ function CheckoutFlowContent({
|
|
|
22546
22567
|
onBack: () => setStep("select"),
|
|
22547
22568
|
onResponse,
|
|
22548
22569
|
uuid,
|
|
22549
|
-
resumo
|
|
22570
|
+
resumo,
|
|
22571
|
+
urlApi: apiUrl
|
|
22550
22572
|
}
|
|
22551
22573
|
);
|
|
22552
22574
|
}
|