Split cart into 4 microservices: relations, likes, orders, page-config→blog
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Phase 1 - Relations service (internal): owns ContainerRelation, exposes get-children data + attach/detach-child actions. Retargeted events, blog, market callers from cart to relations. Phase 2 - Likes service (internal): unified Like model replaces ProductLike and PostLike with generic target_type/target_slug/target_id. Exposes is-liked, liked-slugs, liked-ids data + toggle action. Phase 3 - PageConfig → blog: moved ownership to blog with direct DB queries, removed proxy endpoints from cart. Phase 4 - Orders service (public): owns Order/OrderItem + SumUp checkout flow. Cart checkout now delegates to orders via create-order action. Webhook/return routes and reconciliation moved to orders. Phase 5 - Infrastructure: docker-compose, deploy.sh, Dockerfiles updated for all 3 new services. Added orders_url helper and factory model imports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
63
orders/services/check_sumup_status.py
Normal file
63
orders/services/check_sumup_status.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""Check SumUp checkout status and update order accordingly.
|
||||
|
||||
Moved from cart/bp/cart/services/check_sumup_status.py.
|
||||
"""
|
||||
from types import SimpleNamespace
|
||||
|
||||
from shared.browser.app.payments.sumup import get_checkout as sumup_get_checkout
|
||||
from shared.events import emit_activity
|
||||
from shared.infrastructure.actions import call_action
|
||||
from shared.infrastructure.data_client import fetch_data
|
||||
|
||||
|
||||
async def check_sumup_status(session, order, *, page_config=None):
|
||||
# Auto-fetch page_config from blog if order has one and caller didn't provide it
|
||||
if page_config is None and order.page_config_id:
|
||||
raw_pc = await fetch_data(
|
||||
"blog", "page-config-by-id",
|
||||
params={"id": order.page_config_id},
|
||||
required=False,
|
||||
)
|
||||
if raw_pc:
|
||||
page_config = SimpleNamespace(**raw_pc)
|
||||
|
||||
checkout_data = await sumup_get_checkout(order.sumup_checkout_id, page_config=page_config)
|
||||
order.sumup_status = checkout_data.get("status") or order.sumup_status
|
||||
sumup_status = (order.sumup_status or "").upper()
|
||||
|
||||
if sumup_status == "PAID":
|
||||
if order.status != "paid":
|
||||
order.status = "paid"
|
||||
await call_action("events", "confirm-entries-for-order", payload={
|
||||
"order_id": order.id, "user_id": order.user_id,
|
||||
"session_id": order.session_id,
|
||||
})
|
||||
await call_action("events", "confirm-tickets-for-order", payload={
|
||||
"order_id": order.id,
|
||||
})
|
||||
|
||||
page_post_id = page_config.container_id if page_config else None
|
||||
await call_action("cart", "clear-cart-for-order", payload={
|
||||
"user_id": order.user_id,
|
||||
"session_id": order.session_id,
|
||||
"page_post_id": page_post_id,
|
||||
})
|
||||
|
||||
await emit_activity(
|
||||
session,
|
||||
activity_type="rose:OrderPaid",
|
||||
actor_uri="internal:orders",
|
||||
object_type="rose:Order",
|
||||
object_data={
|
||||
"order_id": order.id,
|
||||
"user_id": order.user_id,
|
||||
},
|
||||
source_type="order",
|
||||
source_id=order.id,
|
||||
)
|
||||
elif sumup_status == "FAILED":
|
||||
order.status = "failed"
|
||||
else:
|
||||
order.status = sumup_status.lower() or order.status
|
||||
|
||||
await session.flush()
|
||||
Reference in New Issue
Block a user