diff --git a/web/src/padelnomics/billing/routes.py b/web/src/padelnomics/billing/routes.py index c06708a..84feaba 100644 --- a/web/src/padelnomics/billing/routes.py +++ b/web/src/padelnomics/billing/routes.py @@ -175,6 +175,32 @@ async def checkout(plan: str): return jsonify(payload) +@bp.route("/checkout/item", methods=["POST"]) +@login_required +async def checkout_item(): + """Return checkout JSON for a single item (boost, credit pack, etc.). + + Used by dashboard boost/credit buttons that need a server round-trip + for Stripe (Checkout Session creation) and work with Paddle overlay too. + Expects JSON body: {price_key, custom_data, success_url?} + """ + body = await request.get_json(silent=True) or {} + price_key = body.get("price_key", "") + custom_data = body.get("custom_data", {}) + success_url = body.get("success_url", f"{config.BASE_URL}/suppliers/dashboard?tab=boosts") + + price_id = await get_price_id(price_key) + if not price_id: + return jsonify({"error": "Product not configured."}), 400 + + payload = _provider().build_checkout_payload( + price_id=price_id, + custom_data=custom_data, + success_url=success_url, + ) + return jsonify(payload) + + @bp.route("/manage", methods=["POST"]) @login_required async def manage(): diff --git a/web/src/padelnomics/planner/templates/export.html b/web/src/padelnomics/planner/templates/export.html index 70f99fa..f5c2327 100644 --- a/web/src/padelnomics/planner/templates/export.html +++ b/web/src/padelnomics/planner/templates/export.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% block title %}{{ t.export_title }} - {{ config.APP_NAME }}{% endblock %} -{% block paddle %}{% include "_paddle.html" %}{% endblock %} +{% block paddle %}{% include "_payment_js.html" %}{% endblock %} {% block head %}