django_program.registration.services.checkout¶
Checkout service for converting carts into orders.
Handles the atomic checkout flow, credit application, and order cancellation. All methods are stateless and operate on model instances directly.
Classes
Stateless service for checkout operations. |
- class django_program.registration.services.checkout.CheckoutService[source]¶
Bases:
objectStateless service for checkout operations.
Converts carts into orders, applies credits, and handles cancellations.
- static checkout(cart, *, billing_name='', billing_email='', billing_company='')[source]¶
Convert a cart into an order atomically.
Re-validates stock, pricing, and voucher validity at checkout time to prevent stale-cart issues. Creates an Order with PENDING status, snapshots each CartItem into OrderLineItems, records voucher details, and marks the cart as CHECKED_OUT.
- Parameters:
- Return type:
- Returns:
The newly created Order with PENDING status.
- Raises:
ValidationError – If the cart is empty, expired, not open, or if stock/price validation fails at checkout time.
- static apply_credit(order, credit)[source]¶
Apply a store credit to an order.
Creates a CREDIT payment record and marks the credit as APPLIED. If the credit covers the full remaining balance, transitions the order to PAID and fires the
order_paidsignal.- Parameters:
- Return type:
- Returns:
The created Payment record.
- Raises:
ValidationError – If the order is not PENDING, the credit is not AVAILABLE, or the credit belongs to a different conference/user.