import stripe
from flask import Flask, request, jsonify, render_template

app = Flask(__name__)

# Use your test secret key
stripe.api_key = "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"

@app.route("/")
def donate_page():
    return render_template("donate.html")

@app.route("/create-payment-intent", methods=["POST"])
def create_payment():
    data = request.get_json()
    amount = int(float(data["amount"]) * 100)  # convert dollars/euros to cents

    intent = stripe.PaymentIntent.create(
        amount=amount,
        currency="usd",  # change to eur/gbp etc.
        payment_method_types=["card"]
    )

    return jsonify({"clientSecret": intent.client_secret})

if __name__ == "__main__":
    app.run(port=4242, debug=True)
