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

# Hosted Checkout

> Accept payments with a secure, hosted checkout experience

Hosted Checkout provides a secure, pre-built payment page for collecting payments and creating subscriptions. Reduce PCI compliance burden while providing a seamless checkout experience.

***

## Overview

Hosted Checkout handles:

* Payment information collection
* Tax calculation
* Subscription creation
* Payment processing
* Receipt delivery

***

## Setting Up Checkout

### Configure Plans for Checkout

Before customers can check out, ensure your plans are properly configured:

1. Navigate to **Plans** in the dashboard
2. Select or create a plan
3. Ensure the plan is marked as **Active**
4. Configure pricing and billing terms

### Branding

Customize the checkout appearance to match your brand:

1. Navigate to **Settings → Branding**
2. Upload your logo
3. Configure brand colors
4. Preview the checkout appearance

***

## Creating Checkout Sessions

### Via Dashboard

Generate a checkout link for a customer:

1. Navigate to **Customers → \[Customer]**
2. Click **Create Checkout Session**
3. Select the plan
4. Copy the checkout URL or send directly to customer

### Via API

For programmatic checkout, see the [Create Guest Checkout Session](/api-reference/checkout/create-guest-checkout) API reference.

***

## Checkout Flow

```mermaid theme={null}
sequenceDiagram
    participant Customer
    participant YourApp
    participant Alguna

    Customer->>YourApp: Clicks "Subscribe"
    YourApp->>Alguna: Create checkout session
    Alguna-->>YourApp: Checkout URL
    YourApp->>Customer: Redirect to checkout
    Customer->>Alguna: Enters payment info
    Alguna->>Alguna: Process payment
    Alguna->>Customer: Redirect to success URL
    Alguna->>YourApp: Webhook: checkout.session.completed
```

***

## Handling Checkout Completion

### Success Redirect

After successful payment, customers are redirected to your configured success URL with session information:

```
https://yourapp.com/success?session_id=cs_abc123
```

### Webhooks

Listen for checkout completion:

| Event                        | Description                              |
| ---------------------------- | ---------------------------------------- |
| `checkout.session.completed` | Payment successful, subscription created |

See [Webhooks](/api-reference/webhooks) for details on setting up webhook handlers.

***

## Tax Handling

Alguna automatically calculates tax based on:

* Customer location (address entered at checkout)
* Product tax categories
* Your tax configuration

Configure tax settings in **Settings → Tax**.

***

## Payment Methods

Supported payment methods at checkout depend on your payment provider configuration:

* Credit/Debit cards
* ACH bank transfers (if enabled)

Configure payment methods in **Settings → Payments**.

***

## Security

### PCI Compliance

Hosted Checkout is PCI DSS compliant. Card data never touches your servers.

### Built-in Fraud Prevention

* Address verification (AVS)
* Card verification (CVV)
* 3D Secure when required by card network

### Session Security

* Sessions are single-use
* Sessions expire automatically
* Sessions cannot be reused after completion

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Pre-fill Email" icon="user">
    When you know the customer's email, include it to reduce friction.
  </Card>

  <Card title="Clear Success Page" icon="check">
    Create a clear success page confirming the subscription.
  </Card>

  <Card title="Handle Webhooks" icon="bell">
    Always implement webhook handlers to confirm payments server-side.
  </Card>

  <Card title="Test in Sandbox" icon="flask">
    Test the full checkout flow in sandbox before going live.
  </Card>
</CardGroup>

***

## Troubleshooting

### Checkout Not Loading

1. Verify the checkout URL is valid and not expired
2. Check that the plan is active
3. Ensure your domain is configured correctly

### Payment Failed

1. Customer should check card details
2. Verify the card has sufficient funds
3. Check if the card supports online payments

### Customer Not Redirected

1. Verify success URL is correctly configured
2. Check for browser popup blockers
3. Ensure URL is accessible

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Customer Portal" icon="user-circle" href="/hosted/customer-portal">
    Set up customer self-service portal.
  </Card>

  <Card title="Checkout API" icon="code" href="/api-reference/checkout/create-guest-checkout">
    API reference for creating checkout sessions.
  </Card>
</CardGroup>
