DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

🚀 Launch Your AI‑Powered SaaS in Minutes: Stripe Checkout + Static Landing Page on a VPS

Turn a simple Python script into a live checkout experience for your AI, crypto, or data‑analysis product.


📚 What You’ll Build

  1. Python script (Stripe Python SDK) that creates a Checkout Session for two plans – PRO ($29) and ENTERPRISE ($99) – in test mode.
  2. Static HTML landing page (~2 KB) that displays the product titles, a few punchy benefits, and two “Buy Now” buttons that point to the Checkout Sessions you just created.
  3. One‑liner deployment on a cheap VPS (e.g., DigitalOcean, Linode, or Vultr) using Python’s built‑in HTTP server.
  4. Verification steps so you can be sure the page loads and the Stripe test checkout pages open without a hitch.
  5. Logging of the public URLs for future promotion or affiliate tracking.

All of this can be done in under an hour, even if you’re just getting started with payments. Let’s dive in!


1️⃣ Prerequisites

Requirement Why it matters How to get it
Stripe account (test mode) Needed for the Checkout Session API keys. Sign up at https://dashboard.stripe.com/register (use my affiliate link for a $10 credit: Stripe Affiliate).
Python 3.8+ The Stripe SDK runs on modern Python. Pre‑installed on most Linux VPS images.
Stripe Python SDK Communicates with Stripe’s API. pip install stripe
VPS with a public IP Hosts the static page. Get a $5/mo droplet from DigitalOcean (affiliate).
Domain (optional) Makes the URL friendly. Any registrar works; Cloudflare offers a free plan.

Tip: Keep the Stripe keys in environment variables (STRIPE_SECRET_KEY and STRIPE_PUBLISHABLE_KEY) – never hard‑code them.


2️⃣ Python Script: Create Checkout Sessions

# checkout_sessions.py
import os
import stripe

# -------------------------------------------------
# 1️⃣ Load your secret key from the environment.
# -------------------------------------------------
stripe.api_key = os.getenv("STRIPE_SECRET_KEY")
if not stripe.api_key:
    raise RuntimeError("Set STRIPE_SECRET_KEY env var first!")

# -------------------------------------------------
# 2️⃣ Define the two products you sell.
# -------------------------------------------------
PRODUCTS = {
    "PRO": {"price_id": "price_1PROxxxxxx", "amount": 2900},
    "ENTERPRISE": {"price_id": "price_1ENTxxxxxx", "amount": 9900},
}

def create_session(product_key: str) -> str:
    """Create a Stripe Checkout Session in test mode and return its URL."""
    if product_key not in PRODUCTS:
        raise ValueError(f"Unknown product {product_key}")

    session = stripe.checkout.Session.create(
        success_url="https://example.com/success?session_id={CHECKOUT_SESSION_ID}",
        cancel_url="https://example.com/cancel",
        payment_method_types=["card"],
        mode="payment",
        line_items=[
            {
                "price": PRODUCTS[product_key]["price_id"],
                "quantity": 1,
            }
        ],
        metadata={"product": product_key},
    )
    return session.url

if __name__ == "__main__":
    # -------------------------------------------------
    # 3️⃣ Generate URLs for each plan and print them.
    # -------------------------------------------------
    for key in PRODUCTS:
        url = create_session(key)
        print(f"{key} checkout URL → {url}")
Enter fullscreen mode Exit fullscreen mode

How it works

  • The script pulls your secret key from STRIPE_SECRET_KEY.
  • It references pre‑created Price IDs (price_…) that you set up in the Stripe Dashboard (one for PRO, one for ENTERPRISE).
  • stripe.checkout.Session.create builds a one‑time payment session.
  • The function returns the session URL – a link you can embed directly in a button.

Important: Run the script once in test mode (your account defaults to test when you use test keys). Save the printed URLs; they’ll be the targets for the landing‑page buttons.


3️⃣ Static Landing Page (≈2 KB)

<!-- index.html – ~1.9 KB -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>AI‑Analytics Pro – Plans</title>
  <style>
    body{font-family:Arial,sans-serif;background:#fafafa;margin:0;padding:2rem;}
    .card{background:#fff;padding:1.5rem;margin:1rem auto;max-width:400px;border-radius:8px;box-shadow:0 2px 6px rgba(0,0,0,.1);}
    h1{text-align:center;color:#2c3e50;}
    button{width:100%;padding:.8rem;margin-top:.5rem;border:none;border-radius:4px;font-size:1rem;cursor:pointer;}
    .pro{background:#3498db;color:#fff;}
    .ent{background:#e67e22;color:#fff;}
  </style>
</head>
<body>
  <h1>AI‑Analytics Pro</h1>

  <div class="card">
    <h2>PRO – $29 / month</h2>
    <ul>
      <li>🔎 10 k data points per month</li>
      <li>🚀 Real‑time predictions</li>
      <li>📊 Export to CSV/JSON</li>
    </ul>
    <button class="pro" onclick="location.href='{{PRO_URL}}'">Buy PRO</button>
  </div>

  <div class="card">
    <h2>ENTERPRISE – $99 / month</h2>
    <ul>
      <li>💎 Unlimited data & premium models</li>
      <li>🛡️ Dedicated support</li>
      <li>🔐 SOC 2 compliance</li>
    </ul>
    <button class="ent" onclick="location.href='{{ENT_URL}}'">Buy ENTERPRISE</button>
  </div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Steps to finalize

  1. Run the Python script from step 2.
  2. Copy the two URLs it printed.
  3. Replace {{PRO_URL}} and {{ENT_URL}} in the HTML with those URLs.
  4. Save the file as index.html on your VPS.

The page is intentionally tiny (≈1.9 KB) so it loads instantly even on a modest VPS.


4️⃣ Deploy on VPS1 with a One‑Liner

# 1️⃣ SSH into your VPS
ssh root@YOUR_VPS_IP

# 2️⃣ Install Python if it isn’t already
apt update && apt install -y python3 python3-pip

# 3️⃣ (Optional) Create a virtualenv for isolation
python3 -m venv venv && source venv/bin/activate

# 4️⃣ Install Stripe SDK for future tweaks
pip install stripe

# 5️⃣ Upload the files (scp or git)
# Example using scp from your local machine:
scp checkout_sessions.py index.html root@YOUR_VPS_IP:/root/

# 6️⃣ Run the script once to get the URLs (or do it locally)
python3 checkout_sessions.py   # copy the printed URLs into index.html

# 7️⃣ Serve the static page on port 8080
nohup python3 -m http.server 8080 --bind 0.0.0.0 > server.log 2>&1 &
Enter fullscreen mode Exit fullscreen mode

Your site is now reachable at:

http://YOUR_VPS_IP:8080/
Enter fullscreen mode Exit fullscreen mode

If you own a domain, point a DNS A record to YOUR_VPS_IP and optionally use a reverse proxy (nginx) to expose port 80/443.


5️⃣ Verify Everything Works

Check How to Test
**

Top comments (0)