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

# Payment Processing

> Collect PCI-compliant payments from callers during a voice call via Stripe or a custom payment provider.

# Payment Processing

The **Payment Processing** tool lets your voice agent collect payments from callers during a live call. Payments are processed through your configured provider (Stripe or custom) with PCI compliance — recording is automatically paused during card collection if enabled.

## How It Works

```
Caller: "I'd like to pay my invoice."
Agent: "Sure! Your invoice total is $149.99. Would you like to proceed with the payment?"
Caller: "Yes, go ahead."
-> Agent calls collect_payment with amount=149.99
-> Recording pauses (if configured)
-> Payment processed via Stripe
Agent: "Payment of $149.99 has been processed successfully. Your confirmation number is ending in 4242."
```

## Configuration

```json theme={null}
{
  "paymentProcessingEnabled": true,
  "paymentProvider": "stripe",
  "paymentCurrency": "USD",
  "paymentMaxAmountCents": 100000,
  "paymentApiKey": "sk_live_...",
  "paymentPauseRecording": true,
  "paymentConfirmationMessage": "Payment of {amount} processed. Card ending in {last4}.",
  "paymentFailMessage": "Payment could not be processed. Please try again or use a different card."
}
```

| Setting                      | Type    | Default  | Description                                                              |
| ---------------------------- | ------- | -------- | ------------------------------------------------------------------------ |
| `paymentProcessingEnabled`   | boolean | `false`  | Enable payment processing                                                |
| `paymentProvider`            | string  | `stripe` | Payment provider: `stripe` or `custom`                                   |
| `paymentCurrency`            | string  | `USD`    | Currency code                                                            |
| `paymentMaxAmountCents`      | integer | `100000` | Max single transaction in cents (\$1,000.00)                             |
| `paymentApiKey`              | string  | —        | Provider API key                                                         |
| `paymentApiSecret`           | string  | —        | Provider API secret                                                      |
| `paymentApiEndpoint`         | string  | —        | Custom provider endpoint URL                                             |
| `paymentPauseRecording`      | boolean | `true`   | Pause recording during payment collection                                |
| `paymentConfirmationMessage` | string  | —        | Success message template. Variables: `{amount}`, `{last4}`, `{currency}` |
| `paymentFailMessage`         | string  | —        | Failure message                                                          |

## LLM Tool

**Tool name:** `collect_payment`

Process a payment from the caller.

```
Parameters:
  amount_dollars: float (payment amount in dollars)
  description: string (what the payment is for)

Returns:
  Success: "Payment of $149.99 processed. Card ending in 4242."
  Failure: "Payment could not be processed. Please try again or use a different card."
```

Validations:

* Amount must be greater than \$0
* Amount cannot exceed `paymentMaxAmountCents`
* Insufficient funds or card errors return the configured failure message

## Security

* **PCI Compliance:** Card details are handled by the payment provider, never stored by thinnestAI
* **Recording Pause:** When `paymentPauseRecording` is enabled, call recording stops during payment and resumes after
* **Card Safety:** The agent never reads back the full card number — only confirms the last 4 digits

## Example — Create Agent with Payment Processing

```bash theme={null}
curl -X POST https://api.thinnest.ai/v1/agents \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Billing Agent",
    "model": "gpt-4o",
    "instructions": "You help customers pay their invoices. Always confirm the amount before processing. Never read back the full card number — only the last 4 digits.",
    "voiceEnabled": true,
    "transcriber": { "provider": "deepgram", "model": "nova-2-conversationalai" },
    "voice": { "provider": "deepgram", "voiceId": "aura-2-thalia-en" },
    "paymentProcessingEnabled": true,
    "paymentProvider": "stripe",
    "paymentCurrency": "USD",
    "paymentMaxAmountCents": 100000,
    "paymentPauseRecording": true
  }'
```
