Changes to payment models #32

Merged
valberg merged 35 commits from benjaoming/membersystem:payment-updates into main 2024-08-03 17:55:33 +00:00
Showing only changes of commit 298a453e19 - Show all commits

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,
}