Shell
Agent Kits Store: Stripe + GitHub Delivery
Summary
Set up Stripe payment flow for agent kits with GitHub-based delivery. Collect GitHub username at checkout, add buyer as collaborator to private repo on successful payment.
Architecture Overview
User clicks "Get Kit"
→ Checkout page (collects GitHub username + payment)
→ Stripe Checkout Session
→ Payment success → Webhook fires
→ Supabase purchase record updated
→ GitHub API adds collaborator
→ Email sent with setup instructions
→ User clones repo, runs kit
Decisions (Confirmed)
| Decision | Choice |
|---|---|
| GitHub username collection | During checkout (required field) |
| Repo strategy | Single private repo (id8labs/agent-kits) |
| Delivery method | GitHub collaborator invite |
| Updates | Users git pull for new versions |
Products to Add
| Kit | Price | Stripe Product ID |
|---|---|---|
| TMNT Elite | $79 | agent-kit-tmnt |
| LLC Ops | $49 | agent-kit-llc-ops |
| Pipeline | $49 | agent-kit-pipeline |
| Foundry | $49 | agent-kit-foundry |
| Factory | $39 | agent-kit-factory |
| Bundle | $199 | agent-kit-bundle |
Database Changes
New Column in purchases table
ALTER TABLE purchases ADD COLUMN github_username TEXT;
ALTER TABLE purchases ADD COLUMN github_invite_sent BOOLEAN DEFAULT FALSE;
ALTER TABLE purchases ADD COLUMN github_invite_sent_at TIMESTAMPTZ;
New Table: agent_kit_access
CREATE TABLE agent_kit_access (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES auth.users(id),
github_username TEXT NOT NULL,
kit_id TEXT NOT NULL,
purchase_id UUID REFERENCES purchases(id),
access_granted_at TIMESTAMPTZ DEFAULT NOW(),
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_agent_kit_access_user ON agent_kit_access(user_id);
CREATE INDEX idx_agent_kit_access_github ON agent_kit_access(github_username);
Files to Modify
1. /lib/products.ts
Add 6 new products (5 kits + bundle) with:
purchaseType: 'stripe'requiresGithub: true(new field)category: 'agent-kit'(new category)
2. /app/api/stripe/checkout/route.ts
- Accept
githubUsernamein request body - Validate GitHub username format
- Pass to Stripe metadata:
github_username - Store in purchases table
3. /app/api/stripe/webhook/route.ts
- On
checkout.session.completed:- Extract
github_usernamefrom metadata - Call GitHub API to add collaborator
- Update
github_invite_sentflag - Send confirmation email with setup instructions
- Extract
4. /app/products/ProductsContent.tsx
- Wire "Get Kit" buttons to open checkout modal
- Add checkout modal component with GitHub username field
New Files to Create
1. /lib/github.ts
GitHub API helper using Octokit:
export async function addRepoCollaborator(username: string): Promise<boolean>
export async function removeRepoCollaborator(username: string): Promise<boolean>
export async function checkCollaboratorStatus(username: string): Promise<boolean>
2. /app/api/github/invite/route.ts
Admin endpoint to manually trigger/retry GitHub invites
3. /components/checkout/AgentKitCheckout.tsx
Checkout modal component:
- GitHub username input (required, validated)
- Kit selection summary
- Stripe Elements or redirect to Stripe Checkout
- Loading/success/error states
4. /supabase/migrations/20260104_agent_kit_access.sql
Migration for new columns and table
5. /emails/agent-kit-welcome.tsx (React Email template)
Welcome email with:
- Purchase confirmation
- GitHub invite notification
- Setup instructions (clone, configure, run)
- Link to documentation
Environment Variables Needed
# GitHub (for collaborator API)
GITHUB_TOKEN=ghp_xxx # Personal access token with repo:invite scope
GITHUB_REPO_OWNER=id8labs # or eddiebe147
GITHUB_AGENT_KITS_REPO=agent-kits
# Existing (already configured)
STRIPE_SECRET_KEY=sk_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
RESEND_API_KEY=re_xxx
GitHub Setup Required (Manual)
- Create private repo:
id8labs/agent-kits - Structure:
agent-kits/ ├── README.md ├── tmnt-elite/ │ ├── README.md │ ├── agents/ │ └── setup.sh ├── llc-ops/ ├── pipeline/ ├── foundry/ └── factory/ - Create GitHub Personal Access Token with
reposcope - Add token to Vercel environment variables
Implementation Steps
- Database: Create migration for
github_usernamecolumn andagent_kit_accesstable - Products: Add 6 agent kit products to
/lib/products.ts - GitHub Helper: Create
/lib/github.tswith Octokit - Checkout API: Update to accept and store GitHub username
- Webhook: Add GitHub collaborator logic on payment success
- Email Template: Create welcome email with setup instructions
- UI: Create checkout modal and wire up buttons
- Test: End-to-end test with Stripe test mode
- Deploy: Push to production, verify webhook
Stripe Checkout Flow (Detail)
// Request to /api/stripe/checkout
{
productId: 'agent-kit-tmnt',
githubUsername: 'username123'
}
// Stripe Checkout Session metadata
{
user_id: 'uuid',
product_id: 'agent-kit-tmnt',
github_username: 'username123'
}
// On webhook success
1. Update purchases.status = 'completed'
2. Update purchases.github_username = metadata.github_username
3. Insert into agent_kit_access
4. Call GitHub API: PUT /repos/{owner}/{repo}/collaborators/{username}
5. Send welcome email via Resend
Error Handling
| Scenario | Handling |
|---|---|
| Invalid GitHub username format | Return 400 at checkout |
| GitHub user doesn't exist | Webhook logs error, email sent to retry |
| GitHub API rate limit | Queue for retry, admin notification |
| Duplicate purchase | Return existing access info |
| Refund | Remove collaborator access |
Bundle Logic
When product_id = 'agent-kit-bundle':
- Insert 5 rows into
agent_kit_access(one per kit) - Same GitHub invite (one collaborator = all folders accessible)
- Email lists all 5 kits included
Testing Checklist
- Stripe test mode checkout completes
- GitHub username stored in metadata
- Webhook receives event
- Collaborator added to repo
- Welcome email sent
- User can clone repo
- Bundle creates 5 access records
- Duplicate purchase handled gracefully