Remove stripe session from success page (doesnt somehow work according to their docs hmm)

This commit is contained in:
Benjamin Bach 2024-07-31 21:35:04 +02:00
parent 9a61c237c7
commit 298a453e19
No known key found for this signature in database
GPG key ID: 486F0D69C845416E

View file

@ -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="<int:order_id>/pay/success/<str:stripe_session_id>/",
paths="<int:order_id>/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,
}