Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion rest/python/server/services/checkout_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ async def create_checkout(

fulfillment_resp = FulfillmentResponseClass(methods=resp_methods)

# The SDK enforces the totals contains cardinality (exactly one subtotal
# and one total) on the response model. The server is the authority for
# totals and computes them in _recalculate_totals below, but that runs
# after construction. Seed a valid placeholder so the in-progress model
# satisfies the constraint at construction; it is overwritten with the
# authoritative amounts immediately. See python-sdk#57.
checkout = Checkout(
ucp=ResponseCheckout(
version=config.get_server_version(),
Expand All @@ -303,7 +309,10 @@ async def create_checkout(
status=CheckoutStatus.IN_PROGRESS,
currency=checkout_req.currency,
line_items=line_items,
totals=[],
totals=[
{"type": "subtotal", "amount": 0},
{"type": "total", "amount": 0},
],
links=[],
payment=PaymentResponse(
instruments=checkout_req.payment.instruments
Expand Down
Loading