Buy Orders V2
Create direct purchase order
Changed onCreate a direct purchase order from listing
Creates an order directly from a listing with variant selection, bypassing the cart. This implements "Buy Now" functionality for immediate purchases.
Process:
- Validates listing exists and is active
- Validates variant exists and belongs to listing
- Checks variant availability (sufficient stock)
- Snapshots variant price at purchase time
- Creates order record in V1 orders table
- Creates market_orders entry (V1 compatibility)
- Creates order_market_items_v2 entry with variant tracking
- Allocates stock from variant-specific lots
- Returns order details with purchase summary
Uses database transaction for atomicity to ensure all-or-nothing behavior. Stock allocation uses listing_item_lots directly (V2).
Requirements:
- Validate listing exists and is active
- Validate variant exists and belongs to listing
- Check variant availability before order creation
- Create order with variant-specific line item
- Allocate stock for the variant
- Use database transaction for atomicity
- Snapshot variant price at time of purchase
- Return order_id and purchase summary
- Prevent ordering unavailable variants with descriptive error
- Follow same patterns as cart checkout
post/buy-orders
Request
- Base URL: /api/v2 (relative, and the document was published on a file host, not at the API’s origin)
- URL: /api/v2/buy-orders
- Auth: loggedin (a scheme the document does not define)
Request body
Response
Created order with order_id and purchase details
Changes
- ○
the endpoint scheme security
loggedinwas added to the API - ○
the endpoint scheme security
jwtwas removed from the API
- ○