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

# Payments

> Add Stripe payments to your app — subscriptions, one-time payments, and billing management — all generated by AI.

Fabricate can add complete Stripe payment integrations to your app. Just describe the billing model you want, and the AI generates the full implementation.

<Warning>
  You'll need a Stripe account and API keys. Add your keys as environment secrets after Fabricate generates the payment code. See [Environment Secrets](/build/environment-secrets).
</Warning>

## Adding Payments

```
"Add Stripe subscription billing with monthly and annual plans:
- Basic: $9/month
- Pro: $29/month  
- Add a billing page where users can manage their subscription"
```

Or for one-time payments:

```
"Add a one-time payment flow — users pay $49 to unlock premium features permanently"
```

## What Gets Generated

**Stripe integration:**

* Stripe SDK configuration
* Price IDs mapped to your plan names
* Checkout session creation
* Webhook handler for payment events

**Database updates:**

* Subscription status stored on user records
* Payment history table (if requested)

**API routes:**

* `POST /api/billing/checkout` — creates Stripe checkout session
* `POST /api/billing/portal` — opens Stripe customer portal
* `POST /api/webhooks/stripe` — handles Stripe webhook events

**Frontend:**

* Pricing page with plan comparison
* Checkout flow with Stripe redirect
* Billing portal link for subscription management
* Subscription status gates for premium features

## Subscription Patterns

### Monthly/Annual Plans

```
"Add Pro ($19/mo or $190/yr) and Team ($49/mo or $490/yr) subscription tiers with annual discount"
```

### Per-Seat Pricing

```
"Add usage-based billing — $10 per user per month, manage seats from the account settings"
```

### Freemium with Upgrade

```
"Add a premium upgrade button. Free users get 3 projects, paid users ($12/month) get unlimited"
```

## Setting Up Your Stripe Keys

After Fabricate generates the payment code:

<Steps>
  <Step title="Get your Stripe keys">
    Log into your [Stripe Dashboard](https://dashboard.stripe.com). Go to Developers → API Keys.
  </Step>

  <Step title="Add keys as environment secrets">
    In Fabricate's Build settings, add:

    * `STRIPE_SECRET_KEY` — your Stripe secret key
    * `STRIPE_WEBHOOK_SECRET` — your webhook signing secret
  </Step>

  <Step title="Set up webhooks in Stripe">
    In Stripe, add a webhook endpoint pointing to `https://your-app.fabricate.build/api/webhooks/stripe`.
    Listen for: `checkout.session.completed`, `customer.subscription.updated`, `customer.subscription.deleted`.
  </Step>
</Steps>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Does Fabricate handle PCI compliance?">
    Yes — Stripe handles all card data. Your app never sees or stores raw card numbers. Stripe is PCI DSS Level 1 certified.
  </Accordion>

  <Accordion title="Can I add multiple payment methods?">
    Stripe supports many payment methods (cards, Apple Pay, Google Pay, etc.). Ask Fabricate to enable specific payment methods you want.
  </Accordion>

  <Accordion title="Can I offer a free trial?">
    Yes: "Add a 14-day free trial before the subscription starts — no credit card required until the trial ends."
  </Accordion>

  <Accordion title="Can I test payments without real money?">
    Yes. Use Stripe's test mode keys during development. Test with card number 4242 4242 4242 4242.
  </Accordion>
</AccordionGroup>
