Fix checkout return: resolve product URLs and read status after SumUp check
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 43s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 43s
Resolve page_slug and market_slug from the order's page_config so that product links on the checkout return page include the correct prefix. Also move the status read after check_sumup_status so the template reflects the actual payment result. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ from quart import Blueprint, g, request, render_template, redirect, url_for, mak
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
from models.order import Order
|
from models.order import Order
|
||||||
|
from blog.models.ghost_content import Post
|
||||||
|
from market.models.market_place import MarketPlace
|
||||||
from glue.services.order_lifecycle import get_entries_for_order
|
from glue.services.order_lifecycle import get_entries_for_order
|
||||||
from .services import (
|
from .services import (
|
||||||
current_cart_identity,
|
current_cart_identity,
|
||||||
@@ -178,13 +180,29 @@ def register(url_prefix: str) -> Blueprint:
|
|||||||
)
|
)
|
||||||
return await make_response(html)
|
return await make_response(html)
|
||||||
|
|
||||||
status = (order.status or "pending").lower()
|
# Resolve page/market slugs so product links render correctly
|
||||||
|
if order.page_config:
|
||||||
|
post = await g.s.get(Post, order.page_config.container_id)
|
||||||
|
if post:
|
||||||
|
g.page_slug = post.slug
|
||||||
|
result = await g.s.execute(
|
||||||
|
select(MarketPlace).where(
|
||||||
|
MarketPlace.container_type == "page",
|
||||||
|
MarketPlace.container_id == post.id,
|
||||||
|
MarketPlace.deleted_at.is_(None),
|
||||||
|
).limit(1)
|
||||||
|
)
|
||||||
|
mp = result.scalar_one_or_none()
|
||||||
|
if mp:
|
||||||
|
g.market_slug = mp.slug
|
||||||
|
|
||||||
if order.sumup_checkout_id:
|
if order.sumup_checkout_id:
|
||||||
try:
|
try:
|
||||||
await check_sumup_status(g.s, order)
|
await check_sumup_status(g.s, order)
|
||||||
except Exception:
|
except Exception:
|
||||||
status = status or "pending"
|
pass
|
||||||
|
|
||||||
|
status = (order.status or "pending").lower()
|
||||||
|
|
||||||
calendar_entries = await get_entries_for_order(g.s, order.id)
|
calendar_entries = await get_entries_for_order(g.s, order.id)
|
||||||
await g.s.flush()
|
await g.s.flush()
|
||||||
|
|||||||
2
shared
2
shared
Submodule shared updated: 3aa1aadd0b...d805af0764
Reference in New Issue
Block a user