# Valstorm Customer CRM Stripe Integration Plugin (`valstorm-plugin-stripe`) Connects a tenant's own **Stripe** account to Open Valstorm (`platform.stripe`) to synchronize Customers (`account`), Products (`product`), Prices (`price`), Subscriptions (`subscription`), Invoices (`invoice` & `invoice_item`), Billing Meters (`usage_meter`), and Credit Grants (`credit_grant`). > **Note:** This plugin is completely separate from `valstorm-plugin-billing` (Valstorm Cloud's internal Pay-As-You-Go SaaS billing engine). --- ## 🤖 Agent-Assisted Quick Setup (Let the Valstorm Agent Set It Up) ### 1. Minimal Human Prerequisite Install the Stripe CLI (`brew install stripe/stripe-cli/stripe && stripe login`) or grab a Stripe Secret/Restricted Key (`sk_live_...` / `rk_live_...`) from **Stripe Dashboard -> Developers -> API keys**. ### 2. Copy-Paste Prompt for Your Valstorm Agent ```text Set up the Stripe CRM plugin (`valstorm-plugin-stripe`) for my workspace using `plugins/valstorm-plugin-stripe/README.md`: 1. Save my Stripe API key and account ID via `stripe_save_credentials`. 2. Verify connectivity via `stripe_verify_connection`. 3. Run an initial historical sync of my Products, Prices, Customers, Subscriptions, and Invoices into Valstorm CRM via `stripe_sync_historical`. ``` --- ## 🛠️ End-to-End DIY Setup Guide ### Option A: Direct API Key (BYO Key — Fastest) 1. In the **Stripe Dashboard**, navigate to **Developers -> API keys** and create a Restricted Key or copy your Secret Key (`sk_live_...` or `sk_test_...`). 2. Save your credentials via REST (`POST /v1/stripe/credentials`) or Python: ```python await platform.stripe.save_credentials( api_key="sk_live_...", stripe_account_id="acct_123456789", webhook_secret="whsec_...", ) ``` ### Option B: Stripe Connect / Marketplace App OAuth 1. Configure platform Connect credentials in `.env` (`STRIPE_CLIENT_ID`, `STRIPE_SECRET_KEY`, `STRIPE_SIGNING_SECRET`, `STRIPE_WEBHOOK_SECRET`). 2. Direct users to `GET /v1/stripe/auth/login` -> callback `GET /v1/stripe/public/auth/callback`. 3. Register webhook endpoint `https:///v1/stripe/public/webhook` in Stripe Dashboard for `customer.*`, `product.*`, `price.*`, `invoice.*`, and `customer.subscription.*` events. ### Running Tests ```bash uv run --project apps/open-api pytest apps/open-api/tests/test_plugin_stripe.py -v ```