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

# Going live

> Test in sandbox, then ship embedded checkout to production safely.

## Test in sandbox first

Run the whole flow with no real money:

1. Use a **sandbox** product / payment-link id.
2. Pass `env: "sandbox"` to `Playto.checkout`.
3. Complete payment with the [test card](/api-reference/introduction.md#test-card) in the checkout's card form.
4. Confirm your `onSuccess` (via `handleReturn`) fires and the transaction shows
   up in your dashboard.

```js
Playto.checkout({
  productId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", // a sandbox id
  env: "sandbox",
  returnUrl: window.location.href,
});
```

> [!WARNING]
>
> Without `env: "sandbox"`, a sandbox id shows **Link Not Found**. Sandbox and live
> are separate, so a live id works only without it.

> [!NOTE]
>
> Test mode needs no domain approval. Any domain works, including `localhost` and
> ngrok URLs.

> [!TIP]
>
> Want to see the whole experience before wiring real ids? Pass `demo: true` to
> render a self-contained preview (sample product + a simulated gateway, no backend
> and no charge).

## Approve your domains

In **Live**, the embedded checkout opens only on domains Playto has approved for
your account.

1. In the dashboard, open **Playto Pay → API Key** and switch to **Live**.
2. Under **Embedded checkout domains**, add each site you embed from. Enter only
   the domain, such as `example.com`. Don't add a page path or a wildcard.
3. Wait for Playto to approve it. The domain shows **Approved** when it is ready.
   If it stays **Pending**, contact [support@playto.so](mailto:support@playto.so).

How domains are matched:

* An approved domain also covers its subdomains. Approving `example.com` lets
  the checkout open on `www.example.com`, `shop.example.com` and any other
  subdomain.
* An approved `www.example.com` also covers `example.com`, but not other
  subdomains such as `shop.example.com`.
* An approved subdomain doesn't cover its parent: approving `shop.example.com`
  doesn't cover `example.com`.
* The port and the scheme (`http` or `https`) are ignored.
* Only the page that opens the checkout is checked. Your `returnUrl` can be on
  any host, as long as it's an `http(s)` URL.
* Shared domains such as `vercel.app`, `github.io` or `netlify.app` can't be
  added. Add your own site on them instead, such as `yourname.vercel.app`.

If a domain is not approved, the checkout shows an error. See
[Troubleshooting](/guides/embedded-checkout/troubleshooting.md).

## Go to production

When you're ready:

**1. Use a live id**

Swap in a real `productId` / `paymentLinkId` from your
live dashboard.

**2. Drop the sandbox flag**

Remove `env: "sandbox"` (or set `env: "production"`) and remove `demo`.

**3. Get your domains approved**

Add the sites you embed from, and your `returnUrl` host, under **Embedded
checkout domains** in Live mode. Wait until they show **Approved**.

**4. Serve over HTTPS**

Embed only from `https://` pages — gateways and the SDK assume a secure origin.

**5. Allow Playto in your site's CSP**

If your site sets a Content-Security-Policy, allow `https://app.playto.so` in
`frame-src` and `script-src`. See
[Troubleshooting](/guides/embedded-checkout/troubleshooting.md).

**6. Fulfil from the webhook**

Grant access / fulfil orders from the **signed webhook**, not the browser
callback (next section).

## Confirm payments from the webhook, not the callback

`onSuccess` is great for **UX** — showing a thank-you, unlocking the next screen.
But the browser callback travels through the customer's URL bar and can be
spoofed. **Do the real fulfilment server-side, off the webhook**, which is signed
and authoritative.

1. Set your webhook endpoint and copy your signing secret in
   **Configuration → Webhooks** in the dashboard (switch to **Live**: test and live keep separate settings).
2. Verify the `X-Playto-Signature` header (HMAC-SHA256 over the raw body).
3. Fulfil on `invoice.paid` (invoices) or `payment.succeeded` (payment links), keyed idempotently off the
   event `id` so retries don't double-fulfil.

See the [Webhooks reference](/api-reference/webhooks/overview.md) for payloads and
verification code.

## Pre-launch checklist

> [!TIP]
>
> Using a live id, `env` is production, `demo` removed

> [!TIP]
>
> Every domain you embed from is approved in Live

> [!TIP]
>
> Embedding only from HTTPS pages

> [!TIP]
>
> If your site sets a CSP, it allows `https://app.playto.so` for frames and scripts

> [!TIP]
>
> `Playto.handleReturn()` runs on the return page

> [!TIP]
>
> Webhook endpoint set + signature verified server-side

> [!TIP]
>
> Fulfilment is idempotent (safe on webhook retries)

> [!TIP]
>
> Tested a full sandbox payment end to end
