04 - Payment-Processing
Relevant source files
Purpose & ScopeLink copied!
This document covers the payment processing system in godeep.wiki, which handles the $10 payment from customers through Stripe integration. The payment system consists of three key components: checkout session creation, webhook event handling, and correlation with GitHub installations. This page provides an overview of the payment architecture and data flow.
For detailed information about specific subsystems, see:
For GitHub OAuth flow that follows payment, see 3. For the automation system triggered by payment, see 5.
Payment Architecture OverviewLink copied!
The payment system uses Stripe Checkout Sessions for payment processing, with webhook-based event handling to track successful payments. The architecture is designed to be stateless, relying on the session_id as the correlation key that links payment to subsequent GitHub repository access.
Payment Flow DiagramLink copied!
Sources: app/actions.ts L1-L34
app/api/webhooks/stripe/route.ts L1-L93
Key ComponentsLink copied!
| Component | File Path | Purpose |
|---|---|---|
| Checkout Session Creator | app/actions.ts | Server action that initializes Stripe checkout with $10 product |
| Webhook Handler | app/api/webhooks/stripe/route.ts | Receives and processes Stripe webhook events |
| Stripe Client | lib/stripe.ts | Initialized Stripe SDK instance |
| Success Page | app/success/page.tsx | Receives session_id from redirect |
Sources: app/actions.ts L1-L34
app/api/webhooks/stripe/route.ts L1-L93
Payment Product ConfigurationLink copied!
The system sells a single fixed-price product with the following specifications:
| Property | Value | Location |
|---|---|---|
| Product Name | "DeepWiki Analysis" | app/actions.ts L17 |
| Description | "Full architectural documentation for your GitHub repository." | app/actions.ts L18 |
| Price | $10.00 USD | app/actions.ts L20 |
| Currency | USD | app/actions.ts L15 |
| Payment Mode | One-time payment | app/actions.ts L25 |
The price is hardcoded as unit_amount: 1000 (1000 cents = $10.00) in the checkout session creation.
Sources: app/actions.ts L11-L28
Session ID as Correlation KeyLink copied!
The session_id generated by Stripe serves as the primary correlation key throughout the system. This identifier links multiple system events:
The session_id enables manual correlation between:
- Payment records in Stripe Dashboard
- GitHub installation events in Vercel logs
- Webhook notifications in ntfy.sh
- OAuth callback logs linking payment to
installation_id
Sources: CLAUDE.md L44-L50
app/api/webhooks/stripe/route.ts L54-L68
Webhook Event ProcessingLink copied!
The webhook handler processes Stripe events asynchronously from the payment flow. This provides reliable notification even if the user closes their browser after payment.
Webhook Event Types HandledLink copied!
| Event Type | Action | Output |
|---|---|---|
checkout.session.completed | Log payment details, send ntfy notification | Console logs + ntfy message |
The handler only processes the checkout.session.completed event, which fires when a checkout session successfully completes payment.
Webhook Security FlowLink copied!
Sources: app/api/webhooks/stripe/route.ts L22-L44
Notification DispatchLink copied!
When a payment completes, the webhook handler sends a notification to ntfy.sh containing:
| Field | Example | Purpose |
|---|---|---|
| Amount | "$10.00" | Payment amount |
| Customer Email | "user@example.com" | From session.customer_email or customer_details.email |
| Match ID | Last 12 chars of session_id | For correlation with GitHub installation |
| Timestamp | America/New_York timezone | When payment received |
| Message | "Waiting for customer to connect GitHub..." | Status indicator |
The notification is sent to topic NTFY_TOPIC (default: godeep-wiki-payments) with priority "high" and tags "moneybag,tada".
Sources: app/api/webhooks/stripe/route.ts L61-L79
Notification Message FormatLink copied!
New GoDeep.wiki Sale!
š° Amount: $10.00
š§ Customer: user@example.com
š Match ID: abc123def456
ā° Time: 12/25/2024, 3:45:00 PM
ā ļø Waiting for customer to connect GitHub...
Match this ID with Step 2 notification.
The "Match ID" is the last 12 characters of the session_id, extracted using session.id.slice(-12). This shortened identifier helps the owner manually correlate payment with GitHub installation when checking logs.
Sources: app/api/webhooks/stripe/route.ts L66-L68
Success and Cancel URL ConfigurationLink copied!
The checkout session configures two redirect URLs:
The success_url includes a placeholder {CHECKOUT_SESSION_ID} which Stripe automatically replaces with the actual session ID before redirecting. This ensures the success page receives the correlation key.
The cancel_url redirects back to the landing page with a query parameter indicating cancellation, allowing the UI to display appropriate messaging.
Sources: app/actions.ts L26-L27
Environment Variables RequiredLink copied!
| Variable | Purpose | Used By |
|---|---|---|
STRIPE_SECRET_KEY | Stripe API authentication | app/actions.ts L4 lib/stripe.ts |
STRIPE_PUBLISHABLE_KEY | Public key for Stripe.js (not used in server actions) | Client-side only |
STRIPE_WEBHOOK_SECRET | Webhook signature verification | app/api/webhooks/stripe/route.ts L30 |
NTFY_TOPIC | ntfy.sh topic for notifications | app/api/webhooks/stripe/route.ts L62 |
The STRIPE_WEBHOOK_SECRET must match the webhook secret configured in the Stripe Dashboard for the webhook endpoint URL.
Sources: CLAUDE.md L88-L109
app/api/webhooks/stripe/route.ts L30-L35
Error HandlingLink copied!
The system implements multiple layers of error handling:
Webhook Handler Error CasesLink copied!
| Error Condition | HTTP Status | Response |
|---|---|---|
Missing stripe-signature header | 400 | "Missing stripe-signature header" |
STRIPE_WEBHOOK_SECRET not configured | 500 | "Webhook secret not configured" |
| Signature verification fails | 400 | "Webhook Error: [message]" |
| Event processing exception | 500 | "Error processing webhook" |
All errors are logged to console with descriptive messages before returning HTTP error responses.
Sources: app/api/webhooks/stripe/route.ts L26-L44
app/api/webhooks/stripe/route.ts L88-L91
CORS and HTTP MethodsLink copied!
The webhook endpoint supports multiple HTTP methods:
| Method | Purpose | Response |
|---|---|---|
POST | Process webhook events | JSON { received: true } |
GET | Health check / verification | "Stripe webhook endpoint is active" |
OPTIONS | CORS preflight | 200 with CORS headers |
The OPTIONS handler enables CORS preflight requests with the following headers:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: POST, OPTIONSAccess-Control-Allow-Headers: Content-Type, stripe-signature
Sources: app/api/webhooks/stripe/route.ts L5-L20
Payment Data LoggedLink copied!
The webhook handler logs comprehensive payment information to Vercel logs (stdout):
================================================================================
š° NEW PAYMENT RECEIVED
================================================================================
Session ID: cs_test_xxx...
Amount: $10
Customer Email: user@example.com
Payment Status: paid
Timestamp: 2024-12-25T15:45:00.000Z
================================================================================
This logging provides an audit trail for payment tracking and debugging. The session_id logged here can be manually correlated with installation_id logged by the OAuth callback handler (see 3.3).
Sources: app/api/webhooks/stripe/route.ts L51-L59
Integration with Automation SystemLink copied!
The payment notification sent to ntfy.sh triggers the automation pipeline (see 5). The automation scripts subscribe to the ntfy topic and receive notifications, but they cannot act until the customer also completes GitHub installation, which generates a second notification containing the installation_id.
The two-step notification system (payment + GitHub connection) ensures the owner has both:
- Confirmation of payment (from webhook)
- Repository access credentials (from OAuth callback)
Only when both notifications are received and manually correlated can the owner proceed with repository cloning and documentation generation.
Sources: app/api/webhooks/stripe/route.ts L61-L81
Refresh this wiki
Last indexed: 23 November 2025 (922b35)
On this page
- Payment Processing
- Purpose & Scope
- Payment Architecture Overview
- Payment Flow Diagram
- Key Components
- Payment Product Configuration
- Session ID as Correlation Key
- Webhook Event Processing
- Webhook Event Types Handled
- Webhook Security Flow
- Notification Dispatch
- Notification Message Format
- Success and Cancel URL Configuration
- Environment Variables Required
- Error Handling
- Webhook Handler Error Cases
- CORS and HTTP Methods
- Payment Data Logged
- Integration with Automation System
Ask Devin about godeep.wiki-jb