Skip to content

Commit

Permalink
[IMP] shopinvader_api_payment_cart: add /current/payable route
Browse files Browse the repository at this point in the history
  • Loading branch information
marielejeune committed Jan 19, 2024
1 parent 0b87fca commit 84e3323
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shopinvader_api_payment_cart/routers/cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# @author Stéphane Bidoul <[email protected]>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from typing import Annotated
from uuid import UUID

from fastapi import Depends, HTTPException

Expand All @@ -18,18 +19,19 @@
from odoo.addons.shopinvader_api_payment.schemas import PaymentData


@cart_router.get("/payable")
@cart_router.get("/{uuid}/payable")
@cart_router.get("/current/payable")
def init(
env: Annotated[api.Environment, Depends(authenticated_partner_env)],
partner: Annotated["ResPartner", Depends(authenticated_partner)],
uuid: str | None = None,
uuid: UUID | None = None,
) -> PaymentData | None:
"""Prepare payment data for the current cart.
This route is authenticated, so we can verify the cart
is accessible by the authenticated partner.
"""
cart = env["sale.order"]._find_open_cart(partner.id, uuid)
cart = env["sale.order"]._find_open_cart(partner.id, str(uuid) if uuid else None)
if not cart:
raise HTTPException(status_code=404)
sale_order = env["sale.order"].browse(cart.id)
Expand Down

0 comments on commit 84e3323

Please sign in to comment.