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

# Quickstart

> Render Checkout and take your first payment in five minutes.

This guide mounts a `checkout` element on a page and forwards the tokenized payload to your server. Checkout is the fastest integration path: one mount renders shopper contact, a payment method selector, and a single submit lifecycle.

## Prerequisites

* An Overflow account with a **publishable key** (`live_pub_…` or `test_pub_…`) and a **secret key** from your Overflow dashboard.
* A page where you can add a `<script>` tag, or a project that can install an npm package.
* A server endpoint that can accept the tokenized payload and call the Overflow API to authorize the charge.

## 1. Load the SDK

Pick one of the two install paths. Both are backed by the same CDN artifact.

<CodeGroup>
  ```html Script tag theme={null}
  <script src="https://cdn.overflow.co/sdk/v1/payment-elements.js"></script>
  ```

  ```bash npm theme={null}
  npm install @getoverflow/payment-elements
  ```
</CodeGroup>

See [Installation](/payment-elements/installation) for pinned versions, Subresource Integrity, staging hosts, and preload hints.

## 2. Add a host element

Add an empty container where Checkout will mount.

```html theme={null}
<div id="checkout"></div>
<button id="pay" disabled>Pay</button>
```

## 3. Create Checkout

Use `test_pub_…` while you build, then swap to `live_pub_…` for production.

<CodeGroup>
  ```javascript Script tag theme={null}
  const overflow = new Overflow('test_pub_...');

  const checkout = overflow.checkout({
    paymentMethods: ['card', 'bank'],
    defaultPaymentMethod: 'card',
    contact: { email: {}, fullName: {} },
  });

  checkout.mount('#checkout');
  ```

  ```javascript npm theme={null}
  import { loadOverflow } from '@getoverflow/payment-elements';

  const overflow = await loadOverflow('test_pub_...');
  if (!overflow) return;

  const checkout = overflow.checkout({
    paymentMethods: ['card', 'bank'],
    defaultPaymentMethod: 'card',
    contact: { email: {}, fullName: {} },
  });

  checkout.mount('#checkout');
  ```
</CodeGroup>

## 4. Gate the Pay button

Listen for `onChange` and enable your button when the form is complete.

```javascript theme={null}
const payButton = document.getElementById('pay');

checkout.on('onChange', ({ complete }) => {
  payButton.disabled = !complete;
});

payButton.addEventListener('click', () => {
  checkout.submit();
});
```

## 5. Handle the tokenized payload

`onSubmit` fires once validation passes. Forward the payload to your server. Never call the Overflow authorize endpoint from the browser: your secret key stays server-side.

```javascript theme={null}
checkout.on('onSubmit', async ({ value }) => {
  const res = await fetch('/api/authorize', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(value),
  });
  const result = await res.json();
  // Show success or failure UI based on `result`.
});

checkout.on('onError', ({ code, message, fieldErrors }) => {
  console.error('Checkout failed', { code, message, fieldErrors });
});
```

On your server, POST `value` (plus any additional order data) to the Overflow authorize endpoint with your secret key. See the [authorize a payment API reference](/api-reference/payments/authorize-payment) for the request shape.

## What you built

* A themed, validated payment form that supports card and bank.
* A submit lifecycle that hands you a tokenized payload.
* Error handling for validation failures and authorize failures.

## Next steps

<CardGroup cols={2}>
  <Card title="Accept a payment" icon="credit-card" href="/payment-elements/guides/accept-a-payment">
    Full end-to-end guide with server code.
  </Card>

  <Card title="Add wallets" icon="mobile" href="/payment-elements/guides/wallets">
    Add Apple Pay and Google Pay to Checkout.
  </Card>

  <Card title="Theming" icon="palette" href="/payment-elements/theming/overview">
    Match Checkout to your brand.
  </Card>

  <Card title="Concepts" icon="book" href="/payment-elements/concepts">
    Elements, options, events, theming.
  </Card>
</CardGroup>
