> ## Documentation Index
> Fetch the complete documentation index at: https://developer.pagou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Mount the Payment Element, tokenize card details, and create a card payment through your backend in the shortest possible path.

Use this page for the smallest working Payment Element integration.

## Prerequisites

* a Pagou public key
* a backend route that creates `POST /v2/transactions`
* webhook handling for final payment state

## Load the script

```html theme={null}
<script src="https://js.pagou.ai/payments/v3.js"></script>
<script>
  Pagou.setEnvironment("sandbox");
</script>
```

## Mount the field

```js theme={null}
const elements = Pagou.elements({
  publicKey: "pk_test_your_public_key",
  locale: "en",
  origin: window.location.origin,
});

const card = elements.create("card", { theme: "default" });
card.mount("#card-element");
```

## Submit through your backend

```js theme={null}
const result = await elements.submit({
  createTransaction: async (tokenData) => {
    const response = await fetch("/api/pay", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        token: tokenData.token,
        amount: 2490,
        installments: 1,
        orderId: "order_2001",
      }),
    });

    const payload = await response.json();
    return payload.data ?? payload;
  },
});
```

## Backend request example

```json theme={null}
{
  "external_ref": "order_2001",
  "amount": 2490,
  "currency": "BRL",
  "method": "credit_card",
  "token": "pgct_token_from_browser",
  "installments": 1
}
```

## Backend response example

```json theme={null}
{
  "success": true,
  "requestId": "0190a2b4-18a7-7de0-9a43-69b7cf261201",
  "data": {
    "id": "018f1f2e-7b43-7c9a-8d3e-1a2b3c4d5e70",
    "status": "pending",
    "method": "credit_card"
  }
}
```

## Common error

```json theme={null}
{
  "status": "error",
  "error": "Unable to initialize the card field."
}
```

Fix: confirm the public key, `origin`, and script environment. Your backend must return the transaction payload without dropping fields such as `id`, `status`, and `next_action`.

## Next steps

* [SDK v3 Reference](/frontend/payment-element/sdk-reference)
* [Accept a Payment](/frontend/payment-element/accept-a-payment)
* [Appearance and Events](/frontend/payment-element/appearance-and-events)
* [Testing and Troubleshooting](/frontend/payment-element/testing-and-troubleshooting)
