aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-backend/src/routes/orders.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-09-13 19:38:02 +0100
committerGravatar Chris Lovering <[email protected]>2024-09-13 19:38:02 +0100
commit1cf3fce85817d4520cd9e98c5c456bf693cc787b (patch)
treeb8def6a2164ac53401d74f7a3ad654aba556246b /thallium-backend/src/routes/orders.py
parentAlso accept a quantity for order items (diff)
Set the external_id of the printful order to the voucher id
Diffstat (limited to 'thallium-backend/src/routes/orders.py')
-rw-r--r--thallium-backend/src/routes/orders.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/thallium-backend/src/routes/orders.py b/thallium-backend/src/routes/orders.py
index c5126a8..20682c0 100644
--- a/thallium-backend/src/routes/orders.py
+++ b/thallium-backend/src/routes/orders.py
@@ -20,11 +20,12 @@ async def create_order(request: Request, db: DBSession, client: PrintfulClient,
If the voucher does not have enough funds, the order is cancelled.
"""
- resp = await client.post("/orders", json=order.as_printful_payload(), params={"confirm": False})
+ voucher: Voucher = request.state.voucher
+
+ resp = await client.post("/orders", json=order.as_printful_payload(voucher), params={"confirm": False})
resp.raise_for_status()
submitted_order = Order.model_validate(resp.json()["result"])
- voucher: Voucher = request.state.voucher
stmt = select(DBVoucher).where(DBVoucher.id == voucher.id).with_for_update()
db_voucher = await db.scalar(stmt)
if submitted_order.costs.total > db_voucher.balance: