Systems Library / Platform Integrations / How to Create Automated Stripe Revenue Reports
Platform Integrations ecommerce

How to Create Automated Stripe Revenue Reports

Generate automated revenue and subscription reports from Stripe data.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

I build automate stripe revenue reporting dashboard systems that give store owners automated MRR, churn, and revenue trend reports. This automation runs in the background so you can focus on growth instead of operational tasks.

What You Need

Step 1: Connect to the Stripe API

import requests
import os
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("STRIPE_API_KEY")
API_URL = os.getenv('STRIPE_API_URL')

headers = {
    'Authorization': f'Bearer {API_KEY}',
    "Content-Type": "application/json"
}

def fetch_data(endpoint, params=None):
    url = f'{API_URL}/{endpoint}'
    response = requests.get(url, headers=headers, params=params or {})
    return response.json()

Step 2: Build the Processing Logic

from datetime import datetime
import json

def process_items(items):
    results = []
    for item in items:
        processed = {
            "id": item.get("id"),
            "name": item.get("name", item.get("title", "")),
            "status": item.get("status", ""),
            "amount": item.get("total_price", item.get("amount", 0)),
            "processed_at": datetime.now().isoformat()
        }
        results.append(processed)
    return results

Step 3: Set Up Notifications

def send_notification(message):
    slack_token = os.getenv("SLACK_BOT_TOKEN")
    channel = os.getenv("ECOM_CHANNEL")

    requests.post("https://slack.com/api/chat.postMessage",
        headers={"Authorization": f"Bearer {slack_token}"},
        json={"channel": channel, "text": message})

def notify_batch(processed_items):
    for item in processed_items:
        msg = f"*{item['name']}* | Status: {item['status']} | ${item['amount']}"
        send_notification(msg)
    print(f"Sent {len(processed_items)} notifications")

Step 4: Add Webhook Handler

from flask import Flask, request

app = Flask(__name__)

@app.route("/webhook/stripe", methods=["POST"])
def handle_webhook():
    data = request.json
    processed = process_items([data])
    notify_batch(processed)
    return "OK", 200

Step 5: Run on Schedule

import sqlite3

def log_run(action, count):
    conn = sqlite3.connect("ecom_automation.db")
    conn.execute("""CREATE TABLE IF NOT EXISTS runs (
        action TEXT, count INTEGER, ran_at TEXT
    )""")
    conn.execute("INSERT INTO runs VALUES (?, ?, ?)",
        (action, count, datetime.now().isoformat()))
    conn.commit()

def main():
    data = fetch_data("orders", {"status": "any", "limit": 50})
    items = data.get("orders", data.get("data", []))
    processed = process_items(items)
    notify_batch(processed)
    log_run("Stripe revenue reporting", len(processed))

main()

What to Build Next

Add a dashboard in Google Sheets that shows Stripe revenue reporting trends over time. Connect it to the webhook handler so data flows in real time, not just on schedule.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems