Quick start

Criando a transação

Tipo de requisição: POST

URL: https://<URLPOSTMAN/>/e-sitef/api/v1/transactions

Headers:

  • Content-Type: application/json
  • merchant_id: {seu código de loja}
  • merchant_key: {chave da sua loja}

Requisição:

Para usar este exemplo, não esquecer de definir a variável {{url}} com o valor<br/> <URLPOSTMAN/>

{
  "merchant_usn": "12042142155",
  "order_id": "12042142155",
  "installments": "1",
  "installment_type": "4",
  "authorizer_id": "2",
  "amount": "1000",
  "payment_js": "true"
}
curl
--request POST "https://{{url}}/e-sitef/api/v1/transactions"
--header "Content-Type: application/json"
--header "merchant_id: xxxxxxxx"
--header "merchant_key: xxxxxxxx"
--data-binary
{
    "merchant_usn":"12042142155",
    "order_id":"12042142155",
    "installments":"1",
    "installment_type":"4",
    "authorizer_id":"2",
    "amount":"1000",
    "payment_js":"true"
}
--verbose

Resposta:

{
  "code": "0",
  "message": "OK. Transaction successful.",
  "payment": {
    "status": "NOV",
    "nit": "1234567890123456789012345678901234567890123456789012345678901234",
    "order_id": "12042142155",
    "merchant_usn": "12042142155",
    "amount": "1000",
    "pay_token": "123456789012345678901234567890123456789012345678901234567890123456"
  }
}

Saiba mais sobre esse serviço.

Página de pagamento da loja virtual

A página de pagamento do lojista deve conter o script do Carat. Abaixo estão as URLs para download:

URL para ambiente de Produção:

https://<URLPOSTMANPROD/>/js/esitefpayment-1.0.min.js

URL para ambiente de Homologação:

https://<URLPOSTMAN/>/js/esitefpayment-1.0.min.js

Exemplo:

Abaixo está um exemplo de uma página integrada com o pagamento JavaScript do Carat:

Para usar este exemplo, não esquecer de definir a variável {{url}} com o valor<br/> <URLPOSTMAN/>

&lt;!DOCTYPE html&gt;
<html>
  <head>
    &lt;meta charset="utf-8" /&gt;
    <script
      type="text/javascript"
      src="https://{{url}}/js/esitefpayment-1.0.min.js"
    ></script>
    <script>
      function myPay() {
        var request = {
          onSuccess: function (response) {
            console.log(response.code);
            console.log(response.message);
            console.log(response.payment.authorizer_code);
            console.log(response.payment.authorizer_message);
            console.log(response.payment.status);
            console.log(response.payment.nit);
            console.log(response.payment.order_id);
            console.log(response.payment.customer_receipt);
            console.log(response.payment.authorizer_id);
          },
          onFailure: function (response) {
            console.log(response.code);
            console.log(response.message);
            console.log(response.payment.authorizer_code);
            console.log(response.payment.authorizer_message);
            console.log(response.payment.status);
            console.log(response.payment.nit);
            console.log(response.payment.order_id);
            console.log(response.payment.authorizer_id);
          },
          onInvalid: function (errors) {
            for (var i = 0; i < errors.length; i++) {
              console.log(errors[i].field);
              console.log(errors[i].cause);
            }
          },
          nit:
            "1234567890123456789012345678901234567890123456789012345678901234",
          payToken:
            "123456789012345678901234567890123456789012345678901234567890123456",
          merchantId: "xxxxxxxx",
          locale: "pt",
          isCardSecurityCodeOptional: false,
        };
        esitefDoPayment(request);
      }
    </script>
  </head>

  <body>
    &lt;form method="POST"&gt;
      &lt;input type="text" class="esitef-cardnumber" /&gt;
      &lt;input type="text" class="esitef-cardexpirymonth" /&gt;
      &lt;input type="text" class="esitef-cardexpiryyear" /&gt;
      &lt;input type="text" class="esitef-cardsecuritycode" /&gt;
      &lt;input type="button" onclick="myPay()" /&gt;
    </form>
  </body>
</html>