Build Stripe-Salesforce automations faster with AI coding tools. AI-native context files that reduce the hallucinations
Build Stripe-Salesforce automations faster with AI coding tools. AI-native context files that reduce the hallucinations.
You ask Claude Code, Cursor, or Copilot to “generate a Salesforce Flow that creates a Stripe Customer using the Stripe App.”
What happens:
The cost: Minutes of waiting, wasted tokens, and code that doesn’t work with the Stripe App for Salesforce.
This repo provides AI-native context files that teach AI tools the Stripe App for Salesforce surface—the package structure, invocable actions (v02_*), custom objects (stripeGC__*), and deployment constraints. These files are structured specifically for AI consumption, not just human documentation.
With these context files:
stripeGC__v02_CreateCustomers)AsyncAfterCommit for record-triggered callout flowsResult: Generate working Flows, LWC components, and Apex in one or two iterations instead of five.
Open your AI coding tool in this repo’s directory and prompt:
Read
context/LOAD_ALL.mdand load the core context files it lists. When ready, tell me what you loaded.
This works with any AI coding tool — Claude Code, Cursor, Codex, Copilot, Aider, Cody. No tool-specific syntax needed.
The AI will read the core context files (~35K tokens) and confirm what it loaded. It can pull in the larger reference files on demand when needed. Then prompt with your task:
Good — gets you a starting point:
Better — specific requirements mean fewer iterations:
The more specific you are about trigger conditions, field mappings, and expected behavior, the fewer iterations you’ll need.
The context files total ~230K tokens. You don’t need to load everything at once.
| What to Load | Tokens | When to Use |
|---|---|---|
| Core context only (architecture, rules, billing flows) | ~35K | Most tasks — Flows, LWC, Apex generation |
| Core + reference files (invocable actions + models) | ~230K | When you need specific v02_* action names, parameters, or model field structures |
Practical tip: Start with the core files. Your AI tool can read invocable-actions-reference.md or models-reference.md on demand when it needs to look up a specific action or model — you don’t need them in context for every task.
With AI tools + these context files, you can generate:
| Use Case | What It Does | Context Files |
|---|---|---|
| Stripe Customer Creation Flow | Auto-create Stripe Customer when Opportunity closes | flow-builder.mdc |
| Checkout Session Flow | Generate Stripe Checkout Session link from Opportunity | flow-builder.mdc |
| Subscription Flow | Create Stripe Subscription from Contract | flow-builder.mdc |
| Payment Element LWC | Embed Stripe Payment Element on record pages | lwc-stripe-payment.mdc |
| Payment Link Generator LWC | One-click payment link sharing | lwc-stripe-payment.mdc |
| Custom API Invocables | Wrap Stripe API calls for Flow use | Stripe-Salesforce-Platform-Architecture.md |
Required:
sf command)See full installation guide below for step-by-step instructions.
Need a scratch org? If you don’t have a Salesforce org yet, follow the Scratch Org Quickstart to create a disposable dev environment in minutes. You’ll need a parent org (free Developer Edition, Production, or Partner Business Org) with Dev Hub enabled.
# Copy to your Salesforce project root
cp -r context /path/to/your/salesforce-project/
Alternatively, keep context files in this repo and open your AI tool from this directory.
Open your AI tool in the project directory and prompt:
Using the flow-builder.mdc rules, generate a Salesforce Flow that:
- Triggers when Opportunity.StageName = "Closed Won"
- Creates a Stripe Customer from the Account
- Logs errors to Sync_Log__c
The AI will generate working Flow XML. Review it, deploy to a sandbox, and test.
stripe-salesforce-ai-context/
├── README.md
├── LICENSE
│
├── context/ # AI-native context files
│ ├── LOAD_ALL.md # Context index
│ ├── Stripe-Salesforce-Platform-Architecture.md # Universal Connector architecture
│ ├── API-Extension.md # AutoGen invocables & models
│ ├── Stripe-Billing-Flows.md # Subscription schedule automation
│ ├── Stripe-Payments-Salesforce-Billing.md # Legacy SF Billing (optional)
│ ├── invocable-actions-reference.md # 244 v02_* actions catalog
│ ├── models-reference.md # 2,175 request/response models
│ └── rules/
│ ├── flow-builder.mdc # Flow XML generation rules
│ └── lwc-stripe-payment.mdc # LWC + Payment Element patterns
│
├── setup/ # Environment setup
│ ├── project-scratch-def.json # Scratch org definition (ready to use)
│ └── scratch-org-quickstart.md # Scratch org creation runbook
│
├── prompts/ # Copy-paste prompts
│ └── load-stripe-context.txt # For tools without file access
│
└── examples/ # Working reference code
├── sfdx-project.json # Package dependencies
└── force-app/main/default/
├── flows/ # 3 validated Flow examples
├── classes/ # 3 Apex classes
└── lwc/stripePayment/ # Payment Element LWC
rules/flow-builder.mdc)The AI learns:
AsyncAfterCommit scheduled path for record-triggered FlowsSync_Log__cExample rule snippet:
## Required Preamble: Stripe Account Lookup
Every flow must resolve the Stripe Account record first:
1. recordLookups element to query Stripe_Account__c by Name
2. decisions element to null-check the result
3. Pass Get_Stripe_Account.Id as accountRecordId to all API calls
rules/lwc-stripe-payment.mdc)The AI learns:
frame-src critical for Payment Element)data-* attributes, not IDsloadScript()renderedCallback() with guard flagredirect: 'if_required' for 3DSExample rule snippet:
## Shadow DOM — Data Attributes, Not IDs
LWC Shadow DOM scopes element IDs. Always use data attributes:
<!-- ✅ Correct -->
<div data-stripe-element="payment"></div>
<!-- ❌ Wrong — Stripe.js can't find scoped ID -->
<div id="payment-element"></div>
Stripe-Salesforce-Platform-Architecture.md, API-Extension.md)The AI learns:
stripeGCCustomer__c, Invoice__c, etc.)v02_CreateCustomers, v02_CreatePaymentIntents)Using the flow-builder.mdc rules, generate a Salesforce Flow that:
- Triggers when Contract is activated
- Creates a Stripe Subscription with items from Contract Line Items
- Maps Contract.stripeGC__Customer__c to the Stripe Customer
- Handles errors by creating a Sync_Log__c record
Using the lwc-stripe-payment.mdc rules, generate a Lightning Web Component that:
- Displays on the Order record page
- Shows "Pay Now" button only if Order.Payment_Captured__c = false
- Creates a PaymentIntent for Order.TotalAmount
- Mounts Stripe Payment Element for card collection
- After payment confirmation, updates Order.Payment_Captured__c = true
- Includes Apex controller with createPaymentIntent and recordPaymentSuccess methods
Using the API-Extension.md context, create an Apex invocable action that:
- Accepts customerId (String), priceId (String), quantity (Integer)
- Creates a Stripe Subscription with a single item
- Returns the Subscription ID for use in Flow
- Includes proper error handling and user-mode security
📚 Foundation First:
While AI tools accelerate development, foundational knowledge of Stripe API and Salesforce administration is highly recommended. These context files enhance AI accuracy—they don’t replace understanding the platforms you’re integrating.
with sharing, WITH USER_MODE, field-level securityFlow deployment fails: “One or more elements without an incoming connection”
<connector> or <faultConnector> pointing to itPayment Element renders as empty div
frame-src directive not configured for js.stripe.com“Callout from triggers not supported” error
<scheduledPaths> with <pathType>AsyncAfterCommit</pathType>Charge__c lookup returns empty after confirmPayment
charge.succeeded event hasn’t been processed yetAI generates hallucinated invocable action names
Minimum Salesforce Edition:
Required Salesforce Permissions:
Recommended Salesforce API Version: 64.0 or higher
Via AppExchange (Recommended):
Current Version: 2.7.0 (as of March 2026)
What it includes:
Stripe_Account__c, Customer__c, Invoice__c, Subscription__c, etc.stripeGCDuring the Stripe App setup in Salesforce, you’ll be prompted to install extensions:
Required Extension:
v02_CreateCustomers, v02_CreatePaymentIntents, etc.) and API model classesOptional Extensions:
All extensions share the stripeGC namespace and are installed through the app setup wizard.
Learn more: Stripe App for Salesforce Documentation
⚠️ MUST be done via Setup UI—metadata deployment doesn’t work correctly.
Steps:
Stripe JShttps://js.stripe.comhttps://api.stripe.com with all boxes checkedWhy this matters: Without frame-src, Payment Element renders as an empty div with no visible error.
Option A: Claude Code CLI (Recommended)
npm install -g @anthropic-ai/claude-code
# Or download from https://claude.com/code
Option B: Cursor IDE
Download from cursor.sh
Option C: GitHub Copilot
Install from github.com/features/copilot
Note: Copilot requires more explicit prompting and doesn’t natively read .mdc files.
# Install sf CLI
brew install salesforce-cli # macOS
# OR
npm install -g @salesforce/cli # Windows/Linux
# Authorize your org
sf org login web -a mydev -r https://test.salesforce.com # Sandbox
# OR
sf org login web -a myprod -r https://login.salesforce.com # Production
# Set default org
sf config set target-org mydev
# Check Universal Connector
sf data query \
--query "SELECT Id, Name FROM stripeGC__Stripe_Account__c LIMIT 1" \
--use-tooling-api \
-o mydev
# Check AutoGen Classes
sf data query \
--query "SELECT Id, Name FROM ApexClass WHERE Name LIKE 'v02_CreateCustomers' LIMIT 1" \
--use-tooling-api \
-o mydev
Expected: Both queries return results.
We welcome contributions! If you’ve:
Please open a pull request.
.mdc rules more accuratewith sharing, FLS checksSalesforce Flows:
faultConnector on all API callsSync_Log__cAsyncAfterCommit for record-triggered flows with calloutsDraft (users activate after testing)Lightning Web Components:
data-* attributes for Stripe element containers (not IDs)loadScript()renderedCallback() with guard flagWITH USER_MODE in Apex queriesApex Classes:
with sharing unless there’s a documented reason not toWITH USER_MODE in SOQL queries@AuraEnabled(cacheable=false) for write operationstry/catch)High Priority:
Medium Priority:
This repo tracks versions of the Stripe App for Salesforce packages:
| Context Files Version | Stripe Universal Connector | AutoGen API Version | Notes |
|---|---|---|---|
| v1.0 | 2.7.0 | 2025-04-30 (v1.1) | Initial release |
| v0.9 (beta) | 2.0.0 | 2022-11-15 (v1.0) | Legacy support |
Always use context files that match your installed package versions.
What this doesn’t replace:
AI agents can still:
Always human-review generated code before deploying to production.
MIT License. See LICENSE for details.
These are reference implementations, not production-ready code. You are responsible for:
This project is not affiliated with or endorsed by Stripe, Inc. or Salesforce, Inc.
This repo provides AI-native context (what to generate). Pair it with MCP servers to let your AI tool interact with both Stripe and Salesforce directly.
The Salesforce DX MCP Server (@salesforce/mcp) lets AI tools interact with your Salesforce org:
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": ["-y", "@salesforce/mcp"],
"env": { "SF_ORG": "your-org-alias" }
}
}
}
The Stripe MCP Server (@stripe/mcp) lets AI tools interact with Stripe APIs:
{
"mcpServers": {
"stripe": {
"command": "npx",
"args": ["-y", "@stripe/mcp", "--api-key=YOUR_STRIPE_RESTRICTED_KEY"]
}
}
}
Use a Restricted API Key with only the permissions your workflow needs. Stripe also hosts a remote MCP server at https://mcp.stripe.com with OAuth-based access.
With both MCP servers + this repo’s context files, your AI tool can:
See Salesforce MCP docs and Stripe MCP docs for full setup.
Tip for AI agents: Append
.mdto anydocs.stripe.comURL (e.g.,https://docs.stripe.com/api/customers/create.md) to get clean, agent-readable markdown — no HTML, no JS rendering. Use this with WebFetch when you need to verify API parameters or behavior before generating code.
llm-context command.Built for Salesforce admins, developers, and Stripe implementation partners who want to leverage AI coding tools effectively.