[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71KQ8DV93FJMZCX5SZMYX0Z":3,"skill-same:01M71KQ8DV93FJMZCX5SZMYX0Z":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M71KQ8DV93FJMZCX5SZMYX0Z","stripe",null,"Guidelines for using Stripe to integrate payments in mobile apps and any subsequent CRUD operations related to any Stripe entities","clawdsolana\u002FOpenClawd","clawdsolana","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F279036008?v=4","01M71JTVF9FNGKE2SVJRPTQM31","OpenClawd","01M71JTVGCKWBSS8ZYC1HYWVA5",2,"MIT","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fstripe\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27],"for","guidelines","payments","entities","apps","crud","operations","mobile","integrate","2026-11-10 10:56:23",false,"---\nname: stripe\ndescription: Guidelines for using Stripe to integrate payments in mobile apps and any subsequent CRUD operations related to any Stripe entities\n---\n\n## Introduction\n\nReplit offers a native integration with Stripe that allows users to implement payments in their applications\n\n## Prerequisites\n\n1. These packages must be installed in the workspace root package.json:\n    - `stripe` - Official Stripe SDK for API operations\n    - `stripe-replit-sync` - Handles webhook processing and database sync. Documentation: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fstripe-replit-sync\n\n    If they are not installed, use npm to install them: `$ cd \u002Fhome\u002Frunner\u002Fworkspace && npm install \u003Cpackages>`\n\n\n2. The Stripe integration must be connected to the repl. You can do this by proposing the integration. Reference the `integrations` skill if necessary.\n    Once connected, create `stripeClient.ts` using the template from the code-templates reference -- this file fetches Stripe credentials from the Replit connection API and provides the authenticated client via `getUncachableStripeClient()`.\n\n    Create it in the `server\u002F` directory.\n\n\n3. Ensure a PostgreSQL database exists. If you don't have one yet, use the tool to create a PostgreSQL database. Never use memory database for storing Stripe data.\n\nYou are required to ensure these requirements are met before setting up or using Stripe.\n\n## Project Structure\n\n- **Scripts directory**: `scripts\u002F` at the workspace root (e.g., `scripts\u002Fseed-products.ts`)\n- **Run a script**: `npx tsx scripts\u002F\u003Cscript>.ts`\n- **API server directory**: `server\u002F`\n- **Client app directory**: `client\u002F`\n\nReference files use these terms. Map them to these concrete paths.\n\n## Initial Setup: Step-by-Step Implementation\n\nEnsure prerequisites are met. Do not proceed until you have done so.\n\nFollow these steps in order when implementing Stripe integration for the user. Create a task list to track implementation progress.\n\nRead the code-templates reference file for full code file templates to use during these steps.\n\n1. Set Up Database\n\n    Create the users table with Stripe ID references:\n\n    ```sql\n    CREATE TABLE users (\n      id TEXT PRIMARY KEY,\n      email TEXT,\n      stripe_customer_id TEXT,\n      stripe_subscription_id TEXT,\n      created_at TIMESTAMP DEFAULT NOW()\n    );\n    ```\n\n    **Important**: stripe-replit-sync creates the `stripe` schema automatically. Create application tables (users, orders, etc.) in the public schema, not in the stripe schema.\n\n2. Create Webhook Handler\n\n    In the API server create `webhookHandlers.ts` - use the template provided in the code-templates reference. It handles webhook processing by calling `getStripeSync()` from stripeClient.\n\n3. Initialize Stripe on Startup\n\n    Add this initialization function to the API server's index.ts. **Important order:**\n\n    1. Run migrations to create schema\n    2. Get StripeSync instance\n    3. Set up managed webhook (uses StripeSync)\n    4. Sync existing data with syncBackfill()\n\n    ```typescript\n    import { runMigrations } from 'stripe-replit-sync';\n    import { getStripeSync } from '.\u002FstripeClient';\n\n    async function initStripe() {\n      const databaseUrl = process.env.DATABASE_URL;\n      if (!databaseUrl) throw new Error('DATABASE_URL required');\n\n      \u002F\u002F 1. Create stripe schema and tables\n      await runMigrations({ databaseUrl });\n\n      \u002F\u002F 2. Get StripeSync instance (needed for webhook setup and backfill)\n      const stripeSync = await getStripeSync();\n\n      \u002F\u002F 3. Set up managed webhook\n      const webhookBaseUrl = `https:\u002F\u002F${process.env.REPLIT_DOMAINS?.split(',')[0]}`;\n      const { webhook } = await stripeSync.findOrCreateManagedWebhook(\n        `${webhookBaseUrl}\u002Fapi\u002Fstripe\u002Fwebhook`\n      );\n\n      \u002F\u002F 4. Sync all existing Stripe data\n      await stripeSync.syncBackfill();\n    }\n\n    await initStripe();\n    ```\n\n4. Register Webhook Route in index.ts\n\n    **Critical:** Register the webhook route BEFORE `express.json()` middleware. See the indexTemplate for the correct pattern:\n\n    1. Route path is `\u002Fapi\u002Fstripe\u002Fwebhook`\n    2. Webhook route uses `express.raw()` to get Buffer in `req.body`\n    3. Webhook route is registered BEFORE `app.use(express.json())`\n    4. Other routes registered after get parsed JSON automatically\n\n    ```typescript\n    app.post(\n      '\u002Fapi\u002Fstripe\u002Fwebhook',\n      express.raw({ type: 'application\u002Fjson' }),\n      async (req, res) => {\n        const signature = req.headers['stripe-signature'];\n        if (!signature) return res.status(400).json({ error: 'Missing signature' });\n\n        const sig = Array.isArray(signature) ? signature[0] : signature;\n\n        await WebhookHandlers.processWebhook(req.body as Buffer, sig);\n        res.status(200).json({ received: true });\n      }\n    );\n\n    app.use(express.json()); \u002F\u002F Now apply to other routes\n    ```\n\n5. Create Storage Layer\n\n    Create `storage.ts` - use the template provided in the code-templates reference. Query Stripe data from PostgreSQL `stripe` schema using standard SQL queries.\n\n6. Set Up Other Routes\n\n    Create `routes.ts` - use the template provided in the code-templates reference for products, prices, checkout, etc. These routes are registered AFTER `express.json()` so they get parsed JSON.\n\n7. Create Products Script (Recommended)\n\n    Create `seed-products.ts` - a script to add products and prices to Stripe via the API. **This is the recommended way to create products. Run it manually when creating products.**\n\n    Use the seed-products template from the code-templates reference as a starting point:\n\n    - Modify the script to create the specific products needed\n    - Run it manually when adding products: `node seed-products.js`\n    - Webhooks automatically sync created products to the database\n    - Stripe handles test vs live mode based on API keys\n\n    ```typescript\n    import { getUncachableStripeClient } from '.\u002FstripeClient';\n\n    async function createProducts() {\n      const stripe = await getUncachableStripeClient();\n\n      \u002F\u002F Create product\n      const product = await stripe.products.create({\n        name: 'Pro Plan',\n        description: 'Professional subscription',\n      });\n\n      \u002F\u002F Create prices for the product\n      const monthlyPrice = await stripe.prices.create({\n        product: product.id,\n        unit_amount: 2900, \u002F\u002F $29.00\n        currency: 'usd',\n        recurring: { interval: 'month' },\n      });\n\n      console.log('Created:', product.id, monthlyPrice.id);\n    }\n\n    createProducts();\n    ```\n\n    **Usage:**\n    Run this script in development when you need to create or add products.\n\n    **Optional idempotency:**\n    To make the script safe to run multiple times, check if specific products exist first:\n\n    ```typescript\n    const products = await stripe.products.search({ query: \"name:'Pro Plan'\" });\n    if (products.data.length > 0) {\n      console.log('Pro Plan already exists');\n      return;\n    }\n    ```\n\n## Database Architecture\n\n1. **stripe-replit-sync creates and manages the `stripe` schema automatically** - DO NOT create any tables in the stripe schema\n2. The stripe schema contains tables for: products, prices, customers, subscriptions, payment_intents, etc.\n3. **Application tables are created in the public schema (or other schemas)** - e.g., users, orders, etc.\n4. Application tables store Stripe IDs as TEXT columns (e.g., `stripe_customer_id TEXT`, `stripe_subscription_id TEXT`)\n5. Replit automatically handles deployment and Stripe data migration moving from sandbox to live.\n\n## Synchronization Flow\n\n1. Stripe credentials are fetched from Replit connection API\n2. **`runMigrations()`** creates the stripe schema and all Stripe tables (idempotent, safe to run on every startup)\n3. **`syncBackfill()`** syncs ALL existing Stripe data from Stripe API to the local PostgreSQL database on startup\n4. **Managed webhooks** are automatically configured by `stripe-replit-sync`\n5. **Webhooks** keep data up-to-date when changes occur in Stripe after startup\n6. Application queries Stripe data from PostgreSQL `stripe` schema (fast, no API calls needed)\n\n## Storing Data\n\nDo NOT Create Product Tables or Maintain Any Other Source of Truth for Stripe Data\n\n**Bad** -- creates duplicate product storage:\n\n```ts\nexport const products = pgTable(\"products\", {\n  id: varchar(\"id\").primaryKey(),\n  name: text(\"name\"),\n  price: integer(\"price\"),\n  \u002F\u002F ... custom fields\n});\n```\n\nCorrect Approach:\n\n- NO product tables needed!\n- Query directly from `stripe.products` and `stripe.prices`\n- Use Stripe's metadata field for ALL custom attributes\n\n### Creating Products and Prices\n\n**NEVER insert data directly into the stripe schema tables.** Instead:\n- Create products via Stripe API (using scripts)\n- Stripe webhooks managed by stripe-replit-sync automatically sync the data to the stripe schema in the local database\n- Query the synced data from the `stripe` schema tables using standard SQL queries\n\nCreate products in Stripe with metadata (use API or script):\n\n```ts\nawait stripe.products.create({\n  name: \"Product Name\",\n  description: \"...\",\n  images: [\"https:\u002F\u002F...\"],\n  metadata: {\n    category: \"electronics\",\n    customField1: \"value1\",\n    featured: \"true\",\n  }\n});\nawait stripe.prices.create({\n  product: product.id,\n  unit_amount: 9999,\n  currency: 'usd',\n});\n```\n\nQuery from synced stripe tables:\n\n```ts\nconst result = await db.execute(sql`\n  SELECT\n    p.id,\n    p.name,\n    p.metadata,\n    pr.id as price_id,\n    pr.unit_amount\n  FROM stripe.products p\n  JOIN stripe.prices pr ON pr.product = p.id\n  WHERE p.active = true\n`);\n```\n\nUse real Stripe price IDs in checkout:\n\n```ts\n\u002F\u002F CORRECT\n{ price: \"price_1ABC...\", quantity: 1 }\n\u002F\u002F WRONG - Never use price_data\n{\n  price_data: {\n    unit_amount: 9999,\n    currency: 'usd',\n    product_data: { name: \"...\" }\n  }\n}\n```\n\n### Decision Tree: When to Create Tables\n\n- Products\u002FPrices? -- NO, use `stripe.products`\u002F`stripe.prices`\n- Customers? -- NO, use `stripe.customers`\n- Subscriptions? -- NO, use `stripe.subscriptions`\n- Orders\u002FCart\u002FUser preferences? -- YES, these aren't in Stripe\n- Relationships to Stripe data? -- YES, store Stripe IDs as foreign keys\n\n**Key Principle: \"If it exists in Stripe, it belongs in Stripe\"**\n\n- Don't duplicate Stripe data in your own tables\n- Don't create parallel storage systems\n- Stripe + metadata = your complete product catalog\n- Your tables should only store data that Stripe doesn't manage\n\n**Creating products:**\nWrite a seed script that calls Stripe API (`stripe.products.create()`, `stripe.prices.create()`). Run this script in development to create your products. Webhooks automatically sync them to the database. Replit handles deployment automatically.\n\n**Workflow:**\n\n```bash\n# Development:\n# - Run seed script to create products in Stripe (test mode)\n# - syncBackfill() syncs them to local database\n\n# Deployment (handled by Replit):\n# - Replit copies products\u002Fprices from dev Stripe to prod Stripe\n# - Your code runs unchanged, syncBackfill() syncs prod database\n\n# Production:\n# - Modify products via Stripe Dashboard (scripts can't run in deployments)\n# - Webhooks automatically sync changes to database\n```\n\n## Publishing with Stripe\n\nTo publish the app with working Stripe payments:\n\n1. Go to the Stripe Dashboard (https:\u002F\u002Fdashboard.stripe.com\u002Fapikeys)\n2. Get live API keys (starts with `pk_live_` and `sk_live_`)\n3. Open the Publish pane in the Workspace\n4. Enter the live Publishable Key and Secret Key\n5. Publish the app\n\n**Placeholder Keys (User-Requested Only):**\n\nOnly offer placeholder keys if the user explicitly asks to publish without live Stripe keys and understands the consequences. Do NOT use these for any other purpose.\n\nIf the user confirms they want to proceed without live keys, suggest the following values to them:\n- **Publishable Key:** `pk_live_abcdef`\n- **Secret Key:** `sk_live_abcdef`\n\n**Consequences the user must understand:**\n- Placeholder keys will NOT process real payments\n- The product catalog and checkout will not function on the published URL\n- Real Stripe keys must be added later for payments to work\n\n## Deleting Stripe Integration\n\nTo remove the Stripe integration from the project:\n\n1. In the project, open the \"Integrations\" tab\n2. Go to \"Stripe\" and click \"Manage\"\n3. Select \"Edit\" then \"Delete\"\n\n## Secrets and Environment Variables\n\n**NEVER write secrets or environment variables directly to the `.replit` file.** This includes Stripe API keys, webhook signing secrets, database URLs, and any other sensitive configuration. Instead, reference the `environment-secrets` skill for the correct way to manage secrets and environment variables.\n\n## Key Rules\n\n**DO:**\n- Create products via Stripe API using scripts (never with SQL INSERT)\n- Query Stripe data from PostgreSQL `stripe` schema tables (products, prices, customers, subscriptions, etc.)\n- Store Stripe IDs in application tables as TEXT (e.g., `stripe_customer_id TEXT`)\n- Keep webhook handler minimal (just call `processWebhook` with payload and signature)\n- Let `syncBackfill()` sync existing Stripe data on startup\n- Let managed webhooks handle webhook configuration automatically\n- Register webhook route BEFORE `express.json()` middleware\n\n**ABSOLUTELY DO NOT:**\n- Create any tables in the `stripe` schema - stripe-replit-sync manages this automatically\n- Insert, update, or delete data in `stripe` schema tables - only query from them\n- Use SQL INSERT for products, prices, customers, subscriptions - use Stripe API instead\n- Manually copy database data between environments - Replit handles Stripe product\u002Fprice copying during deployment\n- Add custom logic in webhook handler beyond calling `processWebhook`\n- Skip running `runMigrations()` or `syncBackfill()`\n- Create StripeSync instance before calling `runMigrations()`\n\n## Common Mistakes\n\n**Database - DO NOT create Stripe tables:**\n\n```sql\n-- WRONG - Creating Stripe tables manually\nCREATE TABLE products (\n  id TEXT PRIMARY KEY,\n  name TEXT,\n  price INTEGER\n);\n\n-- CORRECT - Create application tables, store Stripe IDs\nCREATE TABLE users (\n  id TEXT PRIMARY KEY,\n  stripe_customer_id TEXT\n);\n-- stripe-replit-sync creates stripe.products, stripe.prices, etc. automatically\n```\n\n**Data Creation - Use Stripe API Scripts, NOT SQL:**\n\n```sql\n-- WRONG - Inserting Stripe data with SQL\nINSERT INTO stripe.products (id, name, description)\nVALUES ('prod_123', 'Pro Plan', 'Professional subscription');\n```\n\n```typescript\n\u002F\u002F CORRECT - Use Stripe API in a script\nconst stripe = await getUncachableStripeClient();\nconst product = await stripe.products.create({\n  name: 'Pro Plan',\n  description: 'Professional subscription',\n});\n\u002F\u002F Webhook syncs this to stripe.products automatically\n```\n\n**Initialization Order:**\n\n```typescript\n\u002F\u002F WRONG - Creating StripeSync before migrations\nconst stripeSync = await getStripeSync();\nawait runMigrations({ databaseUrl });\n\n\u002F\u002F CORRECT - Migrations first, then StripeSync\nawait runMigrations({ databaseUrl });\nconst stripeSync = await getStripeSync();\nawait stripeSync.findOrCreateManagedWebhook(...);\nawait stripeSync.syncBackfill();\n```\n\n**Frontend - Must parse JSON responses:**\n\n```typescript\n\u002F\u002F WRONG - returns Response object\nconst response = await apiRequest('POST', '\u002Fapi\u002Fcheckout', { priceId });\nreturn response;\n\n\u002F\u002F CORRECT - parse to get data\nconst response = await apiRequest('POST', '\u002Fapi\u002Fcheckout', { priceId });\nreturn await response.json();\n```\n\n**Backend - Webhook route ordering:**\n\n```typescript\n\u002F\u002F WRONG - Webhook after express.json()\napp.use(express.json());\napp.post('\u002Fapi\u002Fstripe\u002Fwebhook', ...);  \u002F\u002F Too late! Body already parsed\n\n\u002F\u002F CORRECT - Webhook BEFORE express.json()\napp.post('\u002Fapi\u002Fstripe\u002Fwebhook', express.raw({ type: 'application\u002Fjson' }),\n  async (req, res) => {\n    await WebhookHandlers.processWebhook(req.body, sig);\n  }\n);\napp.use(express.json());  \u002F\u002F Now apply to other routes\n```\n\n## References\n\n- .\u002Freferences\u002Fcode-templates.md -- Code file templates for initial Stripe setup. ONLY read this reference when performing initial setup of Stripe in a project that does not already have it configured. Do not read for subsequent modifications, queries, or other Stripe operations.\n","## Introduction\n\nReplit offers a native integration with Stripe that allows users to implement payments in their applications\n\n## Prerequisites\n\n1. These packages must be installed in the workspace root package.json:\n    - `stripe` - Official Stripe SDK for API operations\n    - `stripe-replit-sync` - Handles webhook processing and database sync. Documentation: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fstripe-replit-sync\n\n    If they are not installed, use npm to install them: `$ cd \u002Fhome\u002Frunner\u002Fworkspace && npm install \u003Cpackages>`\n\n\n2. The Stripe integration must be connected to the repl. You can do this by proposing the integration. Reference the `integrations` skill if necessary.\n    Once connected, create `stripeClient.ts` using the template from the code-templates reference -- this file fetches Stripe credentials from the Replit connection API and provides the authenticated client via `getUncachableStripeClient()`.\n\n    Create it in the `server\u002F` directory.\n\n\n3. Ensure a PostgreSQL database exists. If you don't have one yet, use the tool to create a PostgreSQL database. Never use memory database for storing Stripe data.\n\nYou are required to ensure these requirements are met before setting up or using Stripe.\n\n## Project Structure\n\n- **Scripts directory**: `scripts\u002F` at the workspace root (e.g., `scripts\u002Fseed-products.ts`)\n- **Run a script**: `npx tsx scripts\u002F\u003Cscript>.ts`\n- **API server directory**: `server\u002F`\n- **Client app directory**: `client\u002F`\n\nReference files use these terms. Map them to these concrete paths.\n\n## Initial Setup: Step-by-Step Implementation\n\nEnsure prerequisites are met. Do not proceed until you have done so.\n\nFollow these steps in order when implementing Stripe integration for the user. Create a task list to track implementation progress.\n\nRead the code-templates reference file for full code file templates to use during these steps.\n\n1. Set Up Database\n\n    Create the users table with Stripe ID references:\n\n    ```sql\n    CREATE TABLE users (\n      id TEXT PRIMARY KEY,\n      email TEXT,\n      stripe_customer_id TEXT,\n      stripe_subscription_id TEXT,\n      created_at TIMESTAMP DEFAULT NOW()\n    );\n    ```\n\n    **Important**: stripe-replit-sync creates the `stripe` schema automatically. Create application tables (users, orders, etc.) in the public schema, not in the stripe schema.\n\n2. Create Webhook Handler\n\n    In the API server create `webhookHandlers.ts` - use the template provided in the code-templates reference. It handles webhook processing by calling `getStripeSync()` from stripeClient.\n\n3. Initialize Stripe on Startup\n\n    Add this initialization function to the API server's index.ts. **Important order:**\n\n    1. Run migrations to create schema\n    2. Get StripeSync instance\n    3. Set up managed webhook (uses StripeSync)\n    4. Sync existing data with syncBackfill()\n\n    ```typescript\n    import { runMigrations } from 'stripe-replit-sync';\n    import { getStripeSync } from '.\u002FstripeClient';\n\n    async function initStripe() {\n      const databaseUrl = process.env.DATABASE_URL;\n      if (!databaseUrl) throw new Error('DATABASE_URL required');\n\n      \u002F\u002F 1. Create stripe schema and tables\n      await runMigrations({ databaseUrl });\n\n      \u002F\u002F 2. Get StripeSync instance (needed for webhook setup and backfill)\n      const stripeSync = await getStripeSync();\n\n      \u002F\u002F 3. Set up managed webhook\n      const webhookBaseUrl = `https:\u002F\u002F${process.env.REPLIT_DOMAINS?.split(',')[0]}`;\n      const { webhook } = await stripeSync.findOrCreateManagedWebhook(\n        `${webhookBaseUrl}\u002Fapi\u002Fstripe\u002Fwebhook`\n      );\n\n      \u002F\u002F 4. Sync all existing Stripe data\n      await stripeSync.syncBackfill();\n    }\n\n    await initStripe();\n    ```\n\n4. Register Webhook Route in index.ts\n\n    **Critical:** Register the webhook route BEFORE `express.json()` middleware. See the indexTemplate for the correct pattern:\n\n    1. Route path is `\u002Fapi\u002Fstripe\u002Fwebhook`\n    2. Webhook route uses `express.raw()` to get Buffer in `req.body`\n    3. Webhook route is registered BEFORE `app.use(express.json())`\n    4. Other routes registered after get parsed JSON automatically\n\n    ```typescript\n    app.post(\n      '\u002Fapi\u002Fstripe\u002Fwebhook',\n      express.raw({ type: 'application\u002Fjson' }),\n      async (req, res) => {\n        const signature = req.headers['stripe-signature'];\n        if (!signature) return res.status(400).json({ error: 'Missing signature' });\n\n        const sig = Array.isArray(signature) ? signature[0] : signature;\n\n        await WebhookHandlers.processWebhook(req.body as Buffer, sig);\n        res.status(200).json({ received: true });\n      }\n    );\n\n    app.use(express.json()); \u002F\u002F Now apply to other routes\n    ```\n\n5. Create Storage Layer\n\n    Create `storage.ts` - use the template provided in the code-templates reference. Query Stripe data from PostgreSQL `stripe` schema using standard SQL queries.\n\n6. Set Up Other Routes\n\n    Create `routes.ts` - use the template provided in the code-templates reference for products, prices, checkout, etc. These routes are registered AFTER `express.json()` so they get parsed JSON.\n\n7. Create Products Script (Recommended)\n\n    Create `seed-products.ts` - a script to add products and prices to Stripe via the API. **This is the recommended way to create products. Run it manually when creating products.**\n\n    Use the seed-products template from the code-templates reference as a starting point:\n\n    - Modify the script to create the specific products needed\n    - Run it manually when adding products: `node seed-products.js`\n    - Webhooks automatically sync created products to the database\n    - Stripe handles test vs live mode based on API keys\n\n    ```typescript\n    import { getUncachableStripeClient } from '.\u002FstripeClient';\n\n    async function createProducts() {\n      const stripe = await getUncachableStripeClient();\n\n      \u002F\u002F Create product\n      const product = await stripe.products.create({\n        name: 'Pro Plan',\n        description: 'Professional subscription',\n      });\n\n      \u002F\u002F Create prices for the product\n      const monthlyPrice = await stripe.prices.create({\n        product: product.id,\n        unit_amount: 2900, \u002F\u002F $29.00\n        currency: 'usd',\n        recurring: { interval: 'month' },\n      });\n\n      console.log('Created:', product.id, monthlyPrice.id);\n    }\n\n    createProducts();\n    ```\n\n    **Usage:**\n    Run this script in development when you need to create or add products.\n\n    **Optional idempotency:**\n    To make the script safe to run multiple times, check if specific products exist first:\n\n    ```typescript\n    const products = await stripe.products.search({ query: \"name:'Pro Plan'\" });\n    if (products.data.length > 0) {\n      console.log('Pro Plan already exists');\n      return;\n    }\n    ```\n\n## Database Architecture\n\n1. **stripe-replit-sync creates and manages the `stripe` schema automatically** - DO NOT create any tables in the stripe schema\n2. The stripe schema contains tables for: products, prices, customers, subscriptions, payment_intents, etc.\n3. **Application tables are created in the public schema (or other schemas)** - e.g., users, orders, etc.\n4. Application tables store Stripe IDs as TEXT columns (e.g., `stripe_customer_id TEXT`, `stripe_subscription_id TEXT`)\n5. Replit automatically handles deployment and Stripe data migration moving from sandbox to live.\n\n## Synchronization Flow\n\n1. Stripe credentials are fetched from Replit connection API\n2. **`runMigrations()`** creates the stripe schema and all Stripe tables (idempotent, safe to run on every startup)\n3. **`syncBackfill()`** syncs ALL existing Stripe data from Stripe API to the local PostgreSQL database on startup\n4. **Managed webhooks** are automatically configured by `stripe-replit-sync`\n5. **Webhooks** keep data up-to-date when changes occur in Stripe after startup\n6. Application queries Stripe data from PostgreSQL `stripe` schema (fast, no API calls needed)\n\n## Storing Data\n\nDo NOT Create Product Tables or Maintain Any Other Source of Truth for Stripe Data\n\n**Bad** -- creates duplicate product storage:\n\n```ts\nexport const products = pgTable(\"products\", {\n  id: varchar(\"id\").primaryKey(),\n  name: text(\"name\"),\n  price: integer(\"price\"),\n  \u002F\u002F ... custom fields\n});\n```\n\nCorrect Approach:\n\n- NO product tables needed!\n- Query directly from `stripe.products` and `stripe.prices`\n- Use Stripe's metadata field for ALL custom attributes\n\n### Creating Products and Prices\n\n**NEVER insert data directly into the stripe schema tables.** Instead:\n- Create products via Stripe API (using scripts)\n- Stripe webhooks managed by stripe-replit-sync automatically sync the data to the stripe schema in the local database\n- Query the synced data from the `stripe` schema tables using standard SQL queries\n\nCreate products in Stripe with metadata (use API or script):\n\n```ts\nawait stripe.products.create({\n  name: \"Product Name\",\n  description: \"...\",\n  images: [\"https:\u002F\u002F...\"],\n  metadata: {\n    category: \"electronics\",\n    customField1: \"value1\",\n    featured: \"true\",\n  }\n});\nawait stripe.prices.create({\n  product: product.id,\n  unit_amount: 9999,\n  currency: 'usd',\n});\n```\n\nQuery from synced stripe tables:\n\n```ts\nconst result = await db.execute(sql`\n  SELECT\n    p.id,\n    p.name,\n    p.metadata,\n    pr.id as price_id,\n    pr.unit_amount\n  FROM stripe.products p\n  JOIN stripe.prices pr ON pr.product = p.id\n  WHERE p.active = true\n`);\n```\n\nUse real Stripe price IDs in checkout:\n\n```ts\n\u002F\u002F CORRECT\n{ price: \"price_1ABC...\", quantity: 1 }\n\u002F\u002F WRONG - Never use price_data\n{\n  price_data: {\n    unit_amount: 9999,\n    currency: 'usd',\n    product_data: { name: \"...\" }\n  }\n}\n```\n\n### Decision Tree: When to Create Tables\n\n- Products\u002FPrices? -- NO, use `stripe.products`\u002F`stripe.prices`\n- Customers? -- NO, use `stripe.customers`\n- Subscriptions? -- NO, use `stripe.subscriptions`\n- Orders\u002FCart\u002FUser preferences? -- YES, these aren't in Stripe\n- Relationships to Stripe data? -- YES, store Stripe IDs as foreign keys\n\n**Key Principle: \"If it exists in Stripe, it belongs in Stripe\"**\n\n- Don't duplicate Stripe data in your own tables\n- Don't create parallel storage systems\n- Stripe + metadata = your complete product catalog\n- Your tables should only store data that Stripe doesn't manage\n\n**Creating products:**\nWrite a seed script that calls Stripe API (`stripe.products.create()`, `stripe.prices.create()`). Run this script in development to create your products. Webhooks automatically sync them to the database. Replit handles deployment automatically.\n\n**Workflow:**\n\n```bash\n# Development:\n# - Run seed script to create products in Stripe (test mode)\n# - syncBackfill() syncs them to local database\n\n# Deployment (handled by Replit):\n# - Replit copies products\u002Fprices from dev Stripe to prod Stripe\n# - Your code runs unchanged, syncBackfill() syncs prod database\n\n# Production:\n# - Modify products via Stripe Dashboard (scripts can't run in deployments)\n# - Webhooks automatically sync changes to database\n```\n\n## Publishing with Stripe\n\nTo publish the app with working Stripe payments:\n\n1. Go to the Stripe Dashboard (https:\u002F\u002Fdashboard.stripe.com\u002Fapikeys)\n2. Get live API keys (starts with `pk_live_` and `sk_live_`)\n3. Open the Publish pane in the Workspace\n4. Enter the live Publishable Key and Secret Key\n5. Publish the app\n\n**Placeholder Keys (User-Requested Only):**\n\nOnly offer placeholder keys if the user explicitly asks to publish without live Stripe keys and understands the consequences. Do NOT use these for any other purpose.\n\nIf the user confirms they want to proceed without live keys, suggest the following values to them:\n- **Publishable Key:** `pk_live_abcdef`\n- **Secret Key:** `sk_live_abcdef`\n\n**Consequences the user must understand:**\n- Placeholder keys will NOT process real payments\n- The product catalog and checkout will not function on the published URL\n- Real Stripe keys must be added later for payments to work\n\n## Deleting Stripe Integration\n\nTo remove the Stripe integration from the project:\n\n1. In the project, open the \"Integrations\" tab\n2. Go to \"Stripe\" and click \"Manage\"\n3. Select \"Edit\" then \"Delete\"\n\n## Secrets and Environment Variables\n\n**NEVER write secrets or environment variables directly to the `.replit` file.** This includes Stripe API keys, webhook signing secrets, database URLs, and any other sensitive configuration. Instead, reference the `environment-secrets` skill for the correct way to manage secrets and environment variables.\n\n## Key Rules\n\n**DO:**\n- Create products via Stripe API using scripts (never with SQL INSERT)\n- Query Stripe data from PostgreSQL `stripe` schema tables (products, prices, customers, subscriptions, etc.)\n- Store Stripe IDs in application tables as TEXT (e.g., `stripe_customer_id TEXT`)\n- Keep webhook handler minimal (just call `processWebhook` with payload and signature)\n- Let `syncBackfill()` sync existing Stripe data on startup\n- Let managed webhooks handle webhook configuration automatically\n- Register webhook route BEFORE `express.json()` middleware\n\n**ABSOLUTELY DO NOT:**\n- Create any tables in the `stripe` schema - stripe-replit-sync manages this automatically\n- Insert, update, or delete data in `stripe` schema tables - only query from them\n- Use SQL INSERT for products, prices, customers, subscriptions - use Stripe API instead\n- Manually copy database data between environments - Replit handles Stripe product\u002Fprice copying during deployment\n- Add custom logic in webhook handler beyond calling `processWebhook`\n- Skip running `runMigrations()` or `syncBackfill()`\n- Create StripeSync instance before calling `runMigrations()`\n\n## Common Mistakes\n\n**Database - DO NOT create Stripe tables:**\n\n```sql\n-- WRONG - Creating Stripe tables manually\nCREATE TABLE products (\n  id TEXT PRIMARY KEY,\n  name TEXT,\n  price INTEGER\n);\n\n-- CORRECT - Create application tables, store Stripe IDs\nCREATE TABLE users (\n  id TEXT PRIMARY KEY,\n  stripe_customer_id TEXT\n);\n-- stripe-replit-sync creates stripe.products, stripe.prices, etc. automatically\n```\n\n**Data Creation - Use Stripe API Scripts, NOT SQL:**\n\n```sql\n-- WRONG - Inserting Stripe data with SQL\nINSERT INTO stripe.products (id, name, description)\nVALUES ('prod_123', 'Pro Plan', 'Professional subscription');\n```\n\n```typescript\n\u002F\u002F CORRECT - Use Stripe API in a script\nconst stripe = await getUncachableStripeClient();\nconst product = await stripe.products.create({\n  name: 'Pro Plan',\n  description: 'Professional subscription',\n});\n\u002F\u002F Webhook syncs this to stripe.products automatically\n```\n\n**Initialization Order:**\n\n```typescript\n\u002F\u002F WRONG - Creating StripeSync before migrations\nconst stripeSync = await getStripeSync();\nawait runMigrations({ databaseUrl });\n\n\u002F\u002F CORRECT - Migrations first, then StripeSync\nawait runMigrations({ databaseUrl });\nconst stripeSync = await getStripeSync();\nawait stripeSync.findOrCreateManagedWebhook(...);\nawait stripeSync.syncBackfill();\n```\n\n**Frontend - Must parse JSON responses:**\n\n```typescript\n\u002F\u002F WRONG - returns Response object\nconst response = await apiRequest('POST', '\u002Fapi\u002Fcheckout', { priceId });\nreturn response;\n\n\u002F\u002F CORRECT - parse to get data\nconst response = await apiRequest('POST', '\u002Fapi\u002Fcheckout', { priceId });\nreturn await response.json();\n```\n\n**Backend - Webhook route ordering:**\n\n```typescript\n\u002F\u002F WRONG - Webhook after express.json()\napp.use(express.json());\napp.post('\u002Fapi\u002Fstripe\u002Fwebhook', ...);  \u002F\u002F Too late! Body already parsed\n\n\u002F\u002F CORRECT - Webhook BEFORE express.json()\napp.post('\u002Fapi\u002Fstripe\u002Fwebhook', express.raw({ type: 'application\u002Fjson' }),\n  async (req, res) => {\n    await WebhookHandlers.processWebhook(req.body, sig);\n  }\n);\napp.use(express.json());  \u002F\u002F Now apply to other routes\n```\n\n## References\n\n- .\u002Freferences\u002Fcode-templates.md -- Code file templates for initial Stripe setup. ONLY read this reference when performing initial setup of Stripe in a project that does not already have it configured. Do not read for subsequent modifications, queries, or other Stripe operations.\n",{"name":5,"description":7},"main","6b4a291df75c639681e93b4b5b812126443fd6ed","skills\u002Fstripe",3,"https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd","https:\u002F\u002Fsolanaclawd.com\u002Fopenclawd","https:\u002F\u002Fgithub.com\u002Fclawdsolana","https:\u002F\u002Fmusebook.trade","Welcome to Open Clawd. The future of Ai on and off chain. Bringing webMCP to web 3 using X402, A2A, MPP and so much more!","2026-08-01 09:30:51",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add clawdsolana\u002FOpenClawd --skill stripe",{"tool":49,"command":50},"bunx","bunx skills add clawdsolana\u002FOpenClawd --skill stripe",{"tool":52,"command":53},"pnpm","pnpm dlx skills add clawdsolana\u002FOpenClawd --skill stripe","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fstripe\u002FSKILL.md",true,[57,63],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},".fingerprint","OTHER","其他",32,"https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fstripe\u002F.fingerprint",{"path":64,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fcode-templates.md","REFERENCE","参考文档",17428,"https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fstripe\u002Freferences\u002Fcode-templates.md",[70,102,129,154,164,188],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":81,"publishedAt":28},"01M71KRBD0W01EAXJ8YM4M1SJ2","solana-dev","End-to-end Solana development playbook (Jan 2026). Prefer Solana Foundation framework-kit (@solana\u002Fclient + @solana\u002Freact-hooks) for React\u002FNext.js UI. Prefer @solana\u002Fkit for all new client\u002FRPC\u002Ftransaction code. When legacy dependencies require web3.js, isolate it behind @solana\u002Fweb3-compat (or @solana\u002Fweb3.js as a true legacy fallback). Covers wallet-standard-first connection (incl. ConnectorKit), Anchor\u002FPinocchio programs, Codama-based client generation, LiteSVM\u002FMollusk\u002FSurfpool testing, and security checklists.","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fsrc\u002Fskills\u002Fsolana-dev\u002FSKILL.md",[76],{"categoryNo":77,"categoryName":78,"taxonomyType":79,"taxonomyTypeDesc":80},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],"solana dev","dev","solana","Wallet","end","testing","hooks","kit","new","when","web3","code","react","next","2026","playbook","security","ui","fallback","framework",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":111,"publishedAt":28},"01M71KR8QPESSY61SVE8ZTFNVT","xurl","A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fxurl\u002FSKILL.md",[108],{"categoryNo":109,"categoryName":110,"taxonomyType":79,"taxonomyTypeDesc":80},"01JBSEEDCAT000000000000023","Skill与智能体开发",[104,112,113,114,115,116,117,91,118,119,120,121,122,123,124,125,19,126,127,128],"posts","Media","x api","search","send","tap","you","api","cli","read","install","cli tool","endpoint","brew","manage","tool","twitter",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":136,"publishedAt":28},"01M71KR6FSXV88YDKWP7NBY3SH","wurk-integration","WURK API integration for monetizing agents with x402 payments on Solana\u002FBase - create social jobs, custom challenges, and agent help tasks","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fwurk-integration\u002FSKILL.md",[135],{"categoryNo":109,"categoryName":110,"taxonomyType":79,"taxonomyTypeDesc":80},[137,138,139,140,141,21,142,143,119,144,145,146,147,148,149,150,19,151,152,153],"wurk","wurk integration","integration","x402","social","tasks","team","create","social-jobs","command","agent-help","custom-jobs","clawd","safe","api integration","custom","true",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":28},"01M71KR4HCX41BPAK9GP7RPRRP","workflows","Manage application workflows including configuration, restart, and removal.","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fworkflows\u002FSKILL.md",[],[156,126,161,162,163],"configuration","application","restart",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":28},"01M71KR1VM0F5GPEQDNG5J7A0H","web-search","Search the web, fetch content, extract branding profiles, and capture screenshots from URLs. Use for real-time information, API documentation, current events, design matching, and visual reference.","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fweb-search\u002FSKILL.md",[],[171,115,172,173,174,19,175,176,177,178,179,180,181,119,182,183,184,185,186,187],"web search","web","fetch","api documentation","real-time","time","profiles","design","use","information","visual","documentation","branding","matching","reference","capture","content",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":194,"publishedAt":28},"01M71KQZN5MR1JFQHG5GWXYAHS","weather","Get current weather and forecasts via wttr.in or Open-Meteo. Use when: user asks about weather, temperature, or forecasts for any location. NOT for: historical weather data, severe weather alerts, or detailed meteorological analysis. No API key needed.","https:\u002F\u002Fgithub.com\u002Fclawdsolana\u002FOpenClawd\u002Fblob\u002Fmain\u002Fskills\u002Fweather\u002FSKILL.md",[],[190,195,19,196,179,91,197,119,198,199,200,201,202,203,204,205,206,207],"get","open","analysis","alerts","temperature","curl","via","help","about","https","location","data","user"]