"""
Stripe — Create Payment Intent Demo
====================================
A minimal, ready-to-run example of creating a Stripe PaymentIntent.

Get an API key (free):
    1. Create an account at https://dashboard.stripe.com/register
    2. In the Dashboard, open Developers -> API keys.
    3. Copy the "Secret key" (use the sk_test_... key while testing).

Setup:
    pip install stripe
    export STRIPE_API_KEY="sk_test_..."

Run:
    python stripe_demo.py
"""

import os
import stripe

stripe.api_key = os.environ.get("STRIPE_API_KEY")


def create_payment(amount_cents: int, currency: str = "usd") -> str:
    """Create a PaymentIntent and return its client secret."""
    intent = stripe.PaymentIntent.create(
        amount=amount_cents,
        currency=currency,
        automatic_payment_methods={"enabled": True},
    )
    return intent.client_secret


if __name__ == "__main__":
    secret = create_payment(1999)  # $19.99
    print(f"PaymentIntent created. client_secret={secret}")
