> For the complete documentation index, see [llms.txt](https://docs.barte.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.barte.com/sdks/sdk-web/capturar-dados-do-cartao-com-seguranca.md).

# Capturar Dados do Cartão com Segurança

O SDK captura dados de cartão com segurança usando tokenização, garantindo que informações sensíveis nunca passem pelos seus servidores e sejam substituídas por um identificador seguro (cardId).

## 1. Utilização do SDK

### Exemplo de implementação:

```javascript
const sdk = new Barte({
  accessToken: "eyJhbGciOiJIUzI1NiJ9...",
  environment?: "sandbox" | "production"
});

try {
  const result = await sdk.payment.card.token.create({
    cardHolderName: "JOSE DAS NEVES TEST",
    cardCVV: "220",
    cardExpiryDate: "12/2025",
    cardNumber: "5383638854440891",
    buyerUuid: "751f9b5b-7185-465e-a8e4-b958d3b36006"
  });

  console.log(result);
} catch (error) {
  console.error(error);
}
```

***

## Observações importantes

🔸 `buyerUuid` é obrigatório e deve representar o comprador.\
🔸 Os dados sensíveis não passam pelos seus servidores, são enviados apenas ao SDK para a tokenização.\
🔸 A resposta do método `sdk.payment.card.token.create()` retorna um `cardId`, que pode ser utilizado em transações futuras.\
🔸 Caso a opção `environment` do construtor do SDK não seja disponibilizada, por padrão será utilizado o ambiente `production` . Caso essa opção seja disponibilizada, por exemplo `sandbox`, ainda se faz necessária a criação do accessToken no respectivo ambiente que se deseja utilizar.\
🔸 A partir da versão 1.2.0, a opção `environment` define o ambiente por inteiro, incluindo a página segura de captura de dados do cartão. Em versões anteriores ela trocava apenas as URLs de API. Veja a seção Ambientes em [Instalar SDK](/sdks/sdk-web/readme.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.barte.com/sdks/sdk-web/capturar-dados-do-cartao-com-seguranca.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
