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

# Stripe Integration

> Automatic Payment Intent creation and payment processing via Stripe directly during customer calls for seamless e-commerce integration

# Stripe Integration Template

Integrate Stripe payment processing into your Mid-call Actions and enable your AI assistant to initiate payments, create Payment Intents, and start subscription checkouts during customer conversations.

## Overview & Features

<CardGroup cols={2}>
  <Card title="Payment Intent Management" icon="credit-card">
    * Immediate payment preparation during the call
    * Support for one-time payments and subscriptions
    * Multi-currency support (EUR, USD, GBP, etc.)
    * PCI-DSS-compliant payment processing
  </Card>

  <Card title="Customer & Order Integration" icon="shopping-cart">
    * Automatic customer ID linking
    * Order metadata for business intelligence
    * Integration with existing e-commerce systems
    * Webhook-based payment status updates
  </Card>
</CardGroup>

## Stripe Account & API Setup

### 1. Prepare Stripe Dashboard

<Steps>
  <Step title="Set up Stripe Account">
    * Register at [Stripe](https://stripe.com) or log in
    * Complete your business profile for live payments
    * Enable relevant payment methods (cards, SEPA, etc.)
  </Step>

  <Step title="Retrieve API Keys">
    ```yaml theme={null}
    API Keys Location:
      1. Stripe Dashboard → "Developers" → "API keys"
      2. Two key types available:
         - Publishable Key (pk_test_ or pk_live_)
         - Secret Key (sk_test_ or sk_live_)
      
    Required for Mid-call Actions:
      - Secret Key (for server-to-server API calls)
      - Test environment: sk_test_...
      - Production: sk_live_...
    ```
  </Step>

  <Step title="Configure Webhooks">
    ```yaml theme={null}
    Webhook Setup for Payment Updates:
      1. "Developers" → "Webhooks" → "Add endpoint"
      2. Endpoint URL: https://your-app.com/stripe-webhook
      3. Events to send:
         - payment_intent.succeeded
         - payment_intent.payment_failed
         - payment_intent.canceled
      4. Note webhook secret for verification
    ```
  </Step>

  <Step title="Prepare Customer Management">
    * Identify existing customers in Stripe
    * Map customer IDs to internal CRM systems
    * Review default payment methods and billing details
  </Step>
</Steps>

## Configure Payment Intent Tool

### Famulor Interface Configuration

<Tabs>
  <Tab title="Tool Details">
    | Field                       | Value                                                                                                 |
    | --------------------------- | ----------------------------------------------------------------------------------------------------- |
    | **Name** \*                 | `Stripe Zahlung initiieren`                                                                           |
    | **Description**             | "Creates a Payment Intent in Stripe for secure payment processing during customer calls"              |
    | **Function Name** \*        | `create_stripe_payment`                                                                               |
    | **Function Description** \* | "Creates a Payment Intent for a payment. Use this when a customer is ready to pay or make a deposit." |
    | **HTTP Method**             | `POST`                                                                                                |
    | **Timeout (ms)**            | `5000`                                                                                                |
    | **Endpoint** \*             | `https://api.stripe.com/v1/payment_intents`                                                           |
  </Tab>

  <Tab title="Header Configuration">
    ```json theme={null}
    {
      "Authorization": "Bearer {{STRIPE_SECRET_KEY}}",
      "Content-Type": "application/x-www-form-urlencoded",
      "User-Agent": "Famulor-MidCall-Stripe/1.0"
    }
    ```

    <Warning>**Content-Type Important**: Stripe expects `application/x-www-form-urlencoded`, not JSON!</Warning>
  </Tab>

  <Tab title="Body Template (Form Data)">
    ```
    amount={amount}&currency={currency}&customer={customer_id}&description={description}&metadata[order_id]={order_id}&metadata[call_source]=mid_call_tool&metadata[customer_phone]={customer_phone}&automatic_payment_methods[enabled]=true
    ```
  </Tab>
</Tabs>

### Parameter Schema

```json theme={null}
{
  "type": "object",
  "properties": {
    "amount": {
      "type": "integer",
      "description": "Amount in the smallest currency unit (e.g. 5000 for €50.00)",
      "minimum": 50,
      "maximum": 9999999
    },
    "currency": {
      "type": "string",
      "enum": ["eur", "usd", "gbp", "chf", "dkk", "nok", "sek"],
      "description": "Currency code (ISO 4217)",
      "default": "eur"
    },
    "customer_id": {
      "type": "string",
      "description": "Stripe Customer ID (if available, e.g. 'cus_abc123')"
    },
    "description": {
      "type": "string",
      "description": "Payment description (appears on credit card statements)",
      "examples": ["Invoice INV-2024-001", "Project XY deposit", "Subscription Premium Plan"]
    },
    "order_id": {
      "type": "string",
      "description": "Your internal order or invoice ID"
    },
    "customer_phone": {
      "type": "string",
      "description": "Customer phone number (for metadata)"
    },
    "customer_email": {
      "type": "string",
      "format": "email",
      "description": "Customer email address (for receipt and follow-up)"
    },
    "payment_type": {
      "type": "string",
      "enum": ["one_time", "subscription", "installment"],
      "description": "Type of payment",
      "default": "one_time"
    }
  },
  "required": ["amount", "currency", "description"]
}
```

## Practical Use Cases

### Scenario 1: Immediate Deposit During Sales Call

<Steps>
  <Step title="Detect Payment Readiness">
    ```yaml theme={null}
    Sales Conversation:
      Customer: "The offer sounds good. How can I pay the deposit?"
      
    AI Assistant: "Great! I am preparing the payment for €5,000..."

    → create_stripe_payment is triggered
    ```
  </Step>

  <Step title="Payment Intent Creation">
    ```yaml theme={null}
    Stripe API Call:
      amount: 500000  # €5,000 in cents
      currency: "eur"
      description: "Deposit Project CRM Integration"
      customer_id: "cus_abc123def456"  # If known
      order_id: "ORD-2024-001"
      
    Stripe Response:
      payment_intent_id: "pi_abc123def456ghi789"
      client_secret: "pi_abc123def456ghi789_secret_xyz"
      status: "requires_payment_method"
    ```
  </Step>

  <Step title="Payment Link Delivery">
    ```yaml theme={null}
    AI Integration:
      "The payment has been prepared. I will send you a secure payment link via email shortly.  
       The amount is €5,000 for the deposit on your CRM integration project."

    Follow-up Actions:
      - Email with Stripe-hosted checkout link  
      - SMS with payment link as fallback  
      - CRM update: Payment Intent created  
      - Sales team notification  
    ```
  </Step>
</Steps>

### Scenario 2: Subscription Upgrade

<AccordionGroup>
  <Accordion title="Plan Upgrade During Support Call">
    **Subscription Management**:

    ```yaml theme={null}
    Support Context:
      Customer: "I need more features. Can we upgrade immediately?"
      
    Payment Intent for Subscription:
      amount: 9900  # €99/month
      currency: "eur"
      description: "Upgrade to Professional Plan"
      metadata: {
        "subscription_type": "professional",
        "billing_cycle": "monthly",
        "upgrade_from": "basic",
        "effective_date": "2024-01-15"
      }

    Integration Workflow:
      1. Create Payment Intent  
      2. Move customer to premium subscription group  
      3. Activate feature flags after successful payment  
      4. Update billing system  
    ```
  </Accordion>

  <Accordion title="Installment Payment Plans">
    **Installment payments for large projects**:

    ```yaml theme={null}
    Enterprise Deal Context:
      Total: €50,000 enterprise license
      Payment plan: 3 installments of €16,667 each
      
    Payment Intent series:
      Installment 1 (immediate): amount: 1666700, description: "Installment 1/3 Enterprise License"
      Installment 2 (+30 days): Scheduled Payment Intent
      Installment 3 (+60 days): Scheduled Payment Intent
      
    Automation:
      - Successful installment 1 → Feature activation  
      - Scheduled installments → Automatic follow-up calls  
      - Payment failure → Account manager notification  
    ```
  </Accordion>
</AccordionGroup>

## Stripe Response Handling

### Successful Payment Intent Creation

```json theme={null}
{
  "id": "pi_abc123def456ghi789",
  "object": "payment_intent",
  "amount": 500000,
  "currency": "eur",
  "status": "requires_payment_method",
  "customer": "cus_abc123def456",
  "description": "Deposit Project CRM Integration",
  "client_secret": "pi_abc123def456ghi789_secret_xyz",
  "created": 1640995200,
  "metadata": {
    "order_id": "ORD-2024-001",
    "call_source": "mid_call_tool",
    "customer_phone": "+49123456789"
  },
  "next_action": {
    "type": "use_stripe_sdk"
  }
}
```

### Natural Language Integration

<AccordionGroup>
  <Accordion title="Agent Messages Before Payment Creation">
    **Template**: `"I am preparing the payment for {{amount}} {{currency}}..."`

    **Contextual Examples**:

    ```yaml theme={null}
    One-time Payment:
      "I am preparing the payment for €5,000..."

    Subscription:
      "I am setting up your monthly subscription for €99..."

    Deposit:
      "I am creating the payment link for your deposit of €2,500..."
    ```
  </Accordion>

  <Accordion title="Success Communication">
    **Template**: `"Payment has been prepared. Payment Intent ID: {{response.id}}"`

    **Customer-friendly variants**:

    ```yaml theme={null}
    With email follow-up:
      "Payment has been prepared. You will receive an email shortly  
       with the secure payment link for €5,000."

    With security assurance:
      "All payment data is securely processed via Stripe -  
       we do not store any credit card information."

    With next steps:
      "The payment link is ready to be sent. After payment, we will  
       immediately activate your new features."
    ```
  </Accordion>
</AccordionGroup>

## Compliance & Security

### PCI-DSS Compliance

<CardGroup cols={2}>
  <Card title="Secure Payment Handling" icon="shield-halved">
    **Best Practices**:

    * Never include credit card data in Mid-call Actions
    * Only create Payment Intents, no direct charging
    * Use Stripe-hosted checkout for secure entry
    * PCI Level 1 compliance ensured by Stripe
  </Card>

  <Card title="GDPR Compliance" icon="lock">
    **Data Privacy Aspects**:

    * Minimal metadata storage
    * Customer consent for payment processing
    * Audit trail of all payment activities
    * Right to deletion for payment metadata
  </Card>
</CardGroup>

### Webhook Integration for Payment Status

```yaml theme={null}
Stripe Webhook Events:
  payment_intent.succeeded:
    → Customer notification: "Payment received"
    → CRM update: Deal status "Paid"
    → Service activation: unlock features
    → Team notification: Payment confirmed
  
  payment_intent.payment_failed:
    → Customer support notification
    → Retry payment link sent
    → Account manager alert
    → Offer alternative payment methods
  
  payment_intent.canceled:
    → Set deal status to "Payment Canceled"
    → Follow-up task for sales team
    → Start customer retention workflow
```

## Advanced Stripe Features

### Subscription Management

<AccordionGroup>
  <Accordion title="Subscription Creation via Mid-Call">
    ```yaml theme={null}
    Subscription Workflow:
      
    Payment Intent for recurring payments:
      amount: 9900  # €99/month
      currency: "eur"
      setup_future_usage: "off_session"  # For recurring payments
      metadata: {
        "subscription_plan": "professional",
        "billing_interval": "monthly"
      }

    Customer Communication:
      "Your Professional subscription for €99 monthly will be set up.  
       After the first payment, all premium features will be activated."
    ```
  </Accordion>

  <Accordion title="Invoice Payment Integration">
    ```yaml theme={null}
    Invoice-based Payments:
      
    For B2B customers:
      - Payment Intent with payment_method_types: ["sepa_debit"]
      - Automatic invoice generation  
      - NET-30 payment terms
      
    Customer Experience:
      "For your company, we set up invoicing with 30-day payment terms.  
       You will receive the invoice via email."
    ```
  </Accordion>
</AccordionGroup>

<Warning>
  **Payment Security**: Never use Stripe secret keys in frontend code. Mid-call Actions run server-side and are therefore safe for secret key usage.
</Warning>

<Info>
  **Payment tip**: Combine Stripe Payment Intents with CRM integration for complete payment-to-revenue attribution. This allows precise ROI tracking of mid-call sales conversions.
</Info>

<Tip>
  Related pages: [Introduction](/en/automation-platform/introduction) and [Building Flows](/en/automation-platform/building-flows), and [Debugging Runs](/en/automation-platform/debugging-runs).
</Tip>

<Tip>
  Need a whole toolset instead of building HTTP actions one by one? Connect an external **MCP server** — tools are discovered automatically. See [MCP Servers](/en/platform/mcp-servers).
</Tip>
