From 298a453e192f03d90935a7733a57458bc91955b2 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 31 Jul 2024 21:35:04 +0200 Subject: [PATCH] Remove stripe session from success page (doesnt somehow work according to their docs hmm) --- src/accounting/views.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/accounting/views.py b/src/accounting/views.py index bf02c65..05b745f 100644 --- a/src/accounting/views.py +++ b/src/accounting/views.py @@ -71,8 +71,7 @@ def order_pay(request: HttpRequest, order_id: int) -> HttpResponse: checkout_session = stripe.checkout.Session.create( line_items=line_items, mode="payment", - success_url=base_domain - + reverse("order:success", kwargs={"order_id": order.id, "stripe_session_id": "{CHECKOUT_SESSION_ID}"}), + success_url=base_domain + reverse("order:success", kwargs={"order_id": order.id}), cancel_url=base_domain + "/cancel", ) except Exception as e: @@ -85,11 +84,11 @@ def order_pay(request: HttpRequest, order_id: int) -> HttpResponse: @transaction.atomic @order_view( - paths="/pay/success//", + paths="/pay/success/", name="success", login_required=True, ) -def success(request: HttpRequest, order_id: int, stripe_session_id: str) -> HttpResponse: +def success(request: HttpRequest, order_id: int) -> HttpResponse: """Create a Stripe session and redirects to Stripe Checkout. From Stripe docs: When you have a webhook endpoint set up to listen for checkout.session.completed events and @@ -100,8 +99,6 @@ def success(request: HttpRequest, order_id: int, stripe_session_id: str) -> Http user = request.user # People just need to login to pay something, not necessarily be a member order = models.Order.objects.get(pk=order_id, member=user) - bool(stripe_session_id) - context = { "order": order, }