DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

🚀 Build a One‑Click AI‑Powered Landing Page with Stripe Checkout, Webhooks, and Auto‑Delivery (All on a Tiny VPS)

If you’re a solo founder or a hobbyist who wants to sell AI‑tools, crypto utilities, or data‑analysis scripts without spending a fortune on infrastructure, this guide is for you.

In this tutorial you’ll learn how to:

  1. Generate a static HTML landing page with clear value propositions and Stripe checkout buttons using a tiny Python module.
  2. Serve the page on a cheap VPS (port 80) with a lightweight web server (Python http.server or Caddy).
  3. Listen to Stripe payment events on the same VPS and automatically email the buyer the deliverables (API key, download link, etc.).
  4. Log every checkout URL in a JSON file for future analytics.
  5. Bulk‑update the description of existing YouTube videos and Dev.to posts to include the new landing‑page URL and a short CTA.

All the code is open‑source, easy to copy‑paste, and runs on a $5‑$10/month VPS. No Docker, no Kubernetes, no hidden fees.


📚 Table of Contents

  1. Prerequisites
  2. Step 1 – Create the Landing‑Page Generator
  3. Step 2 – Deploy a Tiny Web Server on VPS1
  4. Step 3 – Stripe Webhook Listener & Automated Email
  5. Step 4 – Checkout‑URL Logging
  6. Step 5 – Bulk‑Update YouTube & Dev.to Descriptions
  7. Putting It All Together (Folder Layout)
  8. Bonus: Deploy with Caddy (HTTPS for free)
  9. Wrap‑Up & Next Steps

🔧 Prerequisites

Item Why you need it How to get it
VPS1 (any Linux server, 512 MB RAM is enough) Host the static page, webhook, and JSON logger DigitalOcean, Linode, Hetzner, or a cheap cloud‑provider
Domain name (optional but recommended) Friendly URL and SSL via Let’s Encrypt Namecheap, Cloudflare, etc.
Stripe account (with Checkout enabled) Payment processing https://dashboard.stripe.com/register
SMTP credentials (Gmail App Password or SendGrid API key) Send the delivery email Gmail → “App passwords”, SendGrid → API key
Python 3.9+ Run the scripts Pre‑installed on most VPS images
YouTube Data API v3 key Update video descriptions https://console.developers.google.com/apis/library/youtube.googleapis.com
Dev.to API token Update Dev.to article descriptions https://dev.to/settings/extensions → “API Keys”

Tip: Keep all secrets (Stripe secret key, webhook secret, SMTP password, API keys) in a .env file and load them with python‑dotenv. Never commit them to Git.


1️⃣ Step 1 – Generate a Static Landing Page

Create a Python module called landing_page.py. It reads a tiny Jinja‑like template, injects product data, and writes index.html.


python
# landing_page.py
import os
from pathlib import Path
import json
from urllib.parse import quote_plus

# -------------------------------------------------
# 1️⃣ PRODUCT DEFINITIONS – edit to suit your offers
# -------------------------------------------------
PRODUCTS = [
    {
        "id": "ai‑assistant‑v1",
        "name": "AI Assistant API",
        "price_cents": 1999,
        "description": "Fast, low‑latency LLM endpoint with 10 k‑token limit.",
        "deliverable": {
            "type": "api_key",
            "template": "YOUR-API-KEY-{uid}"
        },
    },
    {
        "id": "crypto‑signal‑pack‑v2",
        "name": "Crypto Signal Pack",
        "price_cents": 4999,
        "description": "Real‑time trading signals + back‑tested CSV.",
        "deliverable": {
            "type": "download",
            "url": "https://example.com/downloads/crypto‑signals-v2.zip"
        },
    },
]

# -------------------------------------------------
# 2️⃣ HTML TEMPLATE (keep it simple – inline CSS)
# -------------------------------------------------
HTML_TEMPLATE = """<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>🚀 {title}</title>
  <style>
    body {{font-family:Arial,Helvetica,sans-serif;background:#f7f9fc;color:#333;max-width:800px;margin:auto;padding:2rem;}}
    .product {{border:1px solid #ddd;border-radius:8px;padding:1.5rem;margin:1rem 0;background:#fff;}}
    .cta {{background:#0066ff;color:#fff;padding:.75rem 1.5rem;border:none;border-radius:4px;cursor:pointer;}}
    .cta:hover {{background:#0055dd;}}
  </style>
</head>
<body>
  <h1>{title}</h1>
  <p>{subtitle}</p>

  {products_html}

</body>
</html>
"""

PRODUCT_BLOCK = """
<div class="product">
  <h2>{name}</h2>
  <p>{description}</p>
  <form action="{checkout_url}" method="POST">
    <button class="cta">Buy for ${price}</button>
  </form>
</div>
"""

# -------------------------------------------------
# 3️⃣ Helper: create Stripe Checkout URL (client‑only)
# -------------------------------------------------
def stripe_checkout_url(product_id: str, price_cents: int) -> str:
    """
    Returns a pre‑built Stripe Checkout URL.
    You must have a Stripe Checkout Session template set up in your dashboard.
    """
    # This example uses Stripe’s “price ID” approach.
    # Create a price in Stripe Dashboard and replace `price_XXXX` below.
    # For dynamic sessions you would call Stripe API from a backend,
    # but for a static page we can embed a pre‑configured session link.
    # See https://stripe.com/docs/payments/checkout/custom-domains
    price_id = os.getenv("STRIPE_PRICE_ID_" + product_id.upper(), "")
    if not price_id:
        raise ValueError(f"Missing price ID for {product_id}")
    # Encode the price ID for a client‑only Session URL
    return f"https://checkout.stripe.com/pay/{quote_plus(price_id)}"

# -------------------------------------------------
# 4️⃣ Main: build the page
# -------------------------------------------------
def build_page(output_path: Path = Path("public")):
    output_path.mkdir(parents=True, exist_ok=True)

    product_html_parts = []
    for p in PRODUCTS:
        checkout = stripe_checkout_url(p["id"], p["price_cents"])
        product_html_parts.append(
            PRODUCT_BLOCK.format(
                name=p["name"],
                description=p["description"],
                checkout_url=checkout,
                price=f"{p['price_cents'] / 100:.2f}"
            )
        )
    page_html = HTML_TEMPLATE.format(
        title="🛒 AI & Crypto Marketplace",
        subtitle="Pick a product, pay
Enter fullscreen mode Exit fullscreen mode

Top comments (0)