Error 404 when using Cielo Ecommerce API

Asked

Viewed 217 times

0

I am trying to make a request via API to make sales via credit card.

URL of the Handbook: https://developercielo.github.io/manual/cielo-ecommerce#requisi%C3%A7%C3%A3o

JSON informed by CIELO

{
   "MerchantOrderId":"2014111703",
   "Customer":{
      "Name":"Comprador crédito simples"
   },
   "Payment":{
     "Type":"CreditCard",
     "Amount":15700,
     "Installments":1,
     "SoftDescriptor":"123456789ABCD",
     "CreditCard":{
         "CardNumber":"1234123412341231",
         "Holder":"Teste Holder",
         "ExpirationDate":"12/2030",
         "SecurityCode":"123",
         "Brand":"Visa"
     }
   }
}

AJAX method I developed

$.ajax({
           url: "https://api.cieloecommerce.cielo.com.br/1/sales/",
           headers:{
             "Content-Type": "application/x-www-form-urlencoded",
             "MerchantId": "INFORMADO PELA CIELO",
           },
           data: {
             "MerchantKey": "INFORMADO PELA CIELO",
             "MerchantOrderId": idCarrinho,
             "Customer":{
                "Name": nomeCliente
             },
             "Payment":{
               "Type": "CreditCard",
               "Amount": valor,
               "Installments": 1,
               "SoftDescriptor":"NOME EMPRESA",
               "CreditCard":{
                   "CardNumber": apenasNumeros(numero),
                   "Holder": nome,
                   "ExpirationDate": data,
                   "SecurityCode": cvv,
                   "Brand": bandeira
               }
             }
           },
           type: "POST",
           success: function(data)
           {
             console.log(data);
           },
           error: function(x)
           {
              Materialize.toast("Ocorreu um erro!", 4000);
           }
});

When I use this 404 error method, I called support and the url is correct and this is the only thing they say.

Someone’s already done it and knows how to light me up?

1 answer

0

You cannot make this call through JS. You will have to send the information on the server side.

This way you leave exposed your Merchantid and your Merchantkey.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.