LiveKit docs › Prebuilt components › Prebuilt tasks › GetCreditCardTask

---

# GetCreditCardTask

> Collect and validate complete credit card information including card number, security code, and expiration date.

Available in (BETA):
- [ ] Node.js
- [x] Python

## Overview

Use `GetCreditCardTask` to collect complete credit card information from the user. This is a composite task that runs a `TaskGroup` internally to collect the cardholder name, card number, security code, and expiration date in sequence.

`GetCreditCardTask` handles the following:

- Sequential collection of cardholder name, card number, security code, and expiration date using a task group.
- Card number format validation.
- Card issuer detection (Visa, Mastercard, American Express, Discover).
- Expiration date validation to reject expired cards.
- Built-in restart flow if the user wants to provide a different card.
- Sensitive information is never repeated back to the user during audio sessions.

The task returns a `GetCreditCardResult` data class with five fields: `cardholder_name`, `issuer`, `card_number`, `security_code`, and `expiration_date`.

### Usage

The following example uses `GetCreditCardTask` to collect payment information:

```python
from livekit.agents.beta.workflows import GetCreditCardTask
from livekit.agents import function_tool, RunContext

@function_tool()
async def collect_payment(context: RunContext) -> str:
    """Collect payment card information from the user"""
    card_result = await GetCreditCardTask(
        chat_ctx=context.session.chat_ctx,
    )
    last_four = card_result.card_number[-4:]
    return f"Payment recorded: {card_result.issuer} ending in {last_four}"

```

### Sub-tasks

`GetCreditCardTask` internally runs a `TaskGroup` with the following sub-tasks in order:

1. **`GetNameTask`**: Collects the cardholder's full name (first and last).
2. **`GetCardNumberTask`**: Collects and validates the card number format.
3. **`GetSecurityCodeTask`**: Collects the 3 or 4 digit security code (CVV/CVC).
4. **`GetExpirationDateTask`**: Collects and validates the expiration date.

Each sub-task includes a `restart_card_collection` tool that allows the user to start over from the beginning if needed.

### Parameters

For a full list of parameters, see the [GetCreditCardTask reference](https://docs.livekit.io/reference/python/livekit/agents/beta/workflows/index.html.md#livekit.agents.beta.workflows.GetCreditCardTask).

- **`chat_ctx`** _(ChatContext)_ (optional): The conversation history the task-specific LLM sees. If you omit it, the task runs with an empty context, with no memory of what was said earlier in the session. Pass the primary agent's chat context so the task can refer to prior turns and, when used inside a task group, so exchanges are summarized back into the main context.

- **`require_confirmation`** _(bool)_ (optional): Whether to confirm each piece of card information with the user before finalizing. For audio sessions this defaults to `True`, for text it defaults to `False`. This setting propagates to all sub-tasks.

- **`tools`** _(list)_ (optional): Additional tools available to the task. Use this to add or substitute function tools.

---

This document was rendered at 2026-06-07T11:37:09.128Z.
For the latest version of this document, see [https://docs.livekit.io/agents/prebuilt/tasks/get-credit-card.md](https://docs.livekit.io/agents/prebuilt/tasks/get-credit-card.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).