Quick start

Criando a transação

Tipo de requisição: POST

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

Headers:

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

Requisição:

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

{
  "merchant_usn": "16013439434",
  "customer_id": "11122211122"
}
curl
--request POST "https://{{url}}/e-sitef/api/v1/store"
--header "Content-Type: application/json"
--header "merchant_id: xxxxxxxxxxx"
--header "merchant_key: xxxxxxxxxxx"
--data-binary
{
   "merchant_usn":"16013439434",
   "customer_id":"11122211122"
}
--verbose

Resposta:

{
  "code": "0",
  "message": "OK. Transaction successful.",
  "store": {
    "status": "CON",
    "nsua": "18051600000560A",
    "merchant_usn": "16013439434",
    "customer_id": "11122211122",
    "nita": "Z123adsfrh342r72498r34920ur23r328r2038r023rh0h203rh032r082380rf43",
    "store_token": "123456789012345678901234567890123456789012345678901234567890123456"
  }
}

Saiba mais sobre esse serviço.

Página de pagamento da loja virtual

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

URL para ambiente de Produção:

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

URL para ambiente de Homologação:

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

Exemplo:

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

&lt;!DOCTYPE html&gt;
<html>
  <head>
    &lt;meta charset="utf-8" /&gt;
    <script
      type="text/javascript"
      src="https://{{url}}/js/esitefstore-1.0.min.js"
    ></script>
    <script>
      function myStore() {
        var request = {
          onSuccess: function (response) {
            console.log(response.code);
            console.log(response.message);
            console.log(response.store.status);
            console.log(response.store.nita);
            console.log(response.store.merchant_usn);
          },
          onFailure: function (response) {
            console.log(response.code);
            console.log(response.message);
            console.log(response.store.status);
            console.log(response.store.nita);
            console.log(response.store.merchant_usn);
          },
          onInvalid: function (errors) {
            for (var i = 0; i < errors.length; i++) {
              console.log(errors[i].field);
              console.log(errors[i].cause);
            }
          },
          nita:
            "Zdn2482f8924jh8fh842390hfef2fij20fj40jf024jf9j240hf4hjf0h243f84jf",
          storeToken:
            "123456789012345678901234567890123456789012345678901234567890123456",
          merchantId: "xxxxxxxx",
          locale: "pt",
          authorizerId: "2",
        };
        esitefStore(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="button" onclick="myStore()" /&gt;
    </form>
  </body>
</html>

Recebendo um aviso de armazenamento

Assim que o armazenamento for concluído, o Carat notificará a loja com um POST (x-www-form-urlencoded) em sua URL de armazenamento cadastrada, contendo o token do cartão armazenado.

<!--Java + Spring Framework-->

@RestController
public class MyStoreController {

    @PostMapping(value = "/mystore",
        consumes = "application/x-www-form-urlencoded; charset=utf-8")
    public ResponseEntity<String> myStore(@RequestParam Map&lt;String, String&gt; request) {
        Log.info("token = " + request.get("hash"));
        // ...
        return new ResponseEntity<>("OK", HttpStatus.OK);
    }

}

Abaixo segue um exemplo de requisição a ser feita pelo Carat no domínio cadastrado pela loja:

curl -X POST \
  https://urlDaLojaCadastrada.com.br \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'cache-control: no-cache' \
  -d 'nsua=9055020677&nita=1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr&nsu=09055020677&status=CON&hash=67890afghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr&bin=498406&final=2268&autorizadora=1'

Saiba mais sobre esse serviço.